Skip to content

Commit

Permalink
Add test and fix dedup
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Apr 12, 2019
1 parent fd4c6e9 commit ca5a9ce
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc_resolve/resolve_imports.rs
Expand Up @@ -1311,6 +1311,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
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,
Expand Down
10 changes: 10 additions & 0 deletions 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;
}

17 changes: 17 additions & 0 deletions 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

0 comments on commit ca5a9ce

Please sign in to comment.