};
use crate::arena::Arena;
-use crate::dep_graph::{DepGraph, DepKind, DepNode, DepNodeIndex};
+use crate::dep_graph::{DepGraph, DepNodeIndex};
use crate::hir::{HirOwner, HirOwnerItems};
use crate::middle::cstore::CrateStoreDyn;
use crate::ty::query::Providers;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::svh::Svh;
use rustc_hir::def::{DefKind, Res};
-use rustc_hir::def_id::{DefId, DefIndex, LocalDefId};
+use rustc_hir::def_id::{DefId, DefIndex, LocalDefId, LOCAL_CRATE};
use rustc_hir::intravisit;
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_hir::print::Nested;
}
pub fn trait_impls(&self, trait_did: DefId) -> &'hir [HirId] {
- self.dep_graph.read(DepNode::new_no_params(DepKind::AllLocalTraitImpls));
-
- // N.B., intentionally bypass `self.krate()` so that we
- // do not trigger a read of the whole krate here
- self.krate.trait_impls.get(&trait_did).map_or(&[], |xs| &xs[..])
+ self.tcx.all_local_trait_impls(LOCAL_CRATE).get(&trait_did).map_or(&[], |xs| &xs[..])
}
/// Gets the attributes on the crate. This is preferable to
}
TypeChecking {
+ query all_local_trait_impls(key: CrateNum) -> &'tcx BTreeMap<DefId, Vec<hir::HirId>> {
+ desc { "local trait impls" }
+ }
query trait_impls_of(key: DefId) -> &'tcx ty::trait_def::TraitImpls {
desc { |tcx| "trait impls of `{}`", tcx.def_path_str(key) }
}
context::provide(providers);
erase_regions::provide(providers);
layout::provide(providers);
- *providers =
- ty::query::Providers { trait_impls_of: trait_def::trait_impls_of_provider, ..*providers };
+ *providers = ty::query::Providers {
+ trait_impls_of: trait_def::trait_impls_of_provider,
+ all_local_trait_impls: trait_def::all_local_trait_impls,
+ ..*providers
+ };
}
/// A map for the local crate mapping each type to a vector of its
use rustc_span::symbol::Symbol;
use rustc_span::{Span, DUMMY_SP};
use std::borrow::Cow;
+use std::collections::BTreeMap;
use std::convert::TryFrom;
use std::ops::Deref;
use std::sync::Arc;
use crate::ty::fold::TypeFoldable;
use crate::ty::{Ty, TyCtxt};
use rustc_hir as hir;
-use rustc_hir::def_id::DefId;
+use rustc_hir::def_id::{CrateNum, DefId};
+use rustc_hir::HirId;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_macros::HashStable;
+use std::collections::BTreeMap;
/// A trait's definition with type information.
#[derive(HashStable)]
}
}
+// Query provider for `all_local_trait_impls`.
+pub(super) fn all_local_trait_impls<'tcx>(
+ tcx: TyCtxt<'tcx>,
+ krate: CrateNum,
+) -> &'tcx BTreeMap<DefId, Vec<HirId>> {
+ &tcx.hir_crate(krate).trait_impls
+}
+
// Query provider for `trait_impls_of`.
pub(super) fn trait_impls_of_provider(tcx: TyCtxt<'_>, trait_id: DefId) -> &TraitImpls {
let mut impls = TraitImpls::default();