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

Allow attributes in logical parameter position #55033

Closed
Robbepop opened this issue Oct 13, 2018 · 2 comments
Closed

Allow attributes in logical parameter position #55033

Robbepop opened this issue Oct 13, 2018 · 2 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@Robbepop
Copy link
Contributor

Robbepop commented Oct 13, 2018

Allow attributes in logical parameter position like here

fn foonction(#[my_attribute] bar: u32) -> bool;

Current Situation

The compiler currently simply does not allow for attributes in this position:

error: expected pattern, found `#`
  --> file.rs:15:13
   |
15 |     pub fn foo(#![bar] capacity: usize) -> Self {
   |                ^ expected pattern

Rational

This could be very useful for some procedural macros which was effectively my use case yesterday.
Also I can imagine use cases for something like an #[ignore] attribute to say that a parameter is not in use which is currently implied by prefixing its name with an underscore. However, at least to me such an #[ignore] attribute (or come up with a better name for it) would be much more explicit which sticks better to the explicit nature of the language itself.

Other Sources

On march this year (2018) @petrochenkov was already talking about the usefulness of attributes for formal function parameters in this thread.


If there is anybody who is free of time and wants to give it a try I would be very grateful. Otherwise I would try implementing it in my spare time.

@Centril Centril added T-lang Relevant to the language team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. labels Oct 13, 2018
@Robbepop
Copy link
Contributor Author

Robbepop commented Oct 15, 2018

@Centril created RFC: rust-lang/rfcs#2565

@Centril
Copy link
Contributor

Centril commented Oct 15, 2018

Closed therefore.

@Centril Centril closed this as completed Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants