Rollup merge of #59896 - estebank:dedup-spans, r=davidtwco
Remove duplicated redundant spans Fix #59895.
This commit is contained in:
commit
99a91094ec
@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
10
src/test/ui/issues/issue-59896.rs
Normal file
10
src/test/ui/issues/issue-59896.rs
Normal file
@ -0,0 +1,10 @@
|
||||
#![deny(unused_imports)]
|
||||
|
||||
struct S;
|
||||
|
||||
fn main() {
|
||||
use S; //~ ERROR the item `S` is imported redundantly
|
||||
|
||||
let _s = S;
|
||||
}
|
||||
|
17
src/test/ui/issues/issue-59896.stderr
Normal file
17
src/test/ui/issues/issue-59896.stderr
Normal file
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user