Open
Description
Code
fn _outer_function() {
mod tests {
#[test]
fn inner_test() {}
}
}
Current output
warning: function `inner_test` is never used
--> src/lib.rs:4:12
|
4 | fn inner_test() {}
| ^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
Desired output
warning: cannot test inner items
--> src/lib.rs:3:9
|
3 | #[test]
| ^^^^^^^
|
= note: `#[warn(unnameable_test_items)]` on by default
= note: this warning originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
Rationale and extra context
The desired warning is produced if mod tests
is removed so that the inner_test()
is directly in the function. The warning should be produced in both cases, since both cases are tests that will not be run.
The warning was last changed in #114414.
Rust Version
Stable 1.81.0 and nightly 1.83.0-nightly (2024-10-05 9096f4f)