-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-unnameable_test_itemsLint: unnameable_test_itemsLint: unnameable_test_itemsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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)
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-unnameable_test_itemsLint: unnameable_test_itemsLint: unnameable_test_itemsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.