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

Improve attribute list syntax suggestion #83232

Open
pickfire opened this issue Mar 17, 2021 · 1 comment
Open

Improve attribute list syntax suggestion #83232

pickfire opened this issue Mar 17, 2021 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pickfire
Copy link
Contributor

Given the following code:

#[doc(alias = ["foo"])]
fn t() {}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: expected unsuffixed literal or identifier, found `[`
 --> src/lib.rs:1:15
  |
1 | #[doc(alias = ["foo"])]
  |               ^

error: aborting due to previous error

error: could not compile `playground`

Ideally the output should look like:

   Compiling playground v0.0.1 (/playground)
error: expected unsuffixed literal or identifier, found `[`
 --> src/lib.rs:1:15
  |
1 | #[doc(alias("foo"))]
  |               ^

error: aborting due to previous error
help: list syntax is not supported for `alias` attribute
suggestion: use `alias("foo")` instead of `alias = ["foo"]`

error: could not compile `playground`

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=dcc601d35deecf1558b3dd66660bf8d5

Follow up of #82846

@pickfire pickfire added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 17, 2021
@jyn514 jyn514 changed the title Improve rustdoc list syntax suggestion Improve attribute list syntax suggestion Mar 18, 2021
@jyn514 jyn514 added the A-parser Area: The parsing of Rust source code to an AST label Mar 18, 2021
@pickfire
Copy link
Contributor Author

pickfire commented Apr 4, 2021

Just saw this in the wild.

    #[clap(aliases = &["baz", "fizz"])]

But clap aliases rather than doc aliases. https://github.com/clap-rs/clap/blob/6ce1e4fda211a7373ce7c4167964e6ca073bdfc1/clap_derive/examples/subcommand_aliases.rs#L13

So it is still possible someone might try this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants