File tree Expand file tree Collapse file tree 4 files changed +37
-5
lines changed Expand file tree Collapse file tree 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 {
681681 let def_span = self . sess ( ) . source_map ( ) . guess_head_span ( span) ;
682682 db. span_help (
683683 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 " ,
685685 ) ;
686686 }
687687 }
Original file line number Diff line number Diff line change @@ -320,7 +320,7 @@ impl Resolver<'_> {
320320 visitor. r . local_def_id ( unused. use_tree_id ) . to_def_id ( ) ,
321321 ) ;
322322 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 ) ,
324324 _ => None ,
325325 } ;
326326
Original file line number Diff line number Diff line change @@ -13,4 +13,12 @@ mod test {
1313 }
1414}
1515
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+
1624fn main ( ) { }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ error: unused import: `super::a`
1616LL | use super::a;
1717 | ^^^^^^^^
1818 |
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
2020 --> $DIR/unused-imports-in-test-module.rs:8:1
2121 |
2222LL | mod test {
@@ -28,11 +28,35 @@ error: unused import: `crate::b`
2828LL | use crate::b;
2929 | ^^^^^^^^
3030 |
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
3232 --> $DIR/unused-imports-in-test-module.rs:8:1
3333 |
3434LL | mod test {
3535 | ^^^^^^^^
3636
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
3862
You can’t perform that action at this time.
0 commit comments