Skip to content

Commit

Permalink
Replace REDUNDANT_IMPORT with UNUSED_IMPORTS
Browse files Browse the repository at this point in the history
  • Loading branch information
fabric-and-ink committed Mar 30, 2019
1 parent f927236 commit 6e7b45e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 72 deletions.
8 changes: 1 addition & 7 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,6 @@ declare_lint! {
"nested occurrence of `impl Trait` type"
}

declare_lint! {
pub REDUNDANT_IMPORT,
Warn,
"redundant import"
}

/// Does nothing as a lint pass, but registers some `Lint`s
/// that are used by other parts of the compiler.
#[derive(Copy, Clone)]
Expand Down Expand Up @@ -591,7 +585,7 @@ impl BuiltinLintDiagnostics {
let introduced = if is_imported { "imported" } else { "defined" };
db.span_label(
span,
format!("the item `{}` was {} here", ident, introduced)
format!("the item `{}` was already {} here", ident, introduced)
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc::lint::builtin::BuiltinLintDiagnostics;
use rustc::lint::builtin::{
DUPLICATE_MACRO_EXPORTS,
PUB_USE_OF_PRIVATE_EXTERN_CRATE,
REDUNDANT_IMPORT,
UNUSED_IMPORTS,
};
use rustc::hir::def_id::{CrateNum, DefId};
use rustc::hir::def::*;
Expand Down Expand Up @@ -1308,7 +1308,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
is_redundant.present_items().all(|is_redundant| is_redundant)
{
self.session.buffer_lint_with_diagnostic(
REDUNDANT_IMPORT,
UNUSED_IMPORTS,
directive.id,
directive.span,
&format!("the item `{}` is imported redundantly", ident),
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/lint/lint-unused-imports.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![deny(unused_imports)]
#![allow(dead_code)]
#![allow(redundant_import)]

use bar::c::cc as cal;

Expand Down
10 changes: 4 additions & 6 deletions src/test/ui/lint/lint-unused-imports.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ error: unused import: `foo::Square`
LL | use foo::Square;
| ^^^^^^^^^^^

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

error: unused import: `self::g`
--> $DIR/lint-unused-imports.rs:68:9
|
LL | use self::g;
| ^^^^^^^

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

error: aborting due to 8 previous errors
error: aborting due to 10 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/rust-2018/future-proofing-locals.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// edition:2018

#![allow(non_camel_case_types)]
#![allow(redundant_import)]
#![allow(unused_imports)]

mod T {
pub struct U;
Expand Down
64 changes: 9 additions & 55 deletions src/test/ui/rust-2018/future-proofing-locals.stderr
Original file line number Diff line number Diff line change
@@ -1,102 +1,56 @@
error: imports cannot refer to type parameters
--> $DIR/future-proofing-locals.rs:13:9
--> $DIR/future-proofing-locals.rs:14:9
|
LL | use T as _;
| ^

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

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

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

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

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

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

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

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

warning: the item `T` is imported redundantly
--> $DIR/future-proofing-locals.rs:19:9
|
LL | / mod T {
LL | | pub struct U;
LL | | }
| |_- the item `T` was already imported here
...
LL | use T;
| ^
|
= note: #[warn(redundant_import)] on by default

warning: the item `x` is imported redundantly
--> $DIR/future-proofing-locals.rs:31:9
|
LL | / mod x {
LL | | pub struct y;
LL | | }
| |_- the item `x` was already imported here
...
LL | use x;
| ^

warning: the item `x` is imported redundantly
--> $DIR/future-proofing-locals.rs:37:17
|
LL | / mod x {
LL | | pub struct y;
LL | | }
| |_- the item `x` was already imported here
...
LL | use x;
| ^

warning: the item `x` is imported redundantly
--> $DIR/future-proofing-locals.rs:45:18
|
LL | / mod x {
LL | | pub struct y;
LL | | }
| |_- the item `x` was already imported here
...
LL | use {T as _, x};
| ^

error: aborting due to 9 previous errors

0 comments on commit 6e7b45e

Please sign in to comment.