Code
mod tests_revision_unpaired_stdout_stderr {
use std::ptr;
}
fn main() {}
Current output
warning: unused import: `std::ptr`
--> src/main.rs:2:9
|
2 | use std::ptr;
| ^^^^^^^^
|
help: consider adding a `#[cfg(test)]` to the containing module
--> src/main.rs:1:1
|
1 | mod tests_revision_unpaired_stdout_stderr {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(unused_imports)]` on by default
Desired output
warning: unused import: `std::ptr`
--> src/main.rs:2:9
|
2 | use std::ptr;
| ^^^^^^^^
|
help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module
--> src/main.rs:1:1
|
1 | mod tests_revision_unpaired_stdout_stderr {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(unused_imports)]` on by default
Rationale and extra context
This help message seems weird. I'd expect the help to be more like:
- Consider adding
#[allow(unused_imports)] if you want to silent the lint on the unused import
- Consider removing the unused import
Suggesting to add #[cfg(test)] to the module is the least expected option, and it seems too assertive in its current wording.
Other cases
No response
Rust Version
rustc 1.78.0-nightly (bb594538f 2024-02-20)
binary: rustc
commit-hash: bb594538fc6e84213a6b8d5e165442570aa48923
commit-date: 2024-02-20
host: x86_64-apple-darwin
release: 1.78.0-nightly
LLVM version: 18.1.0
Anything else?
Perhaps the detection for triggering #[cfg(test)] on the module could be smarter and only consider a module as a potential test module if it contains at least one #[test] annotated function?
Code
Current output
Desired output
Rationale and extra context
This help message seems weird. I'd expect the help to be more like:
#[allow(unused_imports)]if you want to silent the lint on the unused importSuggesting to add
#[cfg(test)]to the module is the least expected option, and it seems too assertive in its current wording.Other cases
No response
Rust Version
Anything else?
Perhaps the detection for triggering
#[cfg(test)]on the module could be smarter and only consider a module as a potential test module if it contains at least one#[test]annotated function?