Skip to content

Commit ad1959e

Browse files
committed
added dep nodes and comment
1 parent 2f73b17 commit ad1959e

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/librustc/dep_graph/dep_node.rs

+6
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ pub enum DepNode<D: Clone + Debug> {
148148
// For proj. cache, we just keep a list of all def-ids, since it is
149149
// not a hotspot.
150150
ProjectionCache { def_ids: Vec<D> },
151+
152+
// Depnodes for MetaData
153+
DescribeDef(D),
154+
DefSpan(D),
151155
}
152156

153157
impl<D: Clone + Debug> DepNode<D> {
@@ -253,6 +257,8 @@ impl<D: Clone + Debug> DepNode<D> {
253257
let def_ids: Option<Vec<E>> = def_ids.iter().map(op).collect();
254258
def_ids.map(|d| ProjectionCache { def_ids: d })
255259
}
260+
DescribeDef(ref d) => op(d).map(MetaData),
261+
DefSpan(ref d) => op(d).map(MetaData),
256262
}
257263
}
258264
}

src/librustc/ty/maps.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ macro_rules! define_maps {
365365
}
366366

367367
// FIXME(eddyb) Get more valid Span's on queries.
368+
// def_span guard is necesary to prevent a recursive loop,
369+
// default_span calls def_span query internally.
368370
if span == DUMMY_SP && stringify!($name) != "def_span" {
369371
span = key.default_span(tcx)
370372
}
@@ -574,9 +576,8 @@ define_maps! { <'tcx>
574576
[] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
575577
[] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
576578

577-
578-
[] describe_def: MetaData(DefId) -> Option<Def>,
579-
[] def_span: MetaData(DefId) -> Span
579+
[] describe_def: describe_def(DefId) -> Option<Def>,
580+
[] def_span: def_span(DefId) -> Span
580581
}
581582

582583
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
@@ -608,3 +609,11 @@ fn typeck_item_bodies_dep_node(_: CrateNum) -> DepNode<DefId> {
608609
fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> {
609610
DepNode::ConstEval(def_id)
610611
}
612+
613+
fn describe_def(def_id: DefId) -> DepNode<DefId> {
614+
DepNode::DescribeDef(def_id)
615+
}
616+
617+
fn def_span(def_id: DefId) -> DepNode<DefId> {
618+
DepNode::DefSpan(def_id)
619+
}

0 commit comments

Comments
 (0)