summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/lint')
-rw-r--r--tests/ui/lint/anonymous-reexport.rs19
-rw-r--r--tests/ui/lint/anonymous-reexport.stderr44
-rw-r--r--tests/ui/lint/clashing-extern-fn.rs33
-rw-r--r--tests/ui/lint/clashing-extern-fn.stderr18
-rw-r--r--tests/ui/lint/dead-code/issue-59003.rs18
-rw-r--r--tests/ui/lint/dead-code/issue-85255.rs12
-rw-r--r--tests/ui/lint/dead-code/issue-85255.stderr54
-rw-r--r--tests/ui/lint/dead-code/lint-dead-code-3.stderr14
-rw-r--r--tests/ui/lint/dead-code/lint-dead-code-6.rs9
-rw-r--r--tests/ui/lint/dead-code/lint-dead-code-6.stderr18
-rw-r--r--tests/ui/lint/dead-code/unused-assoc-fns.rs35
-rw-r--r--tests/ui/lint/dead-code/unused-assoc-fns.stderr29
-rw-r--r--tests/ui/lint/fn_must_use.stderr28
-rw-r--r--tests/ui/lint/inline-trait-and-foreign-items.rs2
-rw-r--r--tests/ui/lint/issue-109152.rs7
-rw-r--r--tests/ui/lint/issue-109152.stderr23
-rw-r--r--tests/ui/lint/issue-109529.fixed6
-rw-r--r--tests/ui/lint/issue-109529.rs6
-rw-r--r--tests/ui/lint/issue-109529.stderr23
-rw-r--r--tests/ui/lint/lint-temporary-cstring-as-ptr.rs8
-rw-r--r--tests/ui/lint/lint-temporary-cstring-as-ptr.stderr19
-rw-r--r--tests/ui/lint/no-coverage.rs2
-rw-r--r--tests/ui/lint/unconditional_panic_98444.rs7
-rw-r--r--tests/ui/lint/unconditional_panic_98444.stderr10
-rw-r--r--tests/ui/lint/unused/auxiliary/must-use-foreign.rs12
-rw-r--r--tests/ui/lint/unused/must-use-box-from-raw.stderr4
-rw-r--r--tests/ui/lint/unused/must-use-foreign.rs15
-rw-r--r--tests/ui/lint/unused/must_use-unit.stderr9
-rw-r--r--tests/ui/lint/unused/trait-alias-supertrait.rs15
-rw-r--r--tests/ui/lint/unused/unused-allocation.rs7
-rw-r--r--tests/ui/lint/unused/unused-allocation.stderr20
-rw-r--r--tests/ui/lint/unused/unused-async.rs2
-rw-r--r--tests/ui/lint/unused/unused-async.stderr21
-rw-r--r--tests/ui/lint/unused/unused-result.stderr17
-rw-r--r--tests/ui/lint/unused/unused_attributes-must_use.stderr34
-rw-r--r--tests/ui/lint/use-redundant/issue-92904.rs17
-rw-r--r--tests/ui/lint/use-redundant/use-redundant-glob-parent.rs16
-rw-r--r--tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr17
-rw-r--r--tests/ui/lint/use-redundant/use-redundant-glob.rs15
-rw-r--r--tests/ui/lint/use-redundant/use-redundant-glob.stderr16
-rw-r--r--tests/ui/lint/use-redundant/use-redundant-multiple-namespaces.rs21
-rw-r--r--tests/ui/lint/use-redundant/use-redundant-not-parent.rs19
-rw-r--r--tests/ui/lint/use-redundant/use-redundant.rs (renamed from tests/ui/lint/use-redundant.rs)0
-rw-r--r--tests/ui/lint/use-redundant/use-redundant.stderr (renamed from tests/ui/lint/use-redundant.stderr)0
44 files changed, 639 insertions, 82 deletions
diff --git a/tests/ui/lint/anonymous-reexport.rs b/tests/ui/lint/anonymous-reexport.rs
new file mode 100644
index 000000000..11ac5d071
--- /dev/null
+++ b/tests/ui/lint/anonymous-reexport.rs
@@ -0,0 +1,19 @@
+#![deny(unused_imports)]
+#![crate_type = "rlib"]
+
+mod my_mod {
+ pub trait Foo {}
+ pub type TyFoo = dyn Foo;
+ pub struct Bar;
+ pub type TyBar = Bar;
+}
+
+pub use self::my_mod::Foo as _;
+pub use self::my_mod::TyFoo as _; //~ ERROR unused import
+pub use self::my_mod::Bar as _; //~ ERROR unused import
+pub use self::my_mod::TyBar as _; //~ ERROR unused import
+pub use self::my_mod::{Bar as _}; //~ ERROR unused import
+pub use self::my_mod::{Bar as _, Foo as _}; //~ ERROR unused import
+pub use self::my_mod::{Bar as _, TyBar as _}; //~ ERROR unused imports
+#[allow(unused_imports)]
+use self::my_mod::TyBar as _;
diff --git a/tests/ui/lint/anonymous-reexport.stderr b/tests/ui/lint/anonymous-reexport.stderr
new file mode 100644
index 000000000..e3854a545
--- /dev/null
+++ b/tests/ui/lint/anonymous-reexport.stderr
@@ -0,0 +1,44 @@
+error: unused import: `self::my_mod::TyFoo as _`
+ --> $DIR/anonymous-reexport.rs:12:9
+ |
+LL | pub use self::my_mod::TyFoo as _;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/anonymous-reexport.rs:1:9
+ |
+LL | #![deny(unused_imports)]
+ | ^^^^^^^^^^^^^^
+
+error: unused import: `self::my_mod::Bar as _`
+ --> $DIR/anonymous-reexport.rs:13:9
+ |
+LL | pub use self::my_mod::Bar as _;
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+error: unused import: `self::my_mod::TyBar as _`
+ --> $DIR/anonymous-reexport.rs:14:9
+ |
+LL | pub use self::my_mod::TyBar as _;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: unused import: `Bar as _`
+ --> $DIR/anonymous-reexport.rs:15:24
+ |
+LL | pub use self::my_mod::{Bar as _};
+ | ^^^^^^^^
+
+error: unused import: `Bar as _`
+ --> $DIR/anonymous-reexport.rs:16:24
+ |
+LL | pub use self::my_mod::{Bar as _, Foo as _};
+ | ^^^^^^^^
+
+error: unused imports: `Bar as _`, `TyBar as _`
+ --> $DIR/anonymous-reexport.rs:17:24
+ |
+LL | pub use self::my_mod::{Bar as _, TyBar as _};
+ | ^^^^^^^^ ^^^^^^^^^^
+
+error: aborting due to 6 previous errors
+
diff --git a/tests/ui/lint/clashing-extern-fn.rs b/tests/ui/lint/clashing-extern-fn.rs
index 809e06026..09fda33db 100644
--- a/tests/ui/lint/clashing-extern-fn.rs
+++ b/tests/ui/lint/clashing-extern-fn.rs
@@ -122,8 +122,8 @@ mod banana {
weight: u32,
length: u16,
} // note: distinct type
- // This should not trigger the lint because two::Banana is structurally equivalent to
- // one::Banana.
+ // This should not trigger the lint because two::Banana is structurally equivalent to
+ // one::Banana.
extern "C" {
fn weigh_banana(count: *const Banana) -> u64;
}
@@ -223,6 +223,27 @@ mod transparent {
}
}
+#[allow(improper_ctypes)]
+mod zst {
+ mod transparent {
+ #[repr(transparent)]
+ struct TransparentZst(());
+ extern "C" {
+ fn zst() -> ();
+ fn transparent_zst() -> TransparentZst;
+ }
+ }
+
+ mod not_transparent {
+ struct NotTransparentZst(());
+ extern "C" {
+ // These shouldn't warn since all return types are zero sized
+ fn zst() -> NotTransparentZst;
+ fn transparent_zst() -> NotTransparentZst;
+ }
+ }
+}
+
mod missing_return_type {
mod a {
extern "C" {
@@ -397,10 +418,14 @@ mod hidden_niche {
use std::num::NonZeroUsize;
#[repr(transparent)]
- struct Transparent { x: NonZeroUsize }
+ struct Transparent {
+ x: NonZeroUsize,
+ }
#[repr(transparent)]
- struct TransparentNoNiche { y: UnsafeCell<NonZeroUsize> }
+ struct TransparentNoNiche {
+ y: UnsafeCell<NonZeroUsize>,
+ }
extern "C" {
fn hidden_niche_transparent() -> Option<Transparent>;
diff --git a/tests/ui/lint/clashing-extern-fn.stderr b/tests/ui/lint/clashing-extern-fn.stderr
index 217eed6c9..5d457ba0e 100644
--- a/tests/ui/lint/clashing-extern-fn.stderr
+++ b/tests/ui/lint/clashing-extern-fn.stderr
@@ -130,7 +130,7 @@ LL | fn transparent_incorrect() -> isize;
found `unsafe extern "C" fn() -> isize`
warning: `missing_return_type` redeclared with a different signature
- --> $DIR/clashing-extern-fn.rs:238:13
+ --> $DIR/clashing-extern-fn.rs:259:13
|
LL | fn missing_return_type() -> usize;
| ---------------------------------- `missing_return_type` previously declared here
@@ -142,7 +142,7 @@ LL | fn missing_return_type();
found `unsafe extern "C" fn()`
warning: `non_zero_usize` redeclared with a different signature
- --> $DIR/clashing-extern-fn.rs:256:13
+ --> $DIR/clashing-extern-fn.rs:277:13
|
LL | fn non_zero_usize() -> core::num::NonZeroUsize;
| ----------------------------------------------- `non_zero_usize` previously declared here
@@ -154,7 +154,7 @@ LL | fn non_zero_usize() -> usize;
found `unsafe extern "C" fn() -> usize`
warning: `non_null_ptr` redeclared with a different signature
- --> $DIR/clashing-extern-fn.rs:258:13
+ --> $DIR/clashing-extern-fn.rs:279:13
|
LL | fn non_null_ptr() -> core::ptr::NonNull<usize>;
| ----------------------------------------------- `non_null_ptr` previously declared here
@@ -166,7 +166,7 @@ LL | fn non_null_ptr() -> *const usize;
found `unsafe extern "C" fn() -> *const usize`
warning: `option_non_zero_usize_incorrect` redeclared with a different signature
- --> $DIR/clashing-extern-fn.rs:356:13
+ --> $DIR/clashing-extern-fn.rs:377:13
|
LL | fn option_non_zero_usize_incorrect() -> usize;
| ---------------------------------------------- `option_non_zero_usize_incorrect` previously declared here
@@ -178,7 +178,7 @@ LL | fn option_non_zero_usize_incorrect() -> isize;
found `unsafe extern "C" fn() -> isize`
warning: `option_non_null_ptr_incorrect` redeclared with a different signature
- --> $DIR/clashing-extern-fn.rs:358:13
+ --> $DIR/clashing-extern-fn.rs:379:13
|
LL | fn option_non_null_ptr_incorrect() -> *const usize;
| --------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here
@@ -190,7 +190,7 @@ LL | fn option_non_null_ptr_incorrect() -> *const isize;
found `unsafe extern "C" fn() -> *const isize`
warning: `hidden_niche_transparent_no_niche` redeclared with a different signature
- --> $DIR/clashing-extern-fn.rs:408:13
+ --> $DIR/clashing-extern-fn.rs:433:13
|
LL | fn hidden_niche_transparent_no_niche() -> usize;
| ------------------------------------------------ `hidden_niche_transparent_no_niche` previously declared here
@@ -202,7 +202,7 @@ LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoN
found `unsafe extern "C" fn() -> Option<TransparentNoNiche>`
warning: `hidden_niche_unsafe_cell` redeclared with a different signature
- --> $DIR/clashing-extern-fn.rs:412:13
+ --> $DIR/clashing-extern-fn.rs:437:13
|
LL | fn hidden_niche_unsafe_cell() -> usize;
| --------------------------------------- `hidden_niche_unsafe_cell` previously declared here
@@ -214,7 +214,7 @@ LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize
found `unsafe extern "C" fn() -> Option<UnsafeCell<NonZeroUsize>>`
warning: `extern` block uses type `Option<TransparentNoNiche>`, which is not FFI-safe
- --> $DIR/clashing-extern-fn.rs:408:55
+ --> $DIR/clashing-extern-fn.rs:433:55
|
LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoNiche>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -224,7 +224,7 @@ LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoN
= note: `#[warn(improper_ctypes)]` on by default
warning: `extern` block uses type `Option<UnsafeCell<NonZeroUsize>>`, which is not FFI-safe
- --> $DIR/clashing-extern-fn.rs:412:46
+ --> $DIR/clashing-extern-fn.rs:437:46
|
LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
diff --git a/tests/ui/lint/dead-code/issue-59003.rs b/tests/ui/lint/dead-code/issue-59003.rs
new file mode 100644
index 000000000..966d64128
--- /dev/null
+++ b/tests/ui/lint/dead-code/issue-59003.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+// Make sure we don't have any false positives about the "struct is never constructed" lint.
+
+#![deny(dead_code)]
+
+struct Foo {
+ #[allow(dead_code)]
+ inner: u32,
+}
+
+impl From<u32> for Foo {
+ fn from(inner: u32) -> Self {
+ Self { inner }
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/lint/dead-code/issue-85255.rs b/tests/ui/lint/dead-code/issue-85255.rs
index 1978bd4e8..d75a8e2dd 100644
--- a/tests/ui/lint/dead-code/issue-85255.rs
+++ b/tests/ui/lint/dead-code/issue-85255.rs
@@ -11,8 +11,8 @@ struct Foo {
struct Bar;
impl Bar {
- fn a(&self) -> i32 { 5 } //~ WARNING: method `a` is never used
- pub fn b(&self) -> i32 { 6 } //~ WARNING: method `b` is never used
+ fn a(&self) -> i32 { 5 } //~ WARNING: methods `a` and `b` are never used [dead_code]
+ pub fn b(&self) -> i32 { 6 }
}
pub(crate) struct Foo1 {
@@ -23,8 +23,8 @@ pub(crate) struct Foo1 {
pub(crate) struct Bar1;
impl Bar1 {
- fn a(&self) -> i32 { 5 } //~ WARNING: method `a` is never used
- pub fn b(&self) -> i32 { 6 } //~ WARNING: method `b` is never used
+ fn a(&self) -> i32 { 5 } //~ WARNING: methods `a` and `b` are never used [dead_code]
+ pub fn b(&self) -> i32 { 6 }
}
pub(crate) struct Foo2 {
@@ -35,8 +35,8 @@ pub(crate) struct Foo2 {
pub(crate) struct Bar2;
impl Bar2 {
- fn a(&self) -> i32 { 5 } //~ WARNING: method `a` is never used
- pub fn b(&self) -> i32 { 6 } //~ WARNING: method `b` is never used
+ fn a(&self) -> i32 { 5 } //~ WARNING: methods `a` and `b` are never used [dead_code]
+ pub fn b(&self) -> i32 { 6 }
}
diff --git a/tests/ui/lint/dead-code/issue-85255.stderr b/tests/ui/lint/dead-code/issue-85255.stderr
index 58a19cf3c..d981085a4 100644
--- a/tests/ui/lint/dead-code/issue-85255.stderr
+++ b/tests/ui/lint/dead-code/issue-85255.stderr
@@ -14,6 +14,16 @@ note: the lint level is defined here
LL | #![warn(dead_code)]
| ^^^^^^^^^
+warning: methods `a` and `b` are never used
+ --> $DIR/issue-85255.rs:14:8
+ |
+LL | impl Bar {
+ | -------- methods in this implementation
+LL | fn a(&self) -> i32 { 5 }
+ | ^
+LL | pub fn b(&self) -> i32 { 6 }
+ | ^
+
warning: fields `a` and `b` are never read
--> $DIR/issue-85255.rs:19:5
|
@@ -24,6 +34,16 @@ LL | a: i32,
LL | pub b: i32,
| ^
+warning: methods `a` and `b` are never used
+ --> $DIR/issue-85255.rs:26:8
+ |
+LL | impl Bar1 {
+ | --------- methods in this implementation
+LL | fn a(&self) -> i32 { 5 }
+ | ^
+LL | pub fn b(&self) -> i32 { 6 }
+ | ^
+
warning: fields `a` and `b` are never read
--> $DIR/issue-85255.rs:31:5
|
@@ -34,41 +54,15 @@ LL | a: i32,
LL | pub b: i32,
| ^
-warning: method `a` is never used
- --> $DIR/issue-85255.rs:14:8
- |
-LL | fn a(&self) -> i32 { 5 }
- | ^
-
-warning: method `b` is never used
- --> $DIR/issue-85255.rs:15:12
- |
-LL | pub fn b(&self) -> i32 { 6 }
- | ^
-
-warning: method `a` is never used
- --> $DIR/issue-85255.rs:26:8
- |
-LL | fn a(&self) -> i32 { 5 }
- | ^
-
-warning: method `b` is never used
- --> $DIR/issue-85255.rs:27:12
- |
-LL | pub fn b(&self) -> i32 { 6 }
- | ^
-
-warning: method `a` is never used
+warning: methods `a` and `b` are never used
--> $DIR/issue-85255.rs:38:8
|
+LL | impl Bar2 {
+ | --------- methods in this implementation
LL | fn a(&self) -> i32 { 5 }
| ^
-
-warning: method `b` is never used
- --> $DIR/issue-85255.rs:39:12
- |
LL | pub fn b(&self) -> i32 { 6 }
| ^
-warning: 9 warnings emitted
+warning: 6 warnings emitted
diff --git a/tests/ui/lint/dead-code/lint-dead-code-3.stderr b/tests/ui/lint/dead-code/lint-dead-code-3.stderr
index 797b7559c..5c68cf0e1 100644
--- a/tests/ui/lint/dead-code/lint-dead-code-3.stderr
+++ b/tests/ui/lint/dead-code/lint-dead-code-3.stderr
@@ -10,6 +10,14 @@ note: the lint level is defined here
LL | #![deny(dead_code)]
| ^^^^^^^^^
+error: method `foo` is never used
+ --> $DIR/lint-dead-code-3.rs:16:8
+ |
+LL | impl Foo {
+ | -------- method in this implementation
+LL | fn foo(&self) {
+ | ^^^
+
error: function `bar` is never used
--> $DIR/lint-dead-code-3.rs:21:4
|
@@ -34,12 +42,6 @@ error: function `blah` is never used
LL | fn blah() {}
| ^^^^
-error: method `foo` is never used
- --> $DIR/lint-dead-code-3.rs:16:8
- |
-LL | fn foo(&self) {
- | ^^^
-
error: function `free` is never used
--> $DIR/lint-dead-code-3.rs:62:8
|
diff --git a/tests/ui/lint/dead-code/lint-dead-code-6.rs b/tests/ui/lint/dead-code/lint-dead-code-6.rs
index e3074acf1..5b2b76b76 100644
--- a/tests/ui/lint/dead-code/lint-dead-code-6.rs
+++ b/tests/ui/lint/dead-code/lint-dead-code-6.rs
@@ -2,17 +2,16 @@
struct UnusedStruct; //~ ERROR struct `UnusedStruct` is never constructed
impl UnusedStruct {
- fn unused_impl_fn_1() { //~ ERROR associated function `unused_impl_fn_1` is never used
+ fn unused_impl_fn_1() {
+ //~^ ERROR associated functions `unused_impl_fn_1`, `unused_impl_fn_2`, and `unused_impl_fn_3` are never used [dead_code]
println!("blah");
}
- fn unused_impl_fn_2(var: i32) { //~ ERROR associated function `unused_impl_fn_2` is never used
+ fn unused_impl_fn_2(var: i32) {
println!("foo {}", var);
}
- fn unused_impl_fn_3( //~ ERROR associated function `unused_impl_fn_3` is never used
- var: i32,
- ) {
+ fn unused_impl_fn_3(var: i32) {
println!("bar {}", var);
}
}
diff --git a/tests/ui/lint/dead-code/lint-dead-code-6.stderr b/tests/ui/lint/dead-code/lint-dead-code-6.stderr
index f9d83308a..ce4110086 100644
--- a/tests/ui/lint/dead-code/lint-dead-code-6.stderr
+++ b/tests/ui/lint/dead-code/lint-dead-code-6.stderr
@@ -10,23 +10,19 @@ note: the lint level is defined here
LL | #![deny(dead_code)]
| ^^^^^^^^^
-error: associated function `unused_impl_fn_1` is never used
+error: associated functions `unused_impl_fn_1`, `unused_impl_fn_2`, and `unused_impl_fn_3` are never used
--> $DIR/lint-dead-code-6.rs:5:8
|
+LL | impl UnusedStruct {
+ | ----------------- associated functions in this implementation
LL | fn unused_impl_fn_1() {
| ^^^^^^^^^^^^^^^^
-
-error: associated function `unused_impl_fn_2` is never used
- --> $DIR/lint-dead-code-6.rs:9:8
- |
+...
LL | fn unused_impl_fn_2(var: i32) {
| ^^^^^^^^^^^^^^^^
-
-error: associated function `unused_impl_fn_3` is never used
- --> $DIR/lint-dead-code-6.rs:13:8
- |
-LL | fn unused_impl_fn_3(
+...
+LL | fn unused_impl_fn_3(var: i32) {
| ^^^^^^^^^^^^^^^^
-error: aborting due to 4 previous errors
+error: aborting due to 2 previous errors
diff --git a/tests/ui/lint/dead-code/unused-assoc-fns.rs b/tests/ui/lint/dead-code/unused-assoc-fns.rs
new file mode 100644
index 000000000..b111f4b94
--- /dev/null
+++ b/tests/ui/lint/dead-code/unused-assoc-fns.rs
@@ -0,0 +1,35 @@
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+#![deny(unused)]
+
+struct Foo;
+
+impl Foo {
+ fn one() {}
+ //~^ ERROR associated items `one`, `two`, `CONSTANT`, `Type`, and `three` are never used [dead_code]
+
+ fn two(&self) {}
+
+ // seperation between items
+ // ...
+ // ...
+
+ fn used() {}
+
+ const CONSTANT: usize = 5;
+
+ // more seperation
+ // ...
+ // ...
+
+ type Type = usize;
+
+ fn three(&self) {
+ Foo::one();
+ // ...
+ }
+}
+
+fn main() {
+ Foo::used();
+}
diff --git a/tests/ui/lint/dead-code/unused-assoc-fns.stderr b/tests/ui/lint/dead-code/unused-assoc-fns.stderr
new file mode 100644
index 000000000..6344a70ea
--- /dev/null
+++ b/tests/ui/lint/dead-code/unused-assoc-fns.stderr
@@ -0,0 +1,29 @@
+error: associated items `one`, `two`, `CONSTANT`, `Type`, and `three` are never used
+ --> $DIR/unused-assoc-fns.rs:8:8
+ |
+LL | impl Foo {
+ | -------- associated items in this implementation
+LL | fn one() {}
+ | ^^^
+...
+LL | fn two(&self) {}
+ | ^^^
+...
+LL | const CONSTANT: usize = 5;
+ | ^^^^^^^^
+...
+LL | type Type = usize;
+ | ^^^^
+LL |
+LL | fn three(&self) {
+ | ^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/unused-assoc-fns.rs:3:9
+ |
+LL | #![deny(unused)]
+ | ^^^^^^
+ = note: `#[deny(dead_code)]` implied by `#[deny(unused)]`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lint/fn_must_use.stderr b/tests/ui/lint/fn_must_use.stderr
index 657f23c60..e88c1a9b8 100644
--- a/tests/ui/lint/fn_must_use.stderr
+++ b/tests/ui/lint/fn_must_use.stderr
@@ -10,12 +10,21 @@ note: the lint level is defined here
|
LL | #![warn(unused_must_use)]
| ^^^^^^^^^^^^^^^
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = need_to_use_this_value();
+ | +++++++
warning: unused return value of `MyStruct::need_to_use_this_method_value` that must be used
--> $DIR/fn_must_use.rs:60:5
|
LL | m.need_to_use_this_method_value();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = m.need_to_use_this_method_value();
+ | +++++++
warning: unused return value of `EvenNature::is_even` that must be used
--> $DIR/fn_must_use.rs:61:5
@@ -24,24 +33,43 @@ LL | m.is_even(); // trait method!
| ^^^^^^^^^^^
|
= note: no side effects
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = m.is_even(); // trait method!
+ | +++++++
warning: unused return value of `MyStruct::need_to_use_this_associated_function_value` that must be used
--> $DIR/fn_must_use.rs:64:5
|
LL | MyStruct::need_to_use_this_associated_function_value();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = MyStruct::need_to_use_this_associated_function_value();
+ | +++++++
warning: unused return value of `std::cmp::PartialEq::eq` that must be used
--> $DIR/fn_must_use.rs:70:5
|
LL | 2.eq(&3);
| ^^^^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = 2.eq(&3);
+ | +++++++
warning: unused return value of `std::cmp::PartialEq::eq` that must be used
--> $DIR/fn_must_use.rs:71:5
|
LL | m.eq(&n);
| ^^^^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = m.eq(&n);
+ | +++++++
warning: unused comparison that must be used
--> $DIR/fn_must_use.rs:74:5
diff --git a/tests/ui/lint/inline-trait-and-foreign-items.rs b/tests/ui/lint/inline-trait-and-foreign-items.rs
index 13dab7ed9..39bc01f71 100644
--- a/tests/ui/lint/inline-trait-and-foreign-items.rs
+++ b/tests/ui/lint/inline-trait-and-foreign-items.rs
@@ -1,5 +1,5 @@
#![feature(extern_types)]
-#![feature(type_alias_impl_trait)]
+#![feature(impl_trait_in_assoc_type)]
#![warn(unused_attributes)]
diff --git a/tests/ui/lint/issue-109152.rs b/tests/ui/lint/issue-109152.rs
new file mode 100644
index 000000000..daf530e6d
--- /dev/null
+++ b/tests/ui/lint/issue-109152.rs
@@ -0,0 +1,7 @@
+#![deny(map_unit_fn)]
+
+#![crate_type = "lib"]
+fn _y() {
+ vec![42].iter().map(drop);
+ //~^ ERROR `Iterator::map` call that discard the iterator's values
+}
diff --git a/tests/ui/lint/issue-109152.stderr b/tests/ui/lint/issue-109152.stderr
new file mode 100644
index 000000000..7db9e71a5
--- /dev/null
+++ b/tests/ui/lint/issue-109152.stderr
@@ -0,0 +1,23 @@
+error: `Iterator::map` call that discard the iterator's values
+ --> $DIR/issue-109152.rs:5:21
+ |
+LL | vec![42].iter().map(drop);
+ | ^^^^----^
+ | | |
+ | | this function returns `()`, which is likely not what you wanted
+ | | called `Iterator::map` with callable that returns `()`
+ | after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items
+ |
+ = note: `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated
+note: the lint level is defined here
+ --> $DIR/issue-109152.rs:1:9
+ |
+LL | #![deny(map_unit_fn)]
+ | ^^^^^^^^^^^
+help: you might have meant to use `Iterator::for_each`
+ |
+LL | vec![42].iter().for_each(drop);
+ | ~~~~~~~~
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lint/issue-109529.fixed b/tests/ui/lint/issue-109529.fixed
new file mode 100644
index 000000000..5ad489073
--- /dev/null
+++ b/tests/ui/lint/issue-109529.fixed
@@ -0,0 +1,6 @@
+// run-rustfix
+
+fn main() {
+ for _ in 0..=255 as u8 {} //~ ERROR range endpoint is out of range
+ for _ in 0..=(255 as u8) {} //~ ERROR range endpoint is out of range
+}
diff --git a/tests/ui/lint/issue-109529.rs b/tests/ui/lint/issue-109529.rs
new file mode 100644
index 000000000..383d7bc4c
--- /dev/null
+++ b/tests/ui/lint/issue-109529.rs
@@ -0,0 +1,6 @@
+// run-rustfix
+
+fn main() {
+ for _ in 0..256 as u8 {} //~ ERROR range endpoint is out of range
+ for _ in 0..(256 as u8) {} //~ ERROR range endpoint is out of range
+}
diff --git a/tests/ui/lint/issue-109529.stderr b/tests/ui/lint/issue-109529.stderr
new file mode 100644
index 000000000..9e857d1b0
--- /dev/null
+++ b/tests/ui/lint/issue-109529.stderr
@@ -0,0 +1,23 @@
+error: range endpoint is out of range for `u8`
+ --> $DIR/issue-109529.rs:4:14
+ |
+LL | for _ in 0..256 as u8 {}
+ | ------^^^^^^
+ | |
+ | help: use an inclusive range instead: `0..=255`
+ |
+ = note: `#[deny(overflowing_literals)]` on by default
+
+error: range endpoint is out of range for `u8`
+ --> $DIR/issue-109529.rs:5:14
+ |
+LL | for _ in 0..(256 as u8) {}
+ | ^^^^^^^^^^^^^^
+ |
+help: use an inclusive range instead
+ |
+LL | for _ in 0..=(255 as u8) {}
+ | + ~~~
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/lint/lint-temporary-cstring-as-ptr.rs b/tests/ui/lint/lint-temporary-cstring-as-ptr.rs
index 7aa4f2e1e..fab792f12 100644
--- a/tests/ui/lint/lint-temporary-cstring-as-ptr.rs
+++ b/tests/ui/lint/lint-temporary-cstring-as-ptr.rs
@@ -3,7 +3,15 @@
use std::ffi::CString;
+macro_rules! mymacro {
+ () => {
+ let s = CString::new("some text").unwrap().as_ptr();
+ //~^ ERROR getting the inner pointer of a temporary `CString`
+ }
+}
+
fn main() {
let s = CString::new("some text").unwrap().as_ptr();
//~^ ERROR getting the inner pointer of a temporary `CString`
+ mymacro!();
}
diff --git a/tests/ui/lint/lint-temporary-cstring-as-ptr.stderr b/tests/ui/lint/lint-temporary-cstring-as-ptr.stderr
index 79ef57dd1..4e5c8aa06 100644
--- a/tests/ui/lint/lint-temporary-cstring-as-ptr.stderr
+++ b/tests/ui/lint/lint-temporary-cstring-as-ptr.stderr
@@ -1,5 +1,5 @@
error: getting the inner pointer of a temporary `CString`
- --> $DIR/lint-temporary-cstring-as-ptr.rs:7:48
+ --> $DIR/lint-temporary-cstring-as-ptr.rs:14:48
|
LL | let s = CString::new("some text").unwrap().as_ptr();
| ---------------------------------- ^^^^^^ this pointer will be invalid
@@ -14,5 +14,20 @@ note: the lint level is defined here
LL | #![deny(temporary_cstring_as_ptr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: getting the inner pointer of a temporary `CString`
+ --> $DIR/lint-temporary-cstring-as-ptr.rs:8:52
+ |
+LL | let s = CString::new("some text").unwrap().as_ptr();
+ | ---------------------------------- ^^^^^^ this pointer will be invalid
+ | |
+ | this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
+...
+LL | mymacro!();
+ | ---------- in this macro invocation
+ |
+ = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
+ = help: for more information, see https://doc.rust-lang.org/reference/destructors.html
+ = note: this error originates in the macro `mymacro` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
diff --git a/tests/ui/lint/no-coverage.rs b/tests/ui/lint/no-coverage.rs
index ff24c12b2..07906a434 100644
--- a/tests/ui/lint/no-coverage.rs
+++ b/tests/ui/lint/no-coverage.rs
@@ -1,6 +1,6 @@
#![feature(extern_types)]
#![feature(no_coverage)]
-#![feature(type_alias_impl_trait)]
+#![feature(impl_trait_in_assoc_type)]
#![warn(unused_attributes)]
#![no_coverage]
//~^ WARN: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly
diff --git a/tests/ui/lint/unconditional_panic_98444.rs b/tests/ui/lint/unconditional_panic_98444.rs
new file mode 100644
index 000000000..011fabfbb
--- /dev/null
+++ b/tests/ui/lint/unconditional_panic_98444.rs
@@ -0,0 +1,7 @@
+// build-fail
+
+fn main() {
+ let xs: [i32; 5] = [1, 2, 3, 4, 5];
+ let _ = &xs;
+ let _ = xs[7]; //~ ERROR: this operation will panic at runtime [unconditional_panic]
+}
diff --git a/tests/ui/lint/unconditional_panic_98444.stderr b/tests/ui/lint/unconditional_panic_98444.stderr
new file mode 100644
index 000000000..a34745809
--- /dev/null
+++ b/tests/ui/lint/unconditional_panic_98444.stderr
@@ -0,0 +1,10 @@
+error: this operation will panic at runtime
+ --> $DIR/unconditional_panic_98444.rs:6:13
+ |
+LL | let _ = xs[7];
+ | ^^^^^ index out of bounds: the length is 5 but the index is 7
+ |
+ = note: `#[deny(unconditional_panic)]` on by default
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lint/unused/auxiliary/must-use-foreign.rs b/tests/ui/lint/unused/auxiliary/must-use-foreign.rs
new file mode 100644
index 000000000..f773f09c3
--- /dev/null
+++ b/tests/ui/lint/unused/auxiliary/must-use-foreign.rs
@@ -0,0 +1,12 @@
+// edition:2021
+
+use std::future::Future;
+
+pub struct Manager;
+
+impl Manager {
+ #[must_use]
+ pub async fn new() -> (Self, impl Future<Output = ()>) {
+ (Manager, async {})
+ }
+}
diff --git a/tests/ui/lint/unused/must-use-box-from-raw.stderr b/tests/ui/lint/unused/must-use-box-from-raw.stderr
index 47ab613be..4898db7fe 100644
--- a/tests/ui/lint/unused/must-use-box-from-raw.stderr
+++ b/tests/ui/lint/unused/must-use-box-from-raw.stderr
@@ -10,6 +10,10 @@ note: the lint level is defined here
|
LL | #![warn(unused_must_use)]
| ^^^^^^^^^^^^^^^
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = Box::from_raw(ptr);
+ | +++++++
warning: 1 warning emitted
diff --git a/tests/ui/lint/unused/must-use-foreign.rs b/tests/ui/lint/unused/must-use-foreign.rs
new file mode 100644
index 000000000..21a110585
--- /dev/null
+++ b/tests/ui/lint/unused/must-use-foreign.rs
@@ -0,0 +1,15 @@
+// edition:2021
+// aux-build:must-use-foreign.rs
+// check-pass
+
+extern crate must_use_foreign;
+
+use must_use_foreign::Manager;
+
+async fn async_main() {
+ Manager::new().await.1.await;
+}
+
+fn main() {
+ let _ = async_main();
+}
diff --git a/tests/ui/lint/unused/must_use-unit.stderr b/tests/ui/lint/unused/must_use-unit.stderr
index 9fcbc5074..993a19e5f 100644
--- a/tests/ui/lint/unused/must_use-unit.stderr
+++ b/tests/ui/lint/unused/must_use-unit.stderr
@@ -9,12 +9,21 @@ note: the lint level is defined here
|
LL | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = foo();
+ | +++++++
error: unused return value of `bar` that must be used
--> $DIR/must_use-unit.rs:15:5
|
LL | bar();
| ^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = bar();
+ | +++++++
error: aborting due to 2 previous errors
diff --git a/tests/ui/lint/unused/trait-alias-supertrait.rs b/tests/ui/lint/unused/trait-alias-supertrait.rs
new file mode 100644
index 000000000..46f00c06b
--- /dev/null
+++ b/tests/ui/lint/unused/trait-alias-supertrait.rs
@@ -0,0 +1,15 @@
+// check-pass
+
+// Make sure that we only consider *Self* supertrait predicates
+// in the `unused_must_use` lint.
+
+#![feature(trait_alias)]
+#![deny(unused_must_use)]
+
+trait Foo<T> = Sized where T: Iterator;
+
+fn test<T: Iterator>() -> impl Foo<T> {}
+
+fn main() {
+ test::<std::iter::Once<()>>();
+}
diff --git a/tests/ui/lint/unused/unused-allocation.rs b/tests/ui/lint/unused/unused-allocation.rs
new file mode 100644
index 000000000..c1a6f5cea
--- /dev/null
+++ b/tests/ui/lint/unused/unused-allocation.rs
@@ -0,0 +1,7 @@
+#![feature(rustc_attrs, stmt_expr_attributes)]
+#![deny(unused_allocation)]
+
+fn main() {
+ _ = (#[rustc_box] Box::new([1])).len(); //~ error: unnecessary allocation, use `&` instead
+ _ = Box::new([1]).len(); //~ error: unnecessary allocation, use `&` instead
+}
diff --git a/tests/ui/lint/unused/unused-allocation.stderr b/tests/ui/lint/unused/unused-allocation.stderr
new file mode 100644
index 000000000..c9ccfbd30
--- /dev/null
+++ b/tests/ui/lint/unused/unused-allocation.stderr
@@ -0,0 +1,20 @@
+error: unnecessary allocation, use `&` instead
+ --> $DIR/unused-allocation.rs:5:9
+ |
+LL | _ = (#[rustc_box] Box::new([1])).len();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/unused-allocation.rs:2:9
+ |
+LL | #![deny(unused_allocation)]
+ | ^^^^^^^^^^^^^^^^^
+
+error: unnecessary allocation, use `&` instead
+ --> $DIR/unused-allocation.rs:6:9
+ |
+LL | _ = Box::new([1]).len();
+ | ^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/lint/unused/unused-async.rs b/tests/ui/lint/unused/unused-async.rs
index 4be93aa15..6355f47f0 100644
--- a/tests/ui/lint/unused/unused-async.rs
+++ b/tests/ui/lint/unused/unused-async.rs
@@ -33,7 +33,7 @@ async fn test() {
foo().await; //~ ERROR unused output of future returned by `foo` that must be used
bar(); //~ ERROR unused return value of `bar` that must be used
//~^ ERROR unused implementer of `Future` that must be used
- bar().await; //~ ERROR unused output of future returned by `bar` that must be used
+ bar().await; // ok, it's not an async fn
baz(); //~ ERROR unused implementer of `Future` that must be used
baz().await; // ok
}
diff --git a/tests/ui/lint/unused/unused-async.stderr b/tests/ui/lint/unused/unused-async.stderr
index 4bcb26dc1..e93a40658 100644
--- a/tests/ui/lint/unused/unused-async.stderr
+++ b/tests/ui/lint/unused/unused-async.stderr
@@ -16,12 +16,22 @@ error: unused return value of `foo` that must be used
|
LL | foo();
| ^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = foo();
+ | +++++++
error: unused output of future returned by `foo` that must be used
--> $DIR/unused-async.rs:33:5
|
LL | foo().await;
| ^^^^^^^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = foo().await;
+ | +++++++
error: unused implementer of `Future` that must be used
--> $DIR/unused-async.rs:34:5
@@ -36,12 +46,11 @@ error: unused return value of `bar` that must be used
|
LL | bar();
| ^^^^^
-
-error: unused output of future returned by `bar` that must be used
- --> $DIR/unused-async.rs:36:5
|
-LL | bar().await;
- | ^^^^^^^^^^^
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = bar();
+ | +++++++
error: unused implementer of `Future` that must be used
--> $DIR/unused-async.rs:37:5
@@ -51,5 +60,5 @@ LL | baz();
|
= note: futures do nothing unless you `.await` or poll them
-error: aborting due to 7 previous errors
+error: aborting due to 6 previous errors
diff --git a/tests/ui/lint/unused/unused-result.stderr b/tests/ui/lint/unused/unused-result.stderr
index 4e1ba1fd9..f42995a65 100644
--- a/tests/ui/lint/unused/unused-result.stderr
+++ b/tests/ui/lint/unused/unused-result.stderr
@@ -9,6 +9,10 @@ note: the lint level is defined here
|
LL | #![deny(unused_results, unused_must_use)]
| ^^^^^^^^^^^^^^^
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = foo::<MustUse>();
+ | +++++++
error: unused `MustUseMsg` that must be used
--> $DIR/unused-result.rs:22:5
@@ -17,6 +21,10 @@ LL | foo::<MustUseMsg>();
| ^^^^^^^^^^^^^^^^^^^
|
= note: some message
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = foo::<MustUseMsg>();
+ | +++++++
error: unused result of type `isize`
--> $DIR/unused-result.rs:34:5
@@ -35,6 +43,11 @@ error: unused `MustUse` that must be used
|
LL | foo::<MustUse>();
| ^^^^^^^^^^^^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = foo::<MustUse>();
+ | +++++++
error: unused `MustUseMsg` that must be used
--> $DIR/unused-result.rs:36:5
@@ -43,6 +56,10 @@ LL | foo::<MustUseMsg>();
| ^^^^^^^^^^^^^^^^^^^
|
= note: some message
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = foo::<MustUseMsg>();
+ | +++++++
error: aborting due to 5 previous errors
diff --git a/tests/ui/lint/unused/unused_attributes-must_use.stderr b/tests/ui/lint/unused/unused_attributes-must_use.stderr
index 0f699429e..9633767c4 100644
--- a/tests/ui/lint/unused/unused_attributes-must_use.stderr
+++ b/tests/ui/lint/unused/unused_attributes-must_use.stderr
@@ -146,42 +146,76 @@ note: the lint level is defined here
|
LL | #![deny(unused_attributes, unused_must_use)]
| ^^^^^^^^^^^^^^^
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = X;
+ | +++++++
error: unused `Y` that must be used
--> $DIR/unused_attributes-must_use.rs:104:5
|
LL | Y::Z;
| ^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = Y::Z;
+ | +++++++
error: unused `U` that must be used
--> $DIR/unused_attributes-must_use.rs:105:5
|
LL | U { unit: () };
| ^^^^^^^^^^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = U { unit: () };
+ | +++++++
error: unused return value of `U::method` that must be used
--> $DIR/unused_attributes-must_use.rs:106:5
|
LL | U::method();
| ^^^^^^^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = U::method();
+ | +++++++
error: unused return value of `foo` that must be used
--> $DIR/unused_attributes-must_use.rs:107:5
|
LL | foo();
| ^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = foo();
+ | +++++++
error: unused return value of `foreign_foo` that must be used
--> $DIR/unused_attributes-must_use.rs:110:9
|
LL | foreign_foo();
| ^^^^^^^^^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = foreign_foo();
+ | +++++++
error: unused return value of `Use::get_four` that must be used
--> $DIR/unused_attributes-must_use.rs:118:5
|
LL | ().get_four();
| ^^^^^^^^^^^^^
+ |
+help: use `let _ = ...` to ignore the resulting value
+ |
+LL | let _ = ().get_four();
+ | +++++++
error: aborting due to 28 previous errors
diff --git a/tests/ui/lint/use-redundant/issue-92904.rs b/tests/ui/lint/use-redundant/issue-92904.rs
new file mode 100644
index 000000000..511d9d263
--- /dev/null
+++ b/tests/ui/lint/use-redundant/issue-92904.rs
@@ -0,0 +1,17 @@
+// check-pass
+
+pub struct Foo(bar::Bar);
+
+pub mod bar {
+ pub struct Foo(pub Bar);
+ pub struct Bar(pub char);
+}
+
+pub fn warning() -> Foo {
+ use bar::*;
+ #[deny(unused_imports)]
+ use self::Foo; // no error
+ Foo(Bar('a'))
+}
+
+fn main() {}
diff --git a/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs b/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs
new file mode 100644
index 000000000..6b1e018d2
--- /dev/null
+++ b/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs
@@ -0,0 +1,16 @@
+// check-pass
+#![warn(unused_imports)]
+
+pub mod bar {
+ pub struct Foo(pub Bar);
+ pub struct Bar(pub char);
+}
+
+use bar::*;
+
+pub fn warning() -> Foo {
+ use bar::Foo; //~ WARNING imported redundantly
+ Foo(Bar('a'))
+}
+
+fn main() {}
diff --git a/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr b/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr
new file mode 100644
index 000000000..2c3b33452
--- /dev/null
+++ b/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr
@@ -0,0 +1,17 @@
+warning: the item `Foo` is imported redundantly
+ --> $DIR/use-redundant-glob-parent.rs:12:9
+ |
+LL | use bar::*;
+ | ------ the item `Foo` is already imported here
+...
+LL | use bar::Foo;
+ | ^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/use-redundant-glob-parent.rs:2:9
+ |
+LL | #![warn(unused_imports)]
+ | ^^^^^^^^^^^^^^
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/lint/use-redundant/use-redundant-glob.rs b/tests/ui/lint/use-redundant/use-redundant-glob.rs
new file mode 100644
index 000000000..bd9e51b6f
--- /dev/null
+++ b/tests/ui/lint/use-redundant/use-redundant-glob.rs
@@ -0,0 +1,15 @@
+// check-pass
+#![warn(unused_imports)]
+
+pub mod bar {
+ pub struct Foo(pub Bar);
+ pub struct Bar(pub char);
+}
+
+pub fn warning() -> bar::Foo {
+ use bar::*;
+ use bar::Foo; //~ WARNING imported redundantly
+ Foo(Bar('a'))
+}
+
+fn main() {}
diff --git a/tests/ui/lint/use-redundant/use-redundant-glob.stderr b/tests/ui/lint/use-redundant/use-redundant-glob.stderr
new file mode 100644
index 000000000..d3b406d82
--- /dev/null
+++ b/tests/ui/lint/use-redundant/use-redundant-glob.stderr
@@ -0,0 +1,16 @@
+warning: the item `Foo` is imported redundantly
+ --> $DIR/use-redundant-glob.rs:11:9
+ |
+LL | use bar::*;
+ | ------ the item `Foo` is already imported here
+LL | use bar::Foo;
+ | ^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/use-redundant-glob.rs:2:9
+ |
+LL | #![warn(unused_imports)]
+ | ^^^^^^^^^^^^^^
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/lint/use-redundant/use-redundant-multiple-namespaces.rs b/tests/ui/lint/use-redundant/use-redundant-multiple-namespaces.rs
new file mode 100644
index 000000000..0fb60840f
--- /dev/null
+++ b/tests/ui/lint/use-redundant/use-redundant-multiple-namespaces.rs
@@ -0,0 +1,21 @@
+// check-pass
+#![allow(nonstandard_style)]
+
+pub mod bar {
+ pub struct Foo { pub bar: Bar }
+ pub struct Bar(pub char);
+}
+
+pub mod x {
+ use crate::bar;
+ pub const Foo: bar::Bar = bar::Bar('a');
+}
+
+pub fn warning() -> bar::Foo {
+ #![deny(unused_imports)] // no error
+ use bar::*;
+ use x::Foo;
+ Foo { bar: Foo }
+}
+
+fn main() {}
diff --git a/tests/ui/lint/use-redundant/use-redundant-not-parent.rs b/tests/ui/lint/use-redundant/use-redundant-not-parent.rs
new file mode 100644
index 000000000..c97a3d341
--- /dev/null
+++ b/tests/ui/lint/use-redundant/use-redundant-not-parent.rs
@@ -0,0 +1,19 @@
+// check-pass
+
+pub mod bar {
+ pub struct Foo(pub Bar);
+ pub struct Bar(pub char);
+}
+
+pub mod x {
+ pub struct Foo(pub crate::bar::Bar);
+}
+
+pub fn warning() -> x::Foo {
+ use bar::*;
+ #[deny(unused_imports)]
+ use x::Foo; // no error
+ Foo(Bar('a'))
+}
+
+fn main() {}
diff --git a/tests/ui/lint/use-redundant.rs b/tests/ui/lint/use-redundant/use-redundant.rs
index 53315dcf6..53315dcf6 100644
--- a/tests/ui/lint/use-redundant.rs
+++ b/tests/ui/lint/use-redundant/use-redundant.rs
diff --git a/tests/ui/lint/use-redundant.stderr b/tests/ui/lint/use-redundant/use-redundant.stderr
index c861a1956..c861a1956 100644
--- a/tests/ui/lint/use-redundant.stderr
+++ b/tests/ui/lint/use-redundant/use-redundant.stderr