Skip to content

Commit

Permalink
Review add weird test case
Browse files Browse the repository at this point in the history
  • Loading branch information
RuairidhWilliamson committed Sep 3, 2024
1 parent 1cb9ec8 commit 8d6272b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_lints/src/anon_trait_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for AnonTraitImport {
// Only check traits
&& let Some(Res::Def(DefKind::Trait, _)) = path.res.first()
&& cx.tcx.maybe_unused_trait_imports(()).contains(&item.owner_id.def_id)
// Only check this use if it is only visible to its module (no pub, pub(crate), ...)
// Only check this import if it is visible to its module only (no pub, pub(crate), ...)
&& let module = cx.tcx.parent_module_from_def_id(item.owner_id.def_id)
&& cx.tcx.visibility(item.owner_id.def_id) == Visibility::Restricted(module.to_def_id())
&& let Some(last_segment) = path.segments.last()
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/anon_trait_import.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,9 @@ proc_macros::with_span!(
"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();
// }
6 changes: 6 additions & 0 deletions tests/ui/anon_trait_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,9 @@ proc_macros::with_span!(
"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();
// }

0 comments on commit 8d6272b

Please sign in to comment.