Update in_scope_traits_map

This commit is contained in:
John Kåre Alsaker 2018-12-01 16:17:59 +01:00
parent fb578794b0
commit 5f808f6588
2 changed files with 8 additions and 10 deletions

View File

@ -637,7 +637,7 @@ rustc_queries! {
desc { "computing whether impls specialize one another" }
}
query in_scope_traits_map(_: DefIndex)
-> Option<Lrc<FxHashMap<ItemLocalId, Lrc<StableVec<TraitCandidate>>>>> {
-> Option<&'tcx FxHashMap<ItemLocalId, StableVec<TraitCandidate>>> {
eval_always
desc { "traits in scope at a block" }
}

View File

@ -1064,8 +1064,8 @@ pub struct GlobalCtxt<'tcx> {
/// Map indicating what traits are in scope for places where this
/// is relevant; generated by resolve.
trait_map: FxHashMap<DefIndex,
Lrc<FxHashMap<ItemLocalId,
Lrc<StableVec<TraitCandidate>>>>>,
FxHashMap<ItemLocalId,
StableVec<TraitCandidate>>>,
/// Export map produced by name resolution.
export_map: FxHashMap<DefId, Lrc<Vec<Export<hir::HirId>>>>,
@ -1305,13 +1305,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
None
};
let mut trait_map: FxHashMap<_, Lrc<FxHashMap<_, _>>> = FxHashMap::default();
let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default();
for (k, v) in resolutions.trait_map {
let hir_id = hir.node_to_hir_id(k);
let map = trait_map.entry(hir_id.owner).or_default();
Lrc::get_mut(map).unwrap()
.insert(hir_id.local_id,
Lrc::new(StableVec::new(v)));
map.insert(hir_id.local_id, StableVec::new(v));
}
GlobalCtxt {
@ -2979,9 +2977,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
lint::struct_lint_level(self.sess, lint, level, src, None, msg)
}
pub fn in_scope_traits(self, id: HirId) -> Option<Lrc<StableVec<TraitCandidate>>> {
pub fn in_scope_traits(self, id: HirId) -> Option<&'gcx StableVec<TraitCandidate>> {
self.in_scope_traits_map(id.owner)
.and_then(|map| map.get(&id.local_id).cloned())
.and_then(|map| map.get(&id.local_id))
}
pub fn named_region(self, id: HirId) -> Option<resolve_lifetime::Region> {
@ -3054,7 +3052,7 @@ fn ptr_eq<T, U>(t: *const T, u: *const U) -> bool {
}
pub fn provide(providers: &mut ty::query::Providers<'_>) {
providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id).cloned();
providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id);
providers.module_exports = |tcx, id| tcx.gcx.export_map.get(&id).cloned();
providers.crate_name = |tcx, id| {
assert_eq!(id, LOCAL_CRATE);