mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 04:56:25 +03:00
89777addb4
Show crate root path in misplaced crate-level attribute diagnostic Fixes rust-lang/rust#157001 If you put `#![feature(...)]` inside a non-root module, the diagnostic tells you it can only be used at the crate root, but never says where the crate root actually is. Not great if you're new to Rust or working in a big workspace with nested modules. Now the diagnostic includes a help line with the crate root file path when the misplaced attribute is an inner attribute. Outer attributes already get a span note pointing at what they're applied to, so they don't need this. Path goes through `RemapPathScopeComponents::DIAGNOSTICS` so `--remap-path-prefix` is respected. ``` warning: the `#![feature]` attribute can only be used at the crate root --> src/foo.rs:1:1 | LL | #![feature(test)] | ^^^^^^^^^^^^^^^^^ | = help: the crate root is at `src/main.rs` ```