Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reference for attributes in function parameters #657

Merged
merged 2 commits into from
Oct 19, 2019

Conversation

c410-f3r
Copy link
Contributor

I guess this PR shouldn't be added before stabilization but for now it is publicly available for review

src/attributes.md Outdated Show resolved Hide resolved
@Centril

This comment has been minimized.

src/attributes.md Outdated Show resolved Hide resolved
src/attributes.md Show resolved Hide resolved
src/items/functions.md Outdated Show resolved Hide resolved
src/items/functions.md Outdated Show resolved Hide resolved
src/items/functions.md Outdated Show resolved Hide resolved
src/items/external-blocks.md Outdated Show resolved Hide resolved
src/items/external-blocks.md Outdated Show resolved Hide resolved
src/items/external-blocks.md Outdated Show resolved Hide resolved
src/types/function-pointer.md Outdated Show resolved Hide resolved
src/types/function-pointer.md Outdated Show resolved Hide resolved
@ehuss
Copy link
Contributor

ehuss commented Sep 24, 2019

Due to a blunder on my part, I did not see that this had already been done. Can you carry over some of the additional changes from #682 over here? In particular:

  • Method SelfParam should be updated.
  • TraitFunctionParam should be updated.
  • I would, for each thing that adds OuterAttribute, include an "Attributes on…" section with a link to the restrictions list (functions.md#attributes-on-function-parameters). That is, for the closure, function pointer, method, extern blocks, and trait functions/methods pages. That way there is no ambiguity about what is allowed where.

@c410-f3r
Copy link
Contributor Author

@ehuss I will do the additional modifications in this weekend

@c410-f3r c410-f3r force-pushed the attrs-fn branch 2 times, most recently from 21da765 to 77e2be2 Compare September 29, 2019 18:38
@c410-f3r
Copy link
Contributor Author

Updated

src/items/functions.md Outdated Show resolved Hide resolved
src/attributes.md Outdated Show resolved Hide resolved
## Attributes on function parameters

[Outer attributes][attributes] are allowed on function parameters and the
permitted [built-in attributes] are restricted to `cfg`, `cfg_attr`, `allow`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to be clearer about exactly which attributes are allowed, since this doesn't mention that (active) proc macros are forbidden. As Centril pointed out in the release notes (and which took me a while to grok until I read rust-lang/rust#63210), that inert helper attributes are allowed. I'm not sure how to word that clearly.

@ehuss
Copy link
Contributor

ehuss commented Oct 16, 2019

Ping @c410-f3r, do you think you'll be able to update for the changes requested above?

@c410-f3r
Copy link
Contributor Author

Omg! Sorry for the delay

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating!

Inert helper attributes used by procedural macro attributes applied to items are also
allowed but be careful to not include these inert attributes in your final `TokenStream`.

```rust
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```rust
```rust,ignore

This doesn't pass the tests because the attribute isn't defined.


```rust
#[hi_i_am_a_proc_macro_attribute]
fn foo_oof(#[hello_i_am_an_inert_attribute] arg: u8) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment explaining what this is trying to illustrate? Maybe something like this:

// This inert attribute is not formally defined anywhere. The
// `hi_i_am_a_proc_macro_attribute` proc macro is responsible for detecting
// its presence and removing it from the output token stream.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ehuss ehuss merged commit 0757a2d into rust-lang:master Oct 19, 2019
@c410-f3r
Copy link
Contributor Author

@ehuss Thank you

bors added a commit to rust-lang/rust that referenced this pull request Oct 30, 2019
Update cargo, books.

## cargo

8 commits in 3ba5f27170db10af7a92f2b682e049397197b8fa..5da4b4d47963868d9878480197581ccbbdaece74
2019-10-22 15:05:18 +0000 to 2019-10-28 21:53:41 +0000
- Add --filter-platform to `cargo metadata`. (rust-lang/cargo#7376)
- Fix `cargo fix` not showing colors. (rust-lang/cargo#7550)
- Rephrase --manifest-path section (rust-lang/cargo#7409)
- Add a note to discourage the use of -Zminimal-versions. (rust-lang/cargo#7549)
- Fix profile override warning in a workspace. (rust-lang/cargo#7536)
- Fix some tests failing on Windows nightly. (rust-lang/cargo#7534)
- Show better error message for Windows abnormal termination. (rust-lang/cargo#7535)
- Run `apt update` before `apt install` (rust-lang/cargo#7541)

## reference

8 commits in 5b9d2fc..4b21b64
2019-10-03 22:39:10 +0200 to 2019-10-27 22:33:11 +0100
- Document `const_constructor` feature (rust-lang/reference#677)
- Add `non_exhaustive` to reference. (rust-lang/reference#609)
- Re-add rust-docs component for lintcheck (rust-lang/reference#702)
- group signed and unsigned integers in layout table (rust-lang/reference#700)
- Fix layout table rendering (rust-lang/reference#699)
- Add reference for attributes in function parameters (rust-lang/reference#657)
- Update now that proc macros can expand to macro_rules. (rust-lang/reference#694)
- Fix match in union example. (rust-lang/reference#684)

## book

8 commits in 9bb8b161963fcebc9d9ccd732ba26f42108016d5..28fa3d15b0bc67ea5e79eeff2198e4277fc61baf
2019-10-14 18:42:55 -0500 to 2019-10-29 07:16:09 -0500
- Update Ch19.1 on slice splitting (rust-lang/book#1999)
- fixed inconsistent terminology regarding enums (rust-lang/book#2022)
- Update ch15-03 code to match output. (rust-lang/book#2020)
- Fixes rust-lang/book#2039 (rust-lang/book#2040)
- Update ch15-03-drop.md (rust-lang/book#2049)
- unit type value is also a value (rust-lang/book#2061)
- Minor: remove an extraneous `.` (rust-lang/book#2059)
- Clarifications and consistent use of quotation marks (rust-lang/book#1992)

## rust-by-example

4 commits in 0b111eaae36cc4b4997684be853882a59e2c7ca7..f3197ddf2abab9abdbc029def8164f4a748b0d91
2019-10-14 18:34:25 -0300 to 2019-10-29 10:17:40 -0300
- Fix typos (rust-lang/rust-by-example#1285)
- Improve Cargo / Dependencies section (rust-lang/rust-by-example#1287)
- Improve Cargo / Build Scripts section (rust-lang/rust-by-example#1288)
- Make if_let exercise runnable (rust-lang/rust-by-example#1289)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants