File tree 4 files changed +37
-5
lines changed
4 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -681,7 +681,7 @@ pub trait LintContext: Sized {
681
681
let def_span = self . sess ( ) . source_map ( ) . guess_head_span ( span) ;
682
682
db. span_help (
683
683
span. shrink_to_lo ( ) . to ( def_span) ,
684
- "consider adding a `#[cfg(test)]` to the module named `test` in which this import is " ,
684
+ "consider adding a `#[cfg(test)]` to the parent module " ,
685
685
) ;
686
686
}
687
687
}
Original file line number Diff line number Diff line change @@ -320,7 +320,7 @@ impl Resolver<'_> {
320
320
visitor. r . local_def_id ( unused. use_tree_id ) . to_def_id ( ) ,
321
321
) ;
322
322
let test_module_span = match module_to_string ( parent_module) {
323
- Some ( module) if module == "test" => Some ( parent_module. span ) ,
323
+ Some ( module) if module. contains ( "test" ) => Some ( parent_module. span ) ,
324
324
_ => None ,
325
325
} ;
326
326
Original file line number Diff line number Diff line change @@ -13,4 +13,12 @@ mod test {
13
13
}
14
14
}
15
15
16
+ mod test_a {
17
+ use super :: a; //~ ERROR unused import: `super::a`
18
+
19
+ fn foo ( ) {
20
+ use crate :: b; //~ ERROR unused import: `crate::b`
21
+ }
22
+ }
23
+
16
24
fn main ( ) { }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ error: unused import: `super::a`
16
16
LL | use super::a;
17
17
| ^^^^^^^^
18
18
|
19
- help: consider adding a `#[cfg(test)]` to the module named `test` in which this import is
19
+ help: consider adding a `#[cfg(test)]` to the parent module
20
20
--> $DIR/unused-imports-in-test-module.rs:8:1
21
21
|
22
22
LL | mod test {
@@ -28,11 +28,35 @@ error: unused import: `crate::b`
28
28
LL | use crate::b;
29
29
| ^^^^^^^^
30
30
|
31
- help: consider adding a `#[cfg(test)]` to the module named `test` in which this import is
31
+ help: consider adding a `#[cfg(test)]` to the parent module
32
32
--> $DIR/unused-imports-in-test-module.rs:8:1
33
33
|
34
34
LL | mod test {
35
35
| ^^^^^^^^
36
36
37
- error: aborting due to 3 previous errors
37
+ error: unused import: `super::a`
38
+ --> $DIR/unused-imports-in-test-module.rs:17:9
39
+ |
40
+ LL | use super::a;
41
+ | ^^^^^^^^
42
+ |
43
+ help: consider adding a `#[cfg(test)]` to the parent module
44
+ --> $DIR/unused-imports-in-test-module.rs:16:1
45
+ |
46
+ LL | mod test_a {
47
+ | ^^^^^^^^^^
48
+
49
+ error: unused import: `crate::b`
50
+ --> $DIR/unused-imports-in-test-module.rs:20:13
51
+ |
52
+ LL | use crate::b;
53
+ | ^^^^^^^^
54
+ |
55
+ help: consider adding a `#[cfg(test)]` to the parent module
56
+ --> $DIR/unused-imports-in-test-module.rs:16:1
57
+ |
58
+ LL | mod test_a {
59
+ | ^^^^^^^^^^
60
+
61
+ error: aborting due to 5 previous errors
38
62
You can’t perform that action at this time.
0 commit comments