Skip to content

Commit 8d6272b

Browse files
Review add weird test case
1 parent 1cb9ec8 commit 8d6272b

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

clippy_lints/src/anon_trait_import.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for AnonTraitImport {
7070
// Only check traits
7171
&& let Some(Res::Def(DefKind::Trait, _)) = path.res.first()
7272
&& cx.tcx.maybe_unused_trait_imports(()).contains(&item.owner_id.def_id)
73-
// Only check this use if it is only visible to its module (no pub, pub(crate), ...)
73+
// Only check this import if it is visible to its module only (no pub, pub(crate), ...)
7474
&& let module = cx.tcx.parent_module_from_def_id(item.owner_id.def_id)
7575
&& cx.tcx.visibility(item.owner_id.def_id) == Visibility::Restricted(module.to_def_id())
7676
&& let Some(last_segment) = path.segments.last()

tests/ui/anon_trait_import.fixed

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,9 @@ proc_macros::with_span!(
238238
"foo".type_id();
239239
}
240240
);
241+
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+
// }

tests/ui/anon_trait_import.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,9 @@ proc_macros::with_span!(
238238
"foo".type_id();
239239
}
240240
);
241+
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+
// }

0 commit comments

Comments
 (0)