Skip to content

Commit

Permalink
Unrolled build for rust-lang#121580
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rust-timer committed Mar 1, 2024
2 parents 17edace + 748c615 commit d53e97c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/context/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
if let Some(span) = in_test_module {
diag.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",
);
}
}
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/imports/unused-imports-in-test-module.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit d53e97c

Please sign in to comment.