Re-add the "perhaps you meant to use an outer attribute" hint to target checking
Open
Nobody has claimed this yet.
A-attributes
A-diagnostics
D-lack-of-suggestion
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
#![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 !.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the diagnostic with the issue's #![rustc_main] crate-level attribute example and compare it with the desired output. Trace the target-checking path involved in the regression, then verify that the outer-attribute suggestion and replacement span appear while the existing error remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100