Skip to content

Commit c63465f

Browse files
Add test and known limitation
1 parent e1b804c commit c63465f

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

tests/ui/anon_trait_imports.fixed

+15
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,18 @@ proc_macros::with_span!(
244244
// use std::any::Any::{self};
245245
// "foo".type_id();
246246
// }
247+
248+
// This should warn the import is unused but should not trigger anon_trait_imports
249+
#[warn(unused)]
250+
mod unused_import {
251+
252+
}
253+
254+
// Limitation: Suggests `use std::any::{Any as _, Any as _};`
255+
// mod repeated_renamed {
256+
// use std::any::{Any, Any as MyAny};
257+
258+
// fn foo() {
259+
// "foo".type_id();
260+
// }
261+
// }

tests/ui/anon_trait_imports.rs

+15
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,18 @@ proc_macros::with_span!(
244244
// use std::any::Any::{self};
245245
// "foo".type_id();
246246
// }
247+
248+
// This should warn the import is unused but should not trigger anon_trait_imports
249+
#[warn(unused)]
250+
mod unused_import {
251+
use std::any::Any;
252+
}
253+
254+
// Limitation: Suggests `use std::any::{Any as _, Any as _};`
255+
// mod repeated_renamed {
256+
// use std::any::{Any, Any as MyAny};
257+
258+
// fn foo() {
259+
// "foo".type_id();
260+
// }
261+
// }

tests/ui/anon_trait_imports.stderr

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
error: unused import: `std::any::Any`
2+
--> tests/ui/anon_trait_imports.rs:251:9
3+
|
4+
LL | use std::any::Any;
5+
| ^^^^^^^^^^^^^
6+
|
7+
= note: `-D unused-imports` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(unused_imports)]`
9+
110
error: importing trait that is only used anonymously
211
--> tests/ui/anon_trait_imports.rs:12:19
312
|
@@ -60,5 +69,5 @@ LL | foo!();
6069
|
6170
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
6271

63-
error: aborting due to 9 previous errors
72+
error: aborting due to 10 previous errors
6473

0 commit comments

Comments
 (0)