diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-04-14 17:49:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-14 17:49:21 +0200 |
| commit | 99a91094ec714b5414b3eecc662fa6d9e4589dc9 (patch) | |
| tree | 015577f081e88190aed2c041ac909d8304f2618c | |
| parent | 27adc935fb0c4391d9e8985b0fb77ad4d8c14dfd (diff) | |
| parent | ca5a9ce2a131b117f1d7f70163d96623ab9ca213 (diff) | |
| download | rust-99a91094ec714b5414b3eecc662fa6d9e4589dc9.tar.gz rust-99a91094ec714b5414b3eecc662fa6d9e4589dc9.zip | |
Rollup merge of #59896 - estebank:dedup-spans, r=davidtwco
Remove duplicated redundant spans Fix #59895.
| -rw-r--r-- | src/librustc_resolve/resolve_imports.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-59896.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-59896.stderr | 17 |
3 files changed, 31 insertions, 4 deletions
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 9f6395fa907..58e0df1cd7c 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -1313,15 +1313,15 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { if !is_redundant.is_empty() && is_redundant.present_items().all(|is_redundant| is_redundant) { + let mut redundant_spans: Vec<_> = redundant_span.present_items().collect(); + redundant_spans.sort(); + redundant_spans.dedup(); self.session.buffer_lint_with_diagnostic( UNUSED_IMPORTS, directive.id, directive.span, &format!("the item `{}` is imported redundantly", ident), - BuiltinLintDiagnostics::RedundantImport( - redundant_span.present_items().collect(), - ident, - ), + BuiltinLintDiagnostics::RedundantImport(redundant_spans, ident), ); } } diff --git a/src/test/ui/issues/issue-59896.rs b/src/test/ui/issues/issue-59896.rs new file mode 100644 index 00000000000..cecf2c5c22b --- /dev/null +++ b/src/test/ui/issues/issue-59896.rs @@ -0,0 +1,10 @@ +#![deny(unused_imports)] + +struct S; + +fn main() { + use S; //~ ERROR the item `S` is imported redundantly + + let _s = S; +} + diff --git a/src/test/ui/issues/issue-59896.stderr b/src/test/ui/issues/issue-59896.stderr new file mode 100644 index 00000000000..ef78f27fa69 --- /dev/null +++ b/src/test/ui/issues/issue-59896.stderr @@ -0,0 +1,17 @@ +error: the item `S` is imported redundantly + --> $DIR/issue-59896.rs:6:9 + | +LL | struct S; + | --------- the item `S` is already defined here +... +LL | use S; + | ^ + | +note: lint level defined here + --> $DIR/issue-59896.rs:1:9 + | +LL | #![deny(unused_imports)] + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + |
