Skip to content

Commit a287de0

Browse files
Added allow lint test
1 parent 550e616 commit a287de0

File tree

3 files changed

+45
-13
lines changed

3 files changed

+45
-13
lines changed

tests/ui/anon_trait_imports.fixed

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,18 +239,34 @@ proc_macros::with_span!(
239239
}
240240
);
241241

242-
// Limitation: Suggests `use std::any::Any as _::{self};` which looks weird
243-
// fn use_trait_self_good() {
244-
// use std::any::Any::{self};
245-
// "foo".type_id();
246-
// }
247-
248242
// This should warn the import is unused but should not trigger anon_trait_imports
249243
#[warn(unused)]
250244
mod unused_import {
251245

252246
}
253247

248+
#[allow(clippy::anon_trait_imports)]
249+
fn allow_lint_fn() {
250+
use std::any::Any;
251+
252+
"foo".type_id();
253+
}
254+
255+
#[allow(clippy::anon_trait_imports)]
256+
mod allow_lint_mod {
257+
use std::any::Any;
258+
259+
fn foo() {
260+
"foo".type_id();
261+
}
262+
}
263+
264+
// Limitation: Suggests `use std::any::Any as _::{self};` which looks weird
265+
// fn use_trait_self_good() {
266+
// use std::any::Any::{self};
267+
// "foo".type_id();
268+
// }
269+
254270
// Limitation: Suggests `use std::any::{Any as _, Any as _};`
255271
// mod repeated_renamed {
256272
// use std::any::{Any, Any as MyAny};

tests/ui/anon_trait_imports.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,18 +239,34 @@ proc_macros::with_span!(
239239
}
240240
);
241241

242-
// Limitation: Suggests `use std::any::Any as _::{self};` which looks weird
243-
// fn use_trait_self_good() {
244-
// use std::any::Any::{self};
245-
// "foo".type_id();
246-
// }
247-
248242
// This should warn the import is unused but should not trigger anon_trait_imports
249243
#[warn(unused)]
250244
mod unused_import {
251245
use std::any::Any;
252246
}
253247

248+
#[allow(clippy::anon_trait_imports)]
249+
fn allow_lint_fn() {
250+
use std::any::Any;
251+
252+
"foo".type_id();
253+
}
254+
255+
#[allow(clippy::anon_trait_imports)]
256+
mod allow_lint_mod {
257+
use std::any::Any;
258+
259+
fn foo() {
260+
"foo".type_id();
261+
}
262+
}
263+
264+
// Limitation: Suggests `use std::any::Any as _::{self};` which looks weird
265+
// fn use_trait_self_good() {
266+
// use std::any::Any::{self};
267+
// "foo".type_id();
268+
// }
269+
254270
// Limitation: Suggests `use std::any::{Any as _, Any as _};`
255271
// mod repeated_renamed {
256272
// use std::any::{Any, Any as MyAny};

tests/ui/anon_trait_imports.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unused import: `std::any::Any`
2-
--> tests/ui/anon_trait_imports.rs:251:9
2+
--> tests/ui/anon_trait_imports.rs:245:9
33
|
44
LL | use std::any::Any;
55
| ^^^^^^^^^^^^^

0 commit comments

Comments
 (0)