mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 01:13:11 +00:00
Update in_scope_traits_map
This commit is contained in:
parent
fb578794b0
commit
5f808f6588
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user