Skip to content

Commit bbbc446

Browse files
Replace REDUNDANT_IMPORT with UNUSED_IMPORTS
1 parent 1062628 commit bbbc446

File tree

6 files changed

+17
-72
lines changed

6 files changed

+17
-72
lines changed

src/librustc/lint/builtin.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,6 @@ declare_lint! {
392392
"nested occurrence of `impl Trait` type"
393393
}
394394

395-
declare_lint! {
396-
pub REDUNDANT_IMPORT,
397-
Warn,
398-
"redundant import"
399-
}
400-
401395
/// Does nothing as a lint pass, but registers some `Lint`s
402396
/// that are used by other parts of the compiler.
403397
#[derive(Copy, Clone)]
@@ -590,7 +584,7 @@ impl BuiltinLintDiagnostics {
590584
let introduced = if is_imported { "imported" } else { "defined" };
591585
db.span_label(
592586
span,
593-
format!("the item `{}` was {} here", ident, introduced)
587+
format!("the item `{}` was already {} here", ident, introduced)
594588
);
595589
}
596590
}

src/librustc_resolve/resolve_imports.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc::lint::builtin::BuiltinLintDiagnostics;
1818
use rustc::lint::builtin::{
1919
DUPLICATE_MACRO_EXPORTS,
2020
PUB_USE_OF_PRIVATE_EXTERN_CRATE,
21-
REDUNDANT_IMPORT,
21+
UNUSED_IMPORTS,
2222
};
2323
use rustc::hir::def_id::{CrateNum, DefId};
2424
use rustc::hir::def::*;
@@ -1311,7 +1311,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
13111311
is_redundant.present_items().all(|is_redundant| is_redundant)
13121312
{
13131313
self.session.buffer_lint_with_diagnostic(
1314-
REDUNDANT_IMPORT,
1314+
UNUSED_IMPORTS,
13151315
directive.id,
13161316
directive.span,
13171317
&format!("the item `{}` is imported redundantly", ident),

src/test/ui/lint/lint-unused-imports.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![deny(unused_imports)]
22
#![allow(dead_code)]
3-
#![allow(redundant_import)]
43

54
use bar::c::cc as cal;
65

src/test/ui/lint/lint-unused-imports.stderr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ error: unused import: `foo::Square`
3434
LL | use foo::Square;
3535
| ^^^^^^^^^^^
3636

37-
warning: the item `g` is imported redundantly
37+
error: the item `g` is imported redundantly
3838
--> $DIR/lint-unused-imports.rs:68:9
3939
|
4040
LL | / fn g() {
@@ -44,17 +44,15 @@ LL | | fn f() {
4444
LL | | self::g();
4545
LL | | }
4646
LL | | }
47-
| |_- the item `g` was already imported here
48-
|
49-
= note: #[warn(redundant_import)] on by default
47+
| |_- the item `g` was already defined here
5048

5149
error: unused import: `self::g`
5250
--> $DIR/lint-unused-imports.rs:68:9
5351
|
5452
LL | use self::g;
5553
| ^^^^^^^
5654

57-
warning: the item `foo` is imported redundantly
55+
error: the item `foo` is imported redundantly
5856
--> $DIR/lint-unused-imports.rs:77:9
5957
|
6058
LL | use test2::{foo, bar};
@@ -75,5 +73,5 @@ error: unused import: `test::B2`
7573
LL | use test::B2;
7674
| ^^^^^^^^
7775

78-
error: aborting due to 8 previous errors
76+
error: aborting due to 10 previous errors
7977

src/test/ui/rust-2018/future-proofing-locals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// edition:2018
22

33
#![allow(non_camel_case_types)]
4-
#![allow(redundant_import)]
4+
#![allow(unused_imports)]
55

66
mod T {
77
pub struct U;
Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,56 @@
11
error: imports cannot refer to type parameters
2-
--> $DIR/future-proofing-locals.rs:13:9
2+
--> $DIR/future-proofing-locals.rs:14:9
33
|
44
LL | use T as _;
55
| ^
66

77
error: imports cannot refer to type parameters
8-
--> $DIR/future-proofing-locals.rs:14:9
8+
--> $DIR/future-proofing-locals.rs:15:9
99
|
1010
LL | use T::U;
1111
| ^
1212

1313
error: imports cannot refer to type parameters
14-
--> $DIR/future-proofing-locals.rs:15:9
14+
--> $DIR/future-proofing-locals.rs:16:9
1515
|
1616
LL | use T::*;
1717
| ^
1818

1919
error: imports cannot refer to type parameters
20-
--> $DIR/future-proofing-locals.rs:19:9
20+
--> $DIR/future-proofing-locals.rs:20:9
2121
|
2222
LL | use T;
2323
| ^
2424

2525
error: imports cannot refer to local variables
26-
--> $DIR/future-proofing-locals.rs:25:9
26+
--> $DIR/future-proofing-locals.rs:26:9
2727
|
2828
LL | use x as _;
2929
| ^
3030

3131
error: imports cannot refer to local variables
32-
--> $DIR/future-proofing-locals.rs:31:9
32+
--> $DIR/future-proofing-locals.rs:32:9
3333
|
3434
LL | use x;
3535
| ^
3636

3737
error: imports cannot refer to local variables
38-
--> $DIR/future-proofing-locals.rs:37:17
38+
--> $DIR/future-proofing-locals.rs:38:17
3939
|
4040
LL | use x;
4141
| ^
4242

4343
error: imports cannot refer to type parameters
44-
--> $DIR/future-proofing-locals.rs:45:10
44+
--> $DIR/future-proofing-locals.rs:46:10
4545
|
4646
LL | use {T as _, x};
4747
| ^
4848

4949
error: imports cannot refer to local variables
50-
--> $DIR/future-proofing-locals.rs:45:18
50+
--> $DIR/future-proofing-locals.rs:46:18
5151
|
5252
LL | use {T as _, x};
5353
| ^
5454

55-
warning: the item `T` is imported redundantly
56-
--> $DIR/future-proofing-locals.rs:19:9
57-
|
58-
LL | / mod T {
59-
LL | | pub struct U;
60-
LL | | }
61-
| |_- the item `T` was already imported here
62-
...
63-
LL | use T;
64-
| ^
65-
|
66-
= note: #[warn(redundant_import)] on by default
67-
68-
warning: the item `x` is imported redundantly
69-
--> $DIR/future-proofing-locals.rs:31:9
70-
|
71-
LL | / mod x {
72-
LL | | pub struct y;
73-
LL | | }
74-
| |_- the item `x` was already imported here
75-
...
76-
LL | use x;
77-
| ^
78-
79-
warning: the item `x` is imported redundantly
80-
--> $DIR/future-proofing-locals.rs:37:17
81-
|
82-
LL | / mod x {
83-
LL | | pub struct y;
84-
LL | | }
85-
| |_- the item `x` was already imported here
86-
...
87-
LL | use x;
88-
| ^
89-
90-
warning: the item `x` is imported redundantly
91-
--> $DIR/future-proofing-locals.rs:45:18
92-
|
93-
LL | / mod x {
94-
LL | | pub struct y;
95-
LL | | }
96-
| |_- the item `x` was already imported here
97-
...
98-
LL | use {T as _, x};
99-
| ^
100-
10155
error: aborting due to 9 previous errors
10256

0 commit comments

Comments
 (0)