-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add suggestion for duplicated import. #57973
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
pub mod a { | ||
pub mod inner { | ||
} | ||
} | ||
|
||
pub mod b { | ||
pub mod inner { | ||
} | ||
} | ||
|
||
pub mod c {} | ||
|
||
pub mod d {} | ||
|
||
pub mod e {} | ||
|
||
pub mod f {} | ||
|
||
pub mod g {} | ||
|
||
pub mod h {} | ||
|
||
pub mod i {} | ||
|
||
pub mod j {} | ||
|
||
pub mod k {} | ||
|
||
pub mod l {} | ||
|
||
pub mod m {} | ||
|
||
pub mod n {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// aux-build:issue-52891.rs | ||
// run-rustfix | ||
|
||
#![allow(warnings)] | ||
|
||
extern crate issue_52891; | ||
|
||
// Check that we don't suggest renaming duplicate imports but instead | ||
// suggest removing one. | ||
|
||
use issue_52891::a; | ||
//~ ERROR `a` is defined multiple times | ||
|
||
use issue_52891::{b, c}; //~ ERROR `a` is defined multiple times | ||
use issue_52891::{d, e}; //~ ERROR `a` is defined multiple times | ||
use issue_52891::{f, g}; //~ ERROR `a` is defined multiple times | ||
|
||
use issue_52891::{//~ ERROR `a` is defined multiple times | ||
h, | ||
i}; | ||
use issue_52891::{j, | ||
//~ ERROR `a` is defined multiple times | ||
k}; | ||
use issue_52891::{l, | ||
m}; //~ ERROR `a` is defined multiple times | ||
|
||
use issue_52891::a::inner; | ||
use issue_52891::b::inner as other_inner; //~ ERROR `inner` is defined multiple times | ||
|
||
|
||
//~^ ERROR `issue_52891` is defined multiple times | ||
|
||
|
||
#[macro_use] | ||
use issue_52891::n; //~ ERROR `n` is defined multiple times | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// aux-build:issue-52891.rs | ||
// run-rustfix | ||
|
||
#![allow(warnings)] | ||
|
||
extern crate issue_52891; | ||
|
||
// Check that we don't suggest renaming duplicate imports but instead | ||
// suggest removing one. | ||
|
||
use issue_52891::a; | ||
use issue_52891::a; //~ ERROR `a` is defined multiple times | ||
|
||
use issue_52891::{a, b, c}; //~ ERROR `a` is defined multiple times | ||
use issue_52891::{d, a, e}; //~ ERROR `a` is defined multiple times | ||
use issue_52891::{f, g, a}; //~ ERROR `a` is defined multiple times | ||
|
||
use issue_52891::{a, //~ ERROR `a` is defined multiple times | ||
h, | ||
i}; | ||
use issue_52891::{j, | ||
a, //~ ERROR `a` is defined multiple times | ||
k}; | ||
use issue_52891::{l, | ||
m, | ||
a}; //~ ERROR `a` is defined multiple times | ||
davidtwco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
use issue_52891::a::inner; | ||
use issue_52891::b::inner; //~ ERROR `inner` is defined multiple times | ||
|
||
use issue_52891::{self}; | ||
//~^ ERROR `issue_52891` is defined multiple times | ||
|
||
use issue_52891::n; | ||
#[macro_use] | ||
use issue_52891::n; //~ ERROR `n` is defined multiple times | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
error[E0252]: the name `a` is defined multiple times | ||
--> $DIR/issue-52891.rs:12:5 | ||
| | ||
LL | use issue_52891::a; | ||
| -------------- previous import of the module `a` here | ||
LL | use issue_52891::a; //~ ERROR `a` is defined multiple times | ||
| ----^^^^^^^^^^^^^^- | ||
| | | | ||
| | `a` reimported here | ||
| help: remove unnecessary import | ||
| | ||
= note: `a` must be defined only once in the type namespace of this module | ||
|
||
error[E0252]: the name `a` is defined multiple times | ||
--> $DIR/issue-52891.rs:14:19 | ||
| | ||
LL | use issue_52891::a; | ||
| -------------- previous import of the module `a` here | ||
... | ||
LL | use issue_52891::{a, b, c}; //~ ERROR `a` is defined multiple times | ||
| ^-- | ||
| | | ||
| `a` reimported here | ||
| help: remove unnecessary import | ||
| | ||
= note: `a` must be defined only once in the type namespace of this module | ||
|
||
error[E0252]: the name `a` is defined multiple times | ||
--> $DIR/issue-52891.rs:15:22 | ||
| | ||
LL | use issue_52891::a; | ||
| -------------- previous import of the module `a` here | ||
... | ||
LL | use issue_52891::{d, a, e}; //~ ERROR `a` is defined multiple times | ||
| ^-- | ||
| | | ||
| `a` reimported here | ||
| help: remove unnecessary import | ||
| | ||
= note: `a` must be defined only once in the type namespace of this module | ||
|
||
error[E0252]: the name `a` is defined multiple times | ||
--> $DIR/issue-52891.rs:16:25 | ||
| | ||
LL | use issue_52891::a; | ||
| -------------- previous import of the module `a` here | ||
... | ||
LL | use issue_52891::{f, g, a}; //~ ERROR `a` is defined multiple times | ||
| --^ | ||
| | | | ||
| | `a` reimported here | ||
| help: remove unnecessary import | ||
| | ||
= note: `a` must be defined only once in the type namespace of this module | ||
|
||
error[E0252]: the name `a` is defined multiple times | ||
--> $DIR/issue-52891.rs:18:19 | ||
| | ||
LL | use issue_52891::a; | ||
| -------------- previous import of the module `a` here | ||
... | ||
LL | use issue_52891::{a, //~ ERROR `a` is defined multiple times | ||
| ^-- | ||
| | | ||
| `a` reimported here | ||
| help: remove unnecessary import | ||
| | ||
= note: `a` must be defined only once in the type namespace of this module | ||
|
||
error[E0252]: the name `a` is defined multiple times | ||
--> $DIR/issue-52891.rs:22:5 | ||
| | ||
LL | use issue_52891::a; | ||
| -------------- previous import of the module `a` here | ||
... | ||
LL | a, //~ ERROR `a` is defined multiple times | ||
| ^-- | ||
| | | ||
| `a` reimported here | ||
| help: remove unnecessary import | ||
| | ||
= note: `a` must be defined only once in the type namespace of this module | ||
|
||
error[E0252]: the name `a` is defined multiple times | ||
--> $DIR/issue-52891.rs:26:5 | ||
| | ||
LL | use issue_52891::a; | ||
| -------------- previous import of the module `a` here | ||
... | ||
LL | m, | ||
| ______- | ||
LL | | a}; //~ ERROR `a` is defined multiple times | ||
| | - | ||
| | | | ||
| |_____`a` reimported here | ||
| help: remove unnecessary import | ||
| | ||
= note: `a` must be defined only once in the type namespace of this module | ||
|
||
error[E0252]: the name `inner` is defined multiple times | ||
--> $DIR/issue-52891.rs:29:5 | ||
| | ||
LL | use issue_52891::a::inner; | ||
| --------------------- previous import of the module `inner` here | ||
LL | use issue_52891::b::inner; //~ ERROR `inner` is defined multiple times | ||
| ^^^^^^^^^^^^^^^^^^^^^ `inner` reimported here | ||
| | ||
= note: `inner` must be defined only once in the type namespace of this module | ||
help: you can use `as` to change the binding name of the import | ||
| | ||
LL | use issue_52891::b::inner as other_inner; //~ ERROR `inner` is defined multiple times | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0254]: the name `issue_52891` is defined multiple times | ||
--> $DIR/issue-52891.rs:31:19 | ||
| | ||
LL | extern crate issue_52891; | ||
| ------------------------- previous import of the extern crate `issue_52891` here | ||
... | ||
LL | use issue_52891::{self}; | ||
| ------------------^^^^-- | ||
| | | | ||
| | `issue_52891` reimported here | ||
| help: remove unnecessary import | ||
| | ||
= note: `issue_52891` must be defined only once in the type namespace of this module | ||
|
||
error[E0252]: the name `n` is defined multiple times | ||
--> $DIR/issue-52891.rs:36:5 | ||
| | ||
LL | use issue_52891::n; | ||
| ------------------- | ||
| | | | ||
| | previous import of the module `n` here | ||
| help: remove unnecessary import | ||
LL | #[macro_use] | ||
LL | use issue_52891::n; //~ ERROR `n` is defined multiple times | ||
| ^^^^^^^^^^^^^^ `n` reimported here | ||
davidtwco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| | ||
= note: `n` must be defined only once in the type namespace of this module | ||
|
||
error: aborting due to 10 previous errors | ||
|
||
Some errors occurred: E0252, E0254. | ||
For more information about an error, try `rustc --explain E0252`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
error[E0259]: the name `derive_a` is defined multiple times | ||
--> $DIR/shadow.rs:6:1 | ||
| | ||
LL | extern crate derive_a; | ||
| ---------------------- previous import of the extern crate `derive_a` here | ||
LL | #[macro_use] | ||
LL | extern crate derive_a; //~ ERROR the name `derive_a` is defined multiple times | ||
| ^^^^^^^^^^^^^^^^^^^^^^ `derive_a` reimported here | ||
LL | extern crate derive_a; | ||
| ---------------------- previous import of the extern crate `derive_a` here | ||
LL | / #[macro_use] | ||
LL | | extern crate derive_a; //~ ERROR the name `derive_a` is defined multiple times | ||
| | ^^^^^^^^^^^^^^^^^^^^^- | ||
| |_|____________________| | ||
| | help: remove unnecessary import | ||
| `derive_a` reimported here | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great behavior, although we probably should make sure we keep the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've changed this to prefer keeping imports with attributes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It didn't seem to work in this case, but only address if you have time. |
||
| | ||
= note: `derive_a` must be defined only once in the type namespace of this module | ||
help: you can use `as` to change the binding name of the import | ||
| | ||
LL | extern crate derive_a as other_derive_a; //~ ERROR the name `derive_a` is defined multiple times | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.