Skip to content

Commit ca5a9ce

Browse files
committed
Add test and fix dedup
1 parent fd4c6e9 commit ca5a9ce

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/librustc_resolve/resolve_imports.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
13111311
is_redundant.present_items().all(|is_redundant| is_redundant)
13121312
{
13131313
let mut redundant_spans: Vec<_> = redundant_span.present_items().collect();
1314+
redundant_spans.sort();
13141315
redundant_spans.dedup();
13151316
self.session.buffer_lint_with_diagnostic(
13161317
UNUSED_IMPORTS,

src/test/ui/issues/issue-59896.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![deny(unused_imports)]
2+
3+
struct S;
4+
5+
fn main() {
6+
use S; //~ ERROR the item `S` is imported redundantly
7+
8+
let _s = S;
9+
}
10+

src/test/ui/issues/issue-59896.stderr

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error: the item `S` is imported redundantly
2+
--> $DIR/issue-59896.rs:6:9
3+
|
4+
LL | struct S;
5+
| --------- the item `S` is already defined here
6+
...
7+
LL | use S;
8+
| ^
9+
|
10+
note: lint level defined here
11+
--> $DIR/issue-59896.rs:1:9
12+
|
13+
LL | #![deny(unused_imports)]
14+
| ^^^^^^^^^^^^^^
15+
16+
error: aborting due to previous error
17+

0 commit comments

Comments
 (0)