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

**URL:** <https://internals.rust-lang.org/t/solved-attributes-doc-comments-on-function-arguments-rfc/10020>\
**Category:** language design\
**Created:** [May 6, 2019, 1:34pm UTC](https://internals.rust-lang.org/t/solved-attributes-doc-comments-on-function-arguments-rfc/10020 "2019-05-06T13:34:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![theduke](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/theduke/32/2782_2.png) [@theduke](https://internals.rust-lang.org/u/theduke)\
**Post date:** [May 6, 2019, 1:34pm UTC](https://internals.rust-lang.org/t/solved-attributes-doc-comments-on-function-arguments-rfc/10020/1 "2019-05-06T13:34:59Z")

</div>

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 [juniper I’m rewriting a ugly macro into a proc macro](https://github.com/graphql-rust/juniper/pull/333), and the missing support for attributes on arguments creates a considerable usability headache.

Wanted:

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

```

What I currently have to use:

```rust
#[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.

---

<div class="post-metadata">

**Author:** ![djc](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/djc/32/1592_2.png) [@djc](https://internals.rust-lang.org/u/djc)\
**Post date:** [May 6, 2019, 3:01pm UTC](https://internals.rust-lang.org/t/solved-attributes-doc-comments-on-function-arguments-rfc/10020/2 "2019-05-06T15:01:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![theduke](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/theduke/32/2782_2.png) [@theduke](https://internals.rust-lang.org/u/theduke)\
**Post date:** [May 6, 2019, 3:03pm UTC](https://internals.rust-lang.org/t/solved-attributes-doc-comments-on-function-arguments-rfc/10020/3 "2019-05-06T15:03:48Z")

</div>

Yes it is indeed.

And recently merged, no less!

Cheers.

---

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [May 6, 2019, 8:33pm UTC](https://internals.rust-lang.org/t/solved-attributes-doc-comments-on-function-arguments-rfc/10020/4 "2019-05-06T20:33:19Z")

</div>

> [@theduke](#):
>
> Doc comments would allow writing argument specific documentation

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

> <https://github.com/rust-lang/rfcs/issues/2639#issuecomment-464423048>
>
> \[RFC 1574\](https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-docu…mentation-conventions.md) gives the following list of updated common headings:
> 
> \* Examples
> \* Panics
> \* Errors
> \* Safety
> \* Aborts
> \* Undefined Behavior
> 
> This list misses the formal parameters for function/method calls, as well as a description of what is returned. Can you please add \`Parameters\` and \`Returns\` as two more common headings?

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [August 4, 2019, 8:33pm UTC](https://internals.rust-lang.org/t/solved-attributes-doc-comments-on-function-arguments-rfc/10020/5 "2019-08-04T20:33:21Z")

</div>

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