Skip to content

Re-add the "perhaps you meant to use an outer attribute" hint to target checking #147688

@JonathanBrouwer

Description

@JonathanBrouwer
#![rustc_main]
mod test {

}

Current output

error: `#[rustc_main]` attribute cannot be used on crates
  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1
   |
LL | #![rustc_main]
   | ^^^^^^^^^^^^^^
   |
   = help: `#[rustc_main]` can only be applied to functions

Desired output

error: `#[rustc_main]` attribute cannot be used on crates
  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1
   |
LL | #![rustc_main]
   | ^^^^^^^^^^^^^^
   |
   = help: `#[rustc_main]` can only be applied to functions. perhaps you meant to use an outer attribute
   |
LL - #![rustc_main]
LL + #[rustc_main]

This hint was there before the target checking refactor but not after, and I think it is a nice hint for people who are a little confused about the attribute syntax of rust and accidentally used !.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.T-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