Tweak unnecessary import suggestion

This commit is contained in:
Esteban Küber 2019-03-10 20:05:01 -07:00
parent 9bfb0ef818
commit 3211f38828
9 changed files with 25 additions and 45 deletions

View File

@ -4932,7 +4932,7 @@ impl<'a> Resolver<'a> {
Some((directive, _, true)) if should_remove_import && !directive.is_glob() => { Some((directive, _, true)) if should_remove_import && !directive.is_glob() => {
// Simple case - remove the entire import. Due to the above match arm, this can // Simple case - remove the entire import. Due to the above match arm, this can
// only be a single use so just remove it entirely. // only be a single use so just remove it entirely.
err.span_suggestion( err.span_suggestion_hidden(
directive.use_span_with_attributes, directive.use_span_with_attributes,
"remove unnecessary import", "remove unnecessary import",
String::new(), String::new(),

View File

@ -4,12 +4,10 @@ error[E0252]: the name `X` is defined multiple times
LL | pub use self::bar::X; LL | pub use self::bar::X;
| ------------ previous import of the type `X` here | ------------ previous import of the type `X` here
LL | use self::bar::X; LL | use self::bar::X;
| ----^^^^^^^^^^^^- | ^^^^^^^^^^^^ `X` reimported here
| | |
| | `X` reimported here
| help: remove unnecessary import
| |
= note: `X` must be defined only once in the type namespace of this module = note: `X` must be defined only once in the type namespace of this module
= help: remove unnecessary import
error: aborting due to previous error error: aborting due to previous error

View File

@ -4,12 +4,10 @@ error[E0252]: the name `foo` is defined multiple times
LL | use a::foo; LL | use a::foo;
| ------ previous import of the value `foo` here | ------ previous import of the value `foo` here
LL | use a::foo; LL | use a::foo;
| ----^^^^^^- | ^^^^^^ `foo` reimported here
| | |
| | `foo` reimported here
| help: remove unnecessary import
| |
= note: `foo` must be defined only once in the value namespace of this module = note: `foo` must be defined only once in the value namespace of this module
= help: remove unnecessary import
error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module) error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module)
--> $DIR/duplicate.rs:46:15 --> $DIR/duplicate.rs:46:15

View File

@ -4,12 +4,10 @@ error[E0252]: the name `Arc` is defined multiple times
LL | use std::sync::{self, Arc}; LL | use std::sync::{self, Arc};
| --- previous import of the type `Arc` here | --- previous import of the type `Arc` here
LL | use std::sync::Arc; LL | use std::sync::Arc;
| ----^^^^^^^^^^^^^^- | ^^^^^^^^^^^^^^ `Arc` reimported here
| | |
| | `Arc` reimported here
| help: remove unnecessary import
| |
= note: `Arc` must be defined only once in the type namespace of this module = note: `Arc` must be defined only once in the type namespace of this module
= help: remove unnecessary import
error[E0252]: the name `sync` is defined multiple times error[E0252]: the name `sync` is defined multiple times
--> $DIR/issue-26886.rs:4:5 --> $DIR/issue-26886.rs:4:5
@ -18,12 +16,10 @@ LL | use std::sync::{self, Arc};
| ---- previous import of the module `sync` here | ---- previous import of the module `sync` here
... ...
LL | use std::sync; LL | use std::sync;
| ----^^^^^^^^^- | ^^^^^^^^^ `sync` reimported here
| | |
| | `sync` reimported here
| help: remove unnecessary import
| |
= note: `sync` must be defined only once in the type namespace of this module = note: `sync` must be defined only once in the type namespace of this module
= help: remove unnecessary import
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -4,12 +4,10 @@ error[E0252]: the name `a` is defined multiple times
LL | use issue_52891::a; LL | use issue_52891::a;
| -------------- previous import of the module `a` here | -------------- previous import of the module `a` here
LL | use issue_52891::a; LL | use issue_52891::a;
| ----^^^^^^^^^^^^^^- | ^^^^^^^^^^^^^^ `a` reimported here
| | |
| | `a` reimported here
| help: remove unnecessary import
| |
= note: `a` must be defined only once in the type namespace of this module = note: `a` must be defined only once in the type namespace of this module
= help: remove unnecessary import
error[E0252]: the name `a` is defined multiple times error[E0252]: the name `a` is defined multiple times
--> $DIR/issue-52891.rs:14:19 --> $DIR/issue-52891.rs:14:19
@ -129,15 +127,13 @@ error[E0252]: the name `n` is defined multiple times
--> $DIR/issue-52891.rs:36:5 --> $DIR/issue-52891.rs:36:5
| |
LL | use issue_52891::n; LL | use issue_52891::n;
| ------------------- | -------------- previous import of the module `n` here
| | |
| | previous import of the module `n` here
| help: remove unnecessary import
LL | #[macro_use] LL | #[macro_use]
LL | use issue_52891::n; LL | use issue_52891::n;
| ^^^^^^^^^^^^^^ `n` reimported here | ^^^^^^^^^^^^^^ `n` reimported here
| |
= note: `n` must be defined only once in the type namespace of this module = note: `n` must be defined only once in the type namespace of this module
= help: remove unnecessary import
error: aborting due to 10 previous errors error: aborting due to 10 previous errors

View File

@ -1,16 +1,14 @@
error[E0259]: the name `derive_a` is defined multiple times error[E0259]: the name `derive_a` is defined multiple times
--> $DIR/shadow.rs:6:1 --> $DIR/shadow.rs:6:1
| |
LL | extern crate derive_a; LL | extern crate derive_a;
| ---------------------- previous import of the extern crate `derive_a` here | ---------------------- previous import of the extern crate `derive_a` here
LL | / #[macro_use] LL | #[macro_use]
LL | | extern crate derive_a; LL | extern crate derive_a;
| | ^^^^^^^^^^^^^^^^^^^^^- | ^^^^^^^^^^^^^^^^^^^^^^ `derive_a` reimported here
| |_|____________________|
| | help: remove unnecessary import
| `derive_a` reimported here
| |
= note: `derive_a` must be defined only once in the type namespace of this module = note: `derive_a` must be defined only once in the type namespace of this module
= help: remove unnecessary import
error: aborting due to previous error error: aborting due to previous error

View File

@ -4,12 +4,10 @@ error[E0252]: the name `transmute` is defined multiple times
LL | use std::mem::transmute; LL | use std::mem::transmute;
| ------------------- previous import of the value `transmute` here | ------------------- previous import of the value `transmute` here
LL | use std::mem::transmute; LL | use std::mem::transmute;
| ----^^^^^^^^^^^^^^^^^^^- | ^^^^^^^^^^^^^^^^^^^ `transmute` reimported here
| | |
| | `transmute` reimported here
| help: remove unnecessary import
| |
= note: `transmute` must be defined only once in the value namespace of this module = note: `transmute` must be defined only once in the value namespace of this module
= help: remove unnecessary import
error: aborting due to previous error error: aborting due to previous error

View File

@ -4,12 +4,10 @@ error[E0254]: the name `core` is defined multiple times
LL | extern crate core; LL | extern crate core;
| ------------------ previous import of the extern crate `core` here | ------------------ previous import of the extern crate `core` here
LL | use core; LL | use core;
| ----^^^^- | ^^^^ `core` reimported here
| | |
| | `core` reimported here
| help: remove unnecessary import
| |
= note: `core` must be defined only once in the type namespace of this module = note: `core` must be defined only once in the type namespace of this module
= help: remove unnecessary import
error: aborting due to previous error error: aborting due to previous error

View File

@ -4,12 +4,10 @@ error[E0252]: the name `mem` is defined multiple times
LL | use std::{mem, ptr}; LL | use std::{mem, ptr};
| --- previous import of the module `mem` here | --- previous import of the module `mem` here
LL | use std::mem; LL | use std::mem;
| ----^^^^^^^^- | ^^^^^^^^ `mem` reimported here
| | |
| | `mem` reimported here
| help: remove unnecessary import
| |
= note: `mem` must be defined only once in the type namespace of this module = note: `mem` must be defined only once in the type namespace of this module
= help: remove unnecessary import
error: aborting due to previous error error: aborting due to previous error