Code
// inside some file that is inside a crate's tests
#![feature(something)]
Current output
warning: the `#![feature]` attribute can only be used at the crate root
Desired output
warning: the `#![feature]` attribute can only be used at the crate root
...
help: add `#![feature(something)]` to path/to/crate/root/lib.rs
Rationale and extra context
Normally the crate root file is fairly obvious but there are cases, like with integration tests, where it is not. Even for more experienced programmers, "crate root" can be a slightly puzzling turn of phrase.
Other cases
Rust Version
rustc 1.96.0-nightly (55e86c996 2026-04-02)
binary: rustc
commit-hash: 55e86c996809902e8bbad512cfb4d2c18be446d9
commit-date: 2026-04-02
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2
Anything else?
Issue is an extraction from #144935 (comment)
Code
Current output
warning: the `#![feature]` attribute can only be used at the crate rootDesired output
Rationale and extra context
Normally the crate root file is fairly obvious but there are cases, like with integration tests, where it is not. Even for more experienced programmers, "crate root" can be a slightly puzzling turn of phrase.
Other cases
Rust Version
Anything else?
Issue is an extraction from #144935 (comment)