Unquerify maybe_unused_trait_imports.
This commit is contained in:
parent
8f08b3a324
commit
258e410feb
4 changed files with 2 additions and 7 deletions
|
|
@ -18,7 +18,7 @@ pub(super) fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) {
|
|||
used_trait_imports.extend_unord(imports.items().copied());
|
||||
}
|
||||
|
||||
for &id in tcx.maybe_unused_trait_imports(()) {
|
||||
for &id in tcx.resolutions(()).maybe_unused_trait_imports.iter() {
|
||||
debug_assert_eq!(tcx.def_kind(id), DefKind::Use);
|
||||
if tcx.visibility(id).is_public() {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -2285,9 +2285,6 @@ rustc_queries! {
|
|||
query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
|
||||
desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) }
|
||||
}
|
||||
query maybe_unused_trait_imports(_: ()) -> &'tcx FxIndexSet<LocalDefId> {
|
||||
desc { "fetching potentially unused trait imports" }
|
||||
}
|
||||
|
||||
/// All available crates in the graph, including those that should not be user-facing
|
||||
/// (such as private crates).
|
||||
|
|
|
|||
|
|
@ -3428,8 +3428,6 @@ pub struct DeducedParamAttrs {
|
|||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
providers.maybe_unused_trait_imports =
|
||||
|tcx, ()| &tcx.resolutions(()).maybe_unused_trait_imports;
|
||||
providers.extern_mod_stmt_cnum =
|
||||
|tcx, id| tcx.resolutions(()).extern_crate_map.get(&id).cloned();
|
||||
providers.is_panic_runtime =
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedTraitNames {
|
|||
&& ident.name != kw::Underscore
|
||||
// Only check traits
|
||||
&& let Some(Res::Def(DefKind::Trait, _)) = path.res.type_ns
|
||||
&& cx.tcx.maybe_unused_trait_imports(()).contains(&item.owner_id.def_id)
|
||||
&& cx.tcx.resolutions(()).maybe_unused_trait_imports.contains(&item.owner_id.def_id)
|
||||
// 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())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue