do not access inherited_impls
map directly
This commit is contained in:
parent
ace517da0d
commit
f35ff22fe8
3 changed files with 20 additions and 17 deletions
|
@ -475,9 +475,9 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||||
// This is done to handle the case where, for example, the static
|
// 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
|
// method of a private type is used, but the type itself is never
|
||||||
// called directly.
|
// called directly.
|
||||||
if let Some(impl_list) =
|
let def_id = self.tcx.hir.local_def_id(id);
|
||||||
self.tcx.maps.inherent_impls.borrow().get(&self.tcx.hir.local_def_id(id)) {
|
let inherent_impls = self.tcx.inherent_impls(def_id);
|
||||||
for &impl_did in impl_list.iter() {
|
for &impl_did in inherent_impls.iter() {
|
||||||
for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {
|
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 let Some(item_node_id) = self.tcx.hir.as_local_node_id(item_did) {
|
||||||
if self.live_symbols.contains(&item_node_id) {
|
if self.live_symbols.contains(&item_node_id) {
|
||||||
|
@ -486,7 +486,6 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
false
|
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.
|
// Encodes the inherent implementations of a structure, enumeration, or trait.
|
||||||
fn encode_inherent_implementations(&mut self, def_id: DefId) -> LazySeq<DefIndex> {
|
fn encode_inherent_implementations(&mut self, def_id: DefId) -> LazySeq<DefIndex> {
|
||||||
debug!("EntryBuilder::encode_inherent_implementations({:?})", def_id);
|
debug!("EntryBuilder::encode_inherent_implementations({:?})", def_id);
|
||||||
match self.tcx.maps.inherent_impls.borrow().get(&def_id) {
|
let implementations = self.tcx.inherent_impls(def_id);
|
||||||
None => LazySeq::empty(),
|
if implementations.is_empty() {
|
||||||
Some(implementations) => {
|
LazySeq::empty()
|
||||||
|
} else {
|
||||||
self.lazy_seq(implementations.iter().map(|&def_id| {
|
self.lazy_seq(implementations.iter().map(|&def_id| {
|
||||||
assert!(def_id.is_local());
|
assert!(def_id.is_local());
|
||||||
def_id.index
|
def_id.index
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn encode_stability(&mut self, def_id: DefId) -> Option<Lazy<attr::Stability>> {
|
fn encode_stability(&mut self, def_id: DefId) -> Option<Lazy<attr::Stability>> {
|
||||||
debug!("EntryBuilder::encode_stability({:?})", def_id);
|
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
|
// [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 result = tcx.dep_graph.with_ignore(|| {
|
||||||
let crate_map = tcx.crate_inherent_impls(ty_def_id.krate);
|
let crate_map = tcx.crate_inherent_impls(ty_def_id.krate);
|
||||||
match crate_map.inherent_impls.get(&ty_def_id) {
|
match crate_map.inherent_impls.get(&ty_def_id) {
|
||||||
Some(v) => v.clone(),
|
Some(v) => v.clone(),
|
||||||
None => Rc::new(vec![]),
|
None => EMPTY_DEF_ID_VEC.with(|v| v.clone())
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue