Skip to content

Commit

Permalink
add #[test] to functions in test modules
Browse files Browse the repository at this point in the history
  • Loading branch information
TaKO8Ki committed Jul 8, 2022
1 parent fac8fa5 commit 29dc72d
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 186 deletions.
54 changes: 36 additions & 18 deletions src/test/ui/imports/unused-imports-in-test-mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,94 @@ fn a() {}
fn b() {}

mod test {
use super::a; //~ ERROR unused import: `super::a`
use super::a;

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod tests {
use super::a; //~ ERROR unused import: `super::a`
use super::a;

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod test_a {
use super::a; //~ ERROR unused import: `super::a`
use super::a;

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod a_test {
use super::a; //~ ERROR unused import: `super::a`
use super::a;

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod tests_a {
use super::a; //~ ERROR unused import: `super::a`
use super::a;

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod a_tests {
use super::a; //~ ERROR unused import: `super::a`
use super::a;

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod fastest_search {
use super::a; //~ ERROR unused import: `super::a`
use super::a;

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b; //~ ERROR unused import: `crate::b`
}
}

#[cfg(test)]
mod test_has_attr {
use super::a; //~ ERROR unused import: `super::a`
use super::a;

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod test_has_no_attr {
#[cfg(test)]
use super::a; //~ ERROR unused import: `super::a`
use super::a;

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b; //~ ERROR unused import: `crate::b`
}
}

Expand Down
74 changes: 10 additions & 64 deletions src/test/ui/imports/unused-imports-in-test-mode.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,113 +10,59 @@ note: the lint level is defined here
LL | #![deny(unused_imports)]
| ^^^^^^^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:11:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:14:13
--> $DIR/unused-imports-in-test-mode.rs:16:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:19:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:22:13
--> $DIR/unused-imports-in-test-mode.rs:26:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:27:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:30:13
--> $DIR/unused-imports-in-test-mode.rs:36:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:35:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:38:13
--> $DIR/unused-imports-in-test-mode.rs:46:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:43:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:46:13
--> $DIR/unused-imports-in-test-mode.rs:56:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:51:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:54:13
--> $DIR/unused-imports-in-test-mode.rs:66:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:59:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:62:13
--> $DIR/unused-imports-in-test-mode.rs:76:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:68:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:71:13
--> $DIR/unused-imports-in-test-mode.rs:87:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:77:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:80:13
--> $DIR/unused-imports-in-test-mode.rs:98:13
|
LL | use crate::b;
| ^^^^^^^^

error: aborting due to 19 previous errors
error: aborting due to 10 previous errors

53 changes: 39 additions & 14 deletions src/test/ui/imports/unused-imports-in-test-module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,83 @@ fn a() {}
fn b() {}

mod test {
use super::a; //~ ERROR unused import: `super::a`
use super::a; //~ ERROR unused import: `super::a`

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b;
}
}

mod tests {
use super::a; //~ ERROR unused import: `super::a`
use super::a; //~ ERROR unused import: `super::a`

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b;
}
}

mod test_a {
use super::a; //~ ERROR unused import: `super::a`
use super::a; //~ ERROR unused import: `super::a`

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b;
}
}

mod a_test {
use super::a; //~ ERROR unused import: `super::a`
use super::a; //~ ERROR unused import: `super::a`

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b;
}
}

mod tests_a {
use super::a; //~ ERROR unused import: `super::a`
use super::a; //~ ERROR unused import: `super::a`

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b;
}
}

mod a_tests {
use super::a; //~ ERROR unused import: `super::a`
use super::a; //~ ERROR unused import: `super::a`

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b;
}
}

mod fastest_search {
use super::a; //~ ERROR unused import: `super::a`
use super::a; //~ ERROR unused import: `super::a`

#[test]
fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
a();
use crate::b;
}
}

#[cfg(test)]
mod test_has_attr {
use super::a;

#[test]
fn foo() {
a();
use crate::b;
}
}

Expand Down
Loading

0 comments on commit 29dc72d

Please sign in to comment.