Skip to content

Improve attribute list syntax suggestion #83232

Open
@pickfire

Description

@pickfire

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions