-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
suggest adding a
#[cfg(test)]
to test modules
remove a empty line import `module_to_string` use `contains("test")` show a suggestion in case module starts_with/ends_with "test" replace `parent` with `containing`
- Loading branch information
Showing
6 changed files
with
264 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#![deny(unused_imports)] | ||
|
||
use std::io::BufRead; //~ ERROR unused import: `std::io::BufRead` | ||
|
||
fn a() {} | ||
fn b() {} | ||
|
||
mod test { | ||
use super::a; //~ ERROR unused import: `super::a` | ||
|
||
fn foo() { | ||
use crate::b; //~ ERROR unused import: `crate::b` | ||
} | ||
} | ||
|
||
mod tests { | ||
use super::a; //~ ERROR unused import: `super::a` | ||
|
||
fn foo() { | ||
use crate::b; //~ ERROR unused import: `crate::b` | ||
} | ||
} | ||
|
||
mod test_a { | ||
use super::a; //~ ERROR unused import: `super::a` | ||
|
||
fn foo() { | ||
use crate::b; //~ ERROR unused import: `crate::b` | ||
} | ||
} | ||
|
||
mod a_test { | ||
use super::a; //~ ERROR unused import: `super::a` | ||
|
||
fn foo() { | ||
use crate::b; //~ ERROR unused import: `crate::b` | ||
} | ||
} | ||
|
||
mod tests_a { | ||
use super::a; //~ ERROR unused import: `super::a` | ||
|
||
fn foo() { | ||
use crate::b; //~ ERROR unused import: `crate::b` | ||
} | ||
} | ||
|
||
mod a_tests { | ||
use super::a; //~ ERROR unused import: `super::a` | ||
|
||
fn foo() { | ||
use crate::b; //~ ERROR unused import: `crate::b` | ||
} | ||
} | ||
|
||
mod fastest_search { | ||
use super::a; //~ ERROR unused import: `super::a` | ||
|
||
fn foo() { | ||
use crate::b; //~ ERROR unused import: `crate::b` | ||
} | ||
} | ||
|
||
fn main() {} |
170 changes: 170 additions & 0 deletions
170
src/test/ui/imports/unused-imports-in-test-module.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
error: unused import: `std::io::BufRead` | ||
--> $DIR/unused-imports-in-test-module.rs:3:5 | ||
| | ||
LL | use std::io::BufRead; | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/unused-imports-in-test-module.rs:1:9 | ||
| | ||
LL | #![deny(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: unused import: `super::a` | ||
--> $DIR/unused-imports-in-test-module.rs:9:9 | ||
| | ||
LL | use super::a; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:8:1 | ||
| | ||
LL | mod test { | ||
| ^^^^^^^^ | ||
|
||
error: unused import: `crate::b` | ||
--> $DIR/unused-imports-in-test-module.rs:12:13 | ||
| | ||
LL | use crate::b; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:8:1 | ||
| | ||
LL | mod test { | ||
| ^^^^^^^^ | ||
|
||
error: unused import: `super::a` | ||
--> $DIR/unused-imports-in-test-module.rs:17:9 | ||
| | ||
LL | use super::a; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:16:1 | ||
| | ||
LL | mod tests { | ||
| ^^^^^^^^^ | ||
|
||
error: unused import: `crate::b` | ||
--> $DIR/unused-imports-in-test-module.rs:20:13 | ||
| | ||
LL | use crate::b; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:16:1 | ||
| | ||
LL | mod tests { | ||
| ^^^^^^^^^ | ||
|
||
error: unused import: `super::a` | ||
--> $DIR/unused-imports-in-test-module.rs:25:9 | ||
| | ||
LL | use super::a; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:24:1 | ||
| | ||
LL | mod test_a { | ||
| ^^^^^^^^^^ | ||
|
||
error: unused import: `crate::b` | ||
--> $DIR/unused-imports-in-test-module.rs:28:13 | ||
| | ||
LL | use crate::b; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:24:1 | ||
| | ||
LL | mod test_a { | ||
| ^^^^^^^^^^ | ||
|
||
error: unused import: `super::a` | ||
--> $DIR/unused-imports-in-test-module.rs:33:9 | ||
| | ||
LL | use super::a; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:32:1 | ||
| | ||
LL | mod a_test { | ||
| ^^^^^^^^^^ | ||
|
||
error: unused import: `crate::b` | ||
--> $DIR/unused-imports-in-test-module.rs:36:13 | ||
| | ||
LL | use crate::b; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:32:1 | ||
| | ||
LL | mod a_test { | ||
| ^^^^^^^^^^ | ||
|
||
error: unused import: `super::a` | ||
--> $DIR/unused-imports-in-test-module.rs:41:9 | ||
| | ||
LL | use super::a; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:40:1 | ||
| | ||
LL | mod tests_a { | ||
| ^^^^^^^^^^^ | ||
|
||
error: unused import: `crate::b` | ||
--> $DIR/unused-imports-in-test-module.rs:44:13 | ||
| | ||
LL | use crate::b; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:40:1 | ||
| | ||
LL | mod tests_a { | ||
| ^^^^^^^^^^^ | ||
|
||
error: unused import: `super::a` | ||
--> $DIR/unused-imports-in-test-module.rs:49:9 | ||
| | ||
LL | use super::a; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:48:1 | ||
| | ||
LL | mod a_tests { | ||
| ^^^^^^^^^^^ | ||
|
||
error: unused import: `crate::b` | ||
--> $DIR/unused-imports-in-test-module.rs:52:13 | ||
| | ||
LL | use crate::b; | ||
| ^^^^^^^^ | ||
| | ||
help: consider adding a `#[cfg(test)]` to the containing module | ||
--> $DIR/unused-imports-in-test-module.rs:48:1 | ||
| | ||
LL | mod a_tests { | ||
| ^^^^^^^^^^^ | ||
|
||
error: unused import: `super::a` | ||
--> $DIR/unused-imports-in-test-module.rs:57:9 | ||
| | ||
LL | use super::a; | ||
| ^^^^^^^^ | ||
|
||
error: unused import: `crate::b` | ||
--> $DIR/unused-imports-in-test-module.rs:60:13 | ||
| | ||
LL | use crate::b; | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to 15 previous errors | ||
|