[Solved] Attributes + doc comments on function arguments (RFC?)

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.


impl SomeType {
  fn field(
    /// Argument description.
    #[graphql(default = true)]
    some_argument: bool,
  ) -> bool { 

What I currently have to use:

impl SomeType {
    arguments = (
        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.

I think this is https://github.com/rust-lang/rfcs/pull/2565?

Yes it is indeed.

And recently merged, no less!


1 Like

Please be very careful moving in this direction. For details, see my comment in

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.