I am wondering why attributes and doc comments (AFAIK doc comments “expand” to attributes internally) are not allowed on function arguments.
I have two motiviations:
-
Doc comments would allow writing argument specific documentation, and allow
rustdoc
to render it appropriately -
customization inside of proc macros
In the last few weeks, I have come across two examples attributes on arguments would be very useful.
I imagine there are plenty of cases where this would be useful. One example below.
In juniper I’m rewriting a ugly macro into a proc macro, and the missing support for attributes on arguments creates a considerable usability headache.
Wanted:
#[impl_object]
impl SomeType {
fn field(
/// Argument description.
#[graphql(default = true)]
some_argument: bool,
) -> bool {
...
}
}
What I currently have to use:
#[impl_object]
impl SomeType {
#[graphql(
arguments = (
some_argument(
description = "...",
default = true
)
)
)]
fn field(some_argument: bool) -> bool { ... }
}
Maybe there is some internal reason why this is not currently the case, or other reasons why this is not wanted?
If not, I’d consider this RFC worhty and would be happy to work on one.