Skip to content

Remove duplicated redundant spans #59896

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

Merged
merged 2 commits into from
Apr 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,15 +1310,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),
);
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/issues/issue-59896.rs
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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