Skip to content

Commit 748c615

Browse files
committed
make unused_imports less assertive in test modules
closes #121502
1 parent e9f9594 commit 748c615

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler/rustc_lint/src/context/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub(super) fn builtin(
108108
if let Some(span) = in_test_module {
109109
db.span_help(
110110
sess.source_map().guess_head_span(span),
111-
"consider adding a `#[cfg(test)]` to the containing module",
111+
"if this is a test module, consider adding a `#[cfg(test)]` to the containing module",
112112
);
113113
}
114114
}

tests/ui/imports/unused-imports-in-test-module.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ error: unused import: `super::a`
1616
LL | use super::a;
1717
| ^^^^^^^^
1818
|
19-
help: consider adding a `#[cfg(test)]` to the containing module
19+
help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module
2020
--> $DIR/unused-imports-in-test-module.rs:8:1
2121
|
2222
LL | mod test {
@@ -28,7 +28,7 @@ error: unused import: `super::a`
2828
LL | use super::a;
2929
| ^^^^^^^^
3030
|
31-
help: consider adding a `#[cfg(test)]` to the containing module
31+
help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module
3232
--> $DIR/unused-imports-in-test-module.rs:18:1
3333
|
3434
LL | mod tests {
@@ -40,7 +40,7 @@ error: unused import: `super::a`
4040
LL | use super::a;
4141
| ^^^^^^^^
4242
|
43-
help: consider adding a `#[cfg(test)]` to the containing module
43+
help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module
4444
--> $DIR/unused-imports-in-test-module.rs:28:1
4545
|
4646
LL | mod test_a {
@@ -52,7 +52,7 @@ error: unused import: `super::a`
5252
LL | use super::a;
5353
| ^^^^^^^^
5454
|
55-
help: consider adding a `#[cfg(test)]` to the containing module
55+
help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module
5656
--> $DIR/unused-imports-in-test-module.rs:38:1
5757
|
5858
LL | mod a_test {
@@ -64,7 +64,7 @@ error: unused import: `super::a`
6464
LL | use super::a;
6565
| ^^^^^^^^
6666
|
67-
help: consider adding a `#[cfg(test)]` to the containing module
67+
help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module
6868
--> $DIR/unused-imports-in-test-module.rs:48:1
6969
|
7070
LL | mod tests_a {
@@ -76,7 +76,7 @@ error: unused import: `super::a`
7676
LL | use super::a;
7777
| ^^^^^^^^
7878
|
79-
help: consider adding a `#[cfg(test)]` to the containing module
79+
help: if this is a test module, consider adding a `#[cfg(test)]` to the containing module
8080
--> $DIR/unused-imports-in-test-module.rs:58:1
8181
|
8282
LL | mod a_tests {

0 commit comments

Comments
 (0)