-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Description
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 patternRational
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.