Skip to content

Commit d53e97c

Browse files
authored
Unrolled build for rust-lang#121580
Rollup merge of rust-lang#121580 - Suyashtnt:issue-121502-fix, r=michaelwoerister make unused_imports less assertive in test modules closes rust-lang#121502 This is a fairly small change and I used the fix suggested in the example expected error message. Not sure if I should've rather used the alternatives but this one seems the most descriptive. Some alternatives: - if this is meant to be a test module, add `#[cfg(test)]` to the containing module - try adding #[cfg(test)] to this test module - consider adding #[allow(unused_imports)] if you want to silent the lint on the unused import - consider removing the unused import
2 parents 17edace + 748c615 commit d53e97c

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
@@ -104,7 +104,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
104104
if let Some(span) = in_test_module {
105105
diag.span_help(
106106
sess.source_map().guess_head_span(span),
107-
"consider adding a `#[cfg(test)]` to the containing module",
107+
"if this is a test module, consider adding a `#[cfg(test)]` to the containing module",
108108
);
109109
}
110110
}

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)