diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 462f0947338..6908674bc13 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -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)] @@ -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) ); } } diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index eacbf81347a..99e20c398d9 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -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::*; @@ -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), diff --git a/src/test/ui/lint/lint-unused-imports.rs b/src/test/ui/lint/lint-unused-imports.rs index c7ffdc270c9..9c5b206203c 100644 --- a/src/test/ui/lint/lint-unused-imports.rs +++ b/src/test/ui/lint/lint-unused-imports.rs @@ -1,6 +1,5 @@ #![deny(unused_imports)] #![allow(dead_code)] -#![allow(redundant_import)] use bar::c::cc as cal; diff --git a/src/test/ui/lint/lint-unused-imports.stderr b/src/test/ui/lint/lint-unused-imports.stderr index bf194696f61..62490972420 100644 --- a/src/test/ui/lint/lint-unused-imports.stderr +++ b/src/test/ui/lint/lint-unused-imports.stderr @@ -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() { @@ -44,9 +44,7 @@ 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 @@ -54,7 +52,7 @@ error: unused import: `self::g` 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}; @@ -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 diff --git a/src/test/ui/rust-2018/future-proofing-locals.rs b/src/test/ui/rust-2018/future-proofing-locals.rs index df3badb94e5..2c388cf3713 100644 --- a/src/test/ui/rust-2018/future-proofing-locals.rs +++ b/src/test/ui/rust-2018/future-proofing-locals.rs @@ -1,7 +1,7 @@ // edition:2018 #![allow(non_camel_case_types)] -#![allow(redundant_import)] +#![allow(unused_imports)] mod T { pub struct U; diff --git a/src/test/ui/rust-2018/future-proofing-locals.stderr b/src/test/ui/rust-2018/future-proofing-locals.stderr index fa8333b5d21..7021489a6dd 100644 --- a/src/test/ui/rust-2018/future-proofing-locals.stderr +++ b/src/test/ui/rust-2018/future-proofing-locals.stderr @@ -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