Skip to content

Commit 6b2aaaf

Browse files
committed
Auto merge of #41340 - eddyb:demand-assoc-defids, r=nikomatsakis
rustc: move associated_item_def_ids to an on-demand query. r? @nikomatsakis
2 parents 235fe83 + 17fce06 commit 6b2aaaf

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/librustc/ty/mod.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use ty;
3131
use ty::subst::{Subst, Substs};
3232
use ty::util::IntTypeExt;
3333
use ty::walk::TypeWalker;
34-
use util::common::MemoizationMap;
3534
use util::nodemap::{NodeSet, DefIdMap, FxHashMap};
3635

3736
use serialize::{self, Encodable, Encoder};
@@ -2154,30 +2153,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
21542153
}
21552154

21562155
pub fn associated_item_def_ids(self, def_id: DefId) -> Rc<Vec<DefId>> {
2157-
if !def_id.is_local() {
2158-
return queries::associated_item_def_ids::get(self, DUMMY_SP, def_id);
2159-
}
2160-
2161-
self.maps.associated_item_def_ids.memoize(def_id, || {
2162-
let id = self.hir.as_local_node_id(def_id).unwrap();
2163-
let item = self.hir.expect_item(id);
2164-
let vec: Vec<_> = match item.node {
2165-
hir::ItemTrait(.., ref trait_item_refs) => {
2166-
trait_item_refs.iter()
2167-
.map(|trait_item_ref| trait_item_ref.id)
2168-
.map(|id| self.hir.local_def_id(id.node_id))
2169-
.collect()
2170-
}
2171-
hir::ItemImpl(.., ref impl_item_refs) => {
2172-
impl_item_refs.iter()
2173-
.map(|impl_item_ref| impl_item_ref.id)
2174-
.map(|id| self.hir.local_def_id(id.node_id))
2175-
.collect()
2176-
}
2177-
_ => span_bug!(item.span, "associated_item_def_ids: not impl or trait")
2178-
};
2179-
Rc::new(vec)
2180-
})
2156+
queries::associated_item_def_ids::get(self, DUMMY_SP, def_id)
21812157
}
21822158

21832159
#[inline] // FIXME(#35870) Avoid closures being unexported due to impl Trait.
@@ -2708,9 +2684,33 @@ fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
27082684
ty
27092685
}
27102686

2687+
fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
2688+
def_id: DefId)
2689+
-> Rc<Vec<DefId>> {
2690+
let id = tcx.hir.as_local_node_id(def_id).unwrap();
2691+
let item = tcx.hir.expect_item(id);
2692+
let vec: Vec<_> = match item.node {
2693+
hir::ItemTrait(.., ref trait_item_refs) => {
2694+
trait_item_refs.iter()
2695+
.map(|trait_item_ref| trait_item_ref.id)
2696+
.map(|id| tcx.hir.local_def_id(id.node_id))
2697+
.collect()
2698+
}
2699+
hir::ItemImpl(.., ref impl_item_refs) => {
2700+
impl_item_refs.iter()
2701+
.map(|impl_item_ref| impl_item_ref.id)
2702+
.map(|id| tcx.hir.local_def_id(id.node_id))
2703+
.collect()
2704+
}
2705+
_ => span_bug!(item.span, "associated_item_def_ids: not impl or trait")
2706+
};
2707+
Rc::new(vec)
2708+
}
2709+
27112710
pub fn provide(providers: &mut ty::maps::Providers) {
27122711
*providers = ty::maps::Providers {
27132712
associated_item,
2713+
associated_item_def_ids,
27142714
adt_sized_constraint,
27152715
..*providers
27162716
};

0 commit comments

Comments
 (0)