-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove braces when fixing a nested use tree into a single use
- Loading branch information
1 parent
13f7623
commit 2d3a9a5
Showing
4 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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,35 @@ | ||
//@ run-rustfix | ||
//@ check-pass | ||
|
||
#![warn(unused_imports)] | ||
|
||
pub mod nested { | ||
pub struct A; | ||
pub struct B; | ||
pub struct C; | ||
pub struct D; | ||
pub mod even_more { | ||
pub struct E; | ||
pub struct F; | ||
pub struct G; | ||
} | ||
pub mod another { | ||
pub struct H; | ||
pub struct I; | ||
} | ||
} | ||
|
||
use nested::B; | ||
//~^ WARN unused import | ||
|
||
use nested::even_more::F; | ||
//~^^^^^^^ WARN unused import | ||
|
||
// Note that the following fix should result in `::{self}`, not `::self`. The latter is invalid | ||
// Rust syntax, so the braces should not be removed. | ||
use nested::another::{self}; | ||
//~^ WARN unused import | ||
|
||
fn main() { | ||
let _ = (B, F, another::I); | ||
} |
This file contains 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,42 @@ | ||
//@ run-rustfix | ||
//@ check-pass | ||
|
||
#![warn(unused_imports)] | ||
|
||
pub mod nested { | ||
pub struct A; | ||
pub struct B; | ||
pub struct C; | ||
pub struct D; | ||
pub mod even_more { | ||
pub struct E; | ||
pub struct F; | ||
pub struct G; | ||
} | ||
pub mod another { | ||
pub struct H; | ||
pub struct I; | ||
} | ||
} | ||
|
||
use nested::{A, B, C}; | ||
//~^ WARN unused import | ||
|
||
use nested::{ | ||
D, | ||
even_more::{ | ||
E, | ||
F, | ||
G, | ||
}, | ||
}; | ||
//~^^^^^^^ WARN unused import | ||
|
||
// Note that the following fix should result in `::{self}`, not `::self`. The latter is invalid | ||
// Rust syntax, so the braces should not be removed. | ||
use nested::another::{self, I}; | ||
//~^ WARN unused import | ||
|
||
fn main() { | ||
let _ = (B, F, another::I); | ||
} |
This file contains 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,32 @@ | ||
warning: unused imports: `A`, `C` | ||
--> $DIR/unused-imports.rs:22:14 | ||
| | ||
LL | use nested::{A, B, C}; | ||
| ^ ^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/unused-imports.rs:4:9 | ||
| | ||
LL | #![warn(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
warning: unused imports: `D`, `E`, `G` | ||
--> $DIR/unused-imports.rs:26:5 | ||
| | ||
LL | D, | ||
| ^ | ||
LL | even_more::{ | ||
LL | E, | ||
| ^ | ||
LL | F, | ||
LL | G, | ||
| ^ | ||
|
||
warning: unused import: `I` | ||
--> $DIR/unused-imports.rs:37:29 | ||
| | ||
LL | use nested::another::{self, I}; | ||
| ^ | ||
|
||
warning: 3 warnings emitted | ||
|