-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Suggest adding a #[cfg(test)]
to a test module
#90197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
TaKO8Ki
wants to merge
5
commits into
rust-lang:master
from
TaKO8Ki:suggest-adding-cfg-test-to-test-module
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2514bd3
suggest adding a `#[cfg(test)]` to test modules
TaKO8Ki 33b438c
remove a empty line
TaKO8Ki c10028f
import `module_to_string`
TaKO8Ki 3e43de4
use `contains("test")`
TaKO8Ki c597dc8
show a suggestion in case module starts_with/ends_with "test"
TaKO8Ki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 parent 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 parent 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 parent 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 parent 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 parent 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 parent 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 parent 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 parent 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 parent 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 parent 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 parent 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 parent 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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.