Skip to content

Commit

Permalink
Add test and known limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
RuairidhWilliamson committed Sep 9, 2024
1 parent e1b804c commit c63465f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
15 changes: 15 additions & 0 deletions tests/ui/anon_trait_imports.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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();
// }
// }
15 changes: 15 additions & 0 deletions tests/ui/anon_trait_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
// }
// }
11 changes: 10 additions & 1 deletion tests/ui/anon_trait_imports.stderr
Original file line number Diff line number Diff line change
@@ -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
|
Expand Down Expand Up @@ -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

0 comments on commit c63465f

Please sign in to comment.