Skip to content
Permalink
Browse files

Update in_scope_traits_map

  • Loading branch information...
Zoxc committed Dec 1, 2018
1 parent fb57879 commit 5f808f6588c3e66d9e578d039dd77f0eb0ea053b
Showing with 8 additions and 10 deletions.
  1. +1 −1 src/librustc/query/mod.rs
  2. +7 −9 src/librustc/ty/context.rs
@@ -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" }
}
@@ -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);

0 comments on commit 5f808f6

Please sign in to comment.
You can’t perform that action at this time.