Skip to content

Commit

Permalink
Added allow lint test
Browse files Browse the repository at this point in the history
  • Loading branch information
RuairidhWilliamson committed Sep 11, 2024
1 parent 550e616 commit a287de0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
28 changes: 22 additions & 6 deletions tests/ui/anon_trait_imports.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,34 @@ proc_macros::with_span!(
}
);

// Limitation: Suggests `use std::any::Any as _::{self};` which looks weird
// fn use_trait_self_good() {
// 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 {

}

#[allow(clippy::anon_trait_imports)]
fn allow_lint_fn() {
use std::any::Any;

"foo".type_id();
}

#[allow(clippy::anon_trait_imports)]
mod allow_lint_mod {
use std::any::Any;

fn foo() {
"foo".type_id();
}
}

// Limitation: Suggests `use std::any::Any as _::{self};` which looks weird
// fn use_trait_self_good() {
// use std::any::Any::{self};
// "foo".type_id();
// }

// Limitation: Suggests `use std::any::{Any as _, Any as _};`
// mod repeated_renamed {
// use std::any::{Any, Any as MyAny};
Expand Down
28 changes: 22 additions & 6 deletions tests/ui/anon_trait_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,34 @@ proc_macros::with_span!(
}
);

// Limitation: Suggests `use std::any::Any as _::{self};` which looks weird
// fn use_trait_self_good() {
// 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;
}

#[allow(clippy::anon_trait_imports)]
fn allow_lint_fn() {
use std::any::Any;

"foo".type_id();
}

#[allow(clippy::anon_trait_imports)]
mod allow_lint_mod {
use std::any::Any;

fn foo() {
"foo".type_id();
}
}

// Limitation: Suggests `use std::any::Any as _::{self};` which looks weird
// fn use_trait_self_good() {
// use std::any::Any::{self};
// "foo".type_id();
// }

// Limitation: Suggests `use std::any::{Any as _, Any as _};`
// mod repeated_renamed {
// use std::any::{Any, Any as MyAny};
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/anon_trait_imports.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: unused import: `std::any::Any`
--> tests/ui/anon_trait_imports.rs:251:9
--> tests/ui/anon_trait_imports.rs:245:9
|
LL | use std::any::Any;
| ^^^^^^^^^^^^^
Expand Down

0 comments on commit a287de0

Please sign in to comment.