]> git.lizzy.rs Git - rust.git/commitdiff
added dep nodes and comment
authorachernyak <artemchernyak@gmail.com>
Sat, 29 Apr 2017 14:56:01 +0000 (09:56 -0500)
committerachernyak <artemchernyak@gmail.com>
Sat, 29 Apr 2017 14:56:01 +0000 (09:56 -0500)
src/librustc/dep_graph/dep_node.rs
src/librustc/ty/maps.rs

index 31e6a3106a438890a49d7f960e6b6aad12b1caaf..acf9baf9677b407b63d767d2228269984af85103 100644 (file)
@@ -148,6 +148,10 @@ pub enum DepNode<D: Clone + Debug> {
     // For proj. cache, we just keep a list of all def-ids, since it is
     // not a hotspot.
     ProjectionCache { def_ids: Vec<D> },
+
+    // Depnodes for MetaData
+    DescribeDef(D),
+    DefSpan(D),
 }
 
 impl<D: Clone + Debug> DepNode<D> {
@@ -253,6 +257,8 @@ pub fn map_def<E, OP>(&self, mut op: OP) -> Option<DepNode<E>>
                 let def_ids: Option<Vec<E>> = def_ids.iter().map(op).collect();
                 def_ids.map(|d| ProjectionCache { def_ids: d })
             }
+            DescribeDef(ref d) => op(d).map(MetaData),
+            DefSpan(ref d) => op(d).map(MetaData),
         }
     }
 }
index 13c167de0fd5b21b23b5da383ae57d14c3a0c18d..233066f266a1db770e432d06542ed62c88861156 100644 (file)
@@ -365,6 +365,8 @@ fn try_get_with<F, R>(tcx: TyCtxt<'a, $tcx, 'lcx>,
                 }
 
                 // FIXME(eddyb) Get more valid Span's on queries.
+                // def_span guard is necesary to prevent a recursive loop,
+                // default_span calls def_span query internally.
                 if span == DUMMY_SP && stringify!($name) != "def_span" {
                     span = key.default_span(tcx)
                 }
@@ -574,9 +576,8 @@ fn default() -> Self {
     [] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
     [] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
 
-
-    [] describe_def: MetaData(DefId) -> Option<Def>,
-    [] def_span: MetaData(DefId) -> Span
+    [] describe_def: describe_def(DefId) -> Option<Def>,
+    [] def_span: def_span(DefId) -> Span
 }
 
 fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
@@ -608,3 +609,11 @@ fn typeck_item_bodies_dep_node(_: CrateNum) -> DepNode<DefId> {
 fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> {
     DepNode::ConstEval(def_id)
 }
+
+fn describe_def(def_id: DefId) -> DepNode<DefId> {
+    DepNode::DescribeDef(def_id)
+}
+
+fn def_span(def_id: DefId) -> DepNode<DefId> {
+    DepNode::DefSpan(def_id)
+}