From 748c6151be9906c8bc201fa79b8d1d49715968b2 Mon Sep 17 00:00:00 2001 From: Suyashtnt Date: Sun, 25 Feb 2024 09:37:57 +0200 Subject: [PATCH] make unused_imports less assertive in test modules closes #121502 --- compiler/rustc_lint/src/context/diagnostics.rs | 2 +- .../ui/imports/unused-imports-in-test-module.stderr | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_lint/src/context/diagnostics.rs b/compiler/rustc_lint/src/context/diagnostics.rs index 86434002e2c66..12b6a15eeddb4 100644 --- a/compiler/rustc_lint/src/context/diagnostics.rs +++ b/compiler/rustc_lint/src/context/diagnostics.rs @@ -108,7 +108,7 @@ pub(super) fn builtin( if let Some(span) = in_test_module { db.span_help( sess.source_map().guess_head_span(span), - "consider adding a `#[cfg(test)]` to the containing module", + "if this is a test module, consider adding a `#[cfg(test)]` to the containing module", ); } } diff --git a/tests/ui/imports/unused-imports-in-test-module.stderr b/tests/ui/imports/unused-imports-in-test-module.stderr index 1598368eb32cc..2d885efc099b3 100644 --- a/tests/ui/imports/unused-imports-in-test-module.stderr +++ b/tests/ui/imports/unused-imports-in-test-module.stderr @@ -16,7 +16,7 @@ error: unused import: `super::a` LL | use super::a; | ^^^^^^^^ | -help: consider adding a `#[cfg(test)]` to the containing module +help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module --> $DIR/unused-imports-in-test-module.rs:8:1 | LL | mod test { @@ -28,7 +28,7 @@ error: unused import: `super::a` LL | use super::a; | ^^^^^^^^ | -help: consider adding a `#[cfg(test)]` to the containing module +help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module --> $DIR/unused-imports-in-test-module.rs:18:1 | LL | mod tests { @@ -40,7 +40,7 @@ error: unused import: `super::a` LL | use super::a; | ^^^^^^^^ | -help: consider adding a `#[cfg(test)]` to the containing module +help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module --> $DIR/unused-imports-in-test-module.rs:28:1 | LL | mod test_a { @@ -52,7 +52,7 @@ error: unused import: `super::a` LL | use super::a; | ^^^^^^^^ | -help: consider adding a `#[cfg(test)]` to the containing module +help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module --> $DIR/unused-imports-in-test-module.rs:38:1 | LL | mod a_test { @@ -64,7 +64,7 @@ error: unused import: `super::a` LL | use super::a; | ^^^^^^^^ | -help: consider adding a `#[cfg(test)]` to the containing module +help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module --> $DIR/unused-imports-in-test-module.rs:48:1 | LL | mod tests_a { @@ -76,7 +76,7 @@ error: unused import: `super::a` LL | use super::a; | ^^^^^^^^ | -help: consider adding a `#[cfg(test)]` to the containing module +help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module --> $DIR/unused-imports-in-test-module.rs:58:1 | LL | mod a_tests {