diff --git a/tests/ui/anon_trait_imports.fixed b/tests/ui/anon_trait_imports.fixed index 1ff6a4fddf2f..c3c5eb8e7edc 100644 --- a/tests/ui/anon_trait_imports.fixed +++ b/tests/ui/anon_trait_imports.fixed @@ -244,3 +244,18 @@ proc_macros::with_span!( // use std::any::Any::{self}; // "foo".type_id(); // } + +// This should warn the import is unused but should not trigger anon_trait_imports +#[warn(unused)] +mod unused_import { + +} + +// Limitation: Suggests `use std::any::{Any as _, Any as _};` +// mod repeated_renamed { +// use std::any::{Any, Any as MyAny}; + +// fn foo() { +// "foo".type_id(); +// } +// } diff --git a/tests/ui/anon_trait_imports.rs b/tests/ui/anon_trait_imports.rs index a759a0f504d3..0c30c3197abe 100644 --- a/tests/ui/anon_trait_imports.rs +++ b/tests/ui/anon_trait_imports.rs @@ -244,3 +244,18 @@ proc_macros::with_span!( // use std::any::Any::{self}; // "foo".type_id(); // } + +// This should warn the import is unused but should not trigger anon_trait_imports +#[warn(unused)] +mod unused_import { + use std::any::Any; +} + +// Limitation: Suggests `use std::any::{Any as _, Any as _};` +// mod repeated_renamed { +// use std::any::{Any, Any as MyAny}; + +// fn foo() { +// "foo".type_id(); +// } +// } diff --git a/tests/ui/anon_trait_imports.stderr b/tests/ui/anon_trait_imports.stderr index d9115e75a0c9..f3ba70350748 100644 --- a/tests/ui/anon_trait_imports.stderr +++ b/tests/ui/anon_trait_imports.stderr @@ -1,3 +1,12 @@ +error: unused import: `std::any::Any` + --> tests/ui/anon_trait_imports.rs:251:9 + | +LL | use std::any::Any; + | ^^^^^^^^^^^^^ + | + = note: `-D unused-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(unused_imports)]` + error: importing trait that is only used anonymously --> tests/ui/anon_trait_imports.rs:12:19 | @@ -60,5 +69,5 @@ LL | foo!(); | = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors