do not access inherited_impls
map directly
This commit is contained in:
parent
ace517da0d
commit
f35ff22fe8
@ -475,9 +475,9 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
// This is done to handle the case where, for example, the static
|
||||
// method of a private type is used, but the type itself is never
|
||||
// called directly.
|
||||
if let Some(impl_list) =
|
||||
self.tcx.maps.inherent_impls.borrow().get(&self.tcx.hir.local_def_id(id)) {
|
||||
for &impl_did in impl_list.iter() {
|
||||
let def_id = self.tcx.hir.local_def_id(id);
|
||||
let inherent_impls = self.tcx.inherent_impls(def_id);
|
||||
for &impl_did in inherent_impls.iter() {
|
||||
for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {
|
||||
if let Some(item_node_id) = self.tcx.hir.as_local_node_id(item_did) {
|
||||
if self.live_symbols.contains(&item_node_id) {
|
||||
@ -486,7 +486,6 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
|
@ -626,16 +626,16 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||
// Encodes the inherent implementations of a structure, enumeration, or trait.
|
||||
fn encode_inherent_implementations(&mut self, def_id: DefId) -> LazySeq<DefIndex> {
|
||||
debug!("EntryBuilder::encode_inherent_implementations({:?})", def_id);
|
||||
match self.tcx.maps.inherent_impls.borrow().get(&def_id) {
|
||||
None => LazySeq::empty(),
|
||||
Some(implementations) => {
|
||||
let implementations = self.tcx.inherent_impls(def_id);
|
||||
if implementations.is_empty() {
|
||||
LazySeq::empty()
|
||||
} else {
|
||||
self.lazy_seq(implementations.iter().map(|&def_id| {
|
||||
assert!(def_id.is_local());
|
||||
def_id.index
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_stability(&mut self, def_id: DefId) -> Option<Lazy<attr::Stability>> {
|
||||
debug!("EntryBuilder::encode_stability({:?})", def_id);
|
||||
|
@ -66,11 +66,15 @@ pub fn inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
//
|
||||
// [the plan]: https://github.com/rust-lang/rust-roadmap/issues/4
|
||||
|
||||
thread_local! {
|
||||
static EMPTY_DEF_ID_VEC: Rc<Vec<DefId>> = Rc::new(vec![])
|
||||
}
|
||||
|
||||
let result = tcx.dep_graph.with_ignore(|| {
|
||||
let crate_map = tcx.crate_inherent_impls(ty_def_id.krate);
|
||||
match crate_map.inherent_impls.get(&ty_def_id) {
|
||||
Some(v) => v.clone(),
|
||||
None => Rc::new(vec![]),
|
||||
None => EMPTY_DEF_ID_VEC.with(|v| v.clone())
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user