Skip to content
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

Add #[test] to functions in test modules #99036

Merged
merged 1 commit into from
Jul 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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