]> git.lizzy.rs Git - rust.git/commitdiff
add more debug logs
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 12 Jun 2019 14:42:21 +0000 (10:42 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 12 Jun 2019 17:56:29 +0000 (13:56 -0400)
src/librustc/traits/select.rs

index 4411aa6cb9401f20dedcf2bd11a735fcc162c25c..5a59a13a37c5233ffded421b417b4a451e9e9b25 100644 (file)
@@ -4126,7 +4126,7 @@ struct ProvisionalEvaluationCache<'tcx> {
 
 /// A cache value for the provisional cache: contains the depth-first
 /// number (DFN) and result.
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, Debug)]
 struct ProvisionalEvaluation {
     from_dfn: usize,
     result: EvaluationResult,
@@ -4145,6 +4145,11 @@ fn next_dfn(&self) -> usize {
     /// it an access to the stack slots at depth
     /// `self.current_reached_depth()` and above.
     fn get_provisional(&self, fresh_trait_ref: ty::PolyTraitRef<'tcx>) -> Option<EvaluationResult> {
+        debug!(
+            "get_provisional(fresh_trait_ref={:?}) = {:#?}",
+            fresh_trait_ref,
+            self.map.borrow().get(&fresh_trait_ref),
+        );
         Some(self.map.borrow().get(&fresh_trait_ref)?.result)
     }
 
@@ -4166,9 +4171,18 @@ fn insert_provisional(
         fresh_trait_ref: ty::PolyTraitRef<'tcx>,
         result: EvaluationResult,
     ) {
+        debug!(
+            "insert_provisional(from_dfn={}, reached_depth={}, fresh_trait_ref={:?}, result={:?})",
+            from_dfn,
+            reached_depth,
+            fresh_trait_ref,
+            result,
+        );
         let r_d = self.reached_depth.get();
         self.reached_depth.set(r_d.min(reached_depth));
 
+        debug!("insert_provisional: reached_depth={:?}", self.reached_depth.get());
+
         self.map.borrow_mut().insert(fresh_trait_ref, ProvisionalEvaluation { from_dfn, result });
     }
 
@@ -4181,7 +4195,18 @@ fn insert_provisional(
     /// these provisional entries must either depend on it or some
     /// ancestor of it.
     fn on_failure(&self, dfn: usize) {
-        self.map.borrow_mut().retain(|_key, eval| eval.from_dfn >= dfn)
+        debug!(
+            "on_failure(dfn={:?})",
+            dfn,
+        );
+        self.map.borrow_mut().retain(|key, eval| {
+            if !eval.from_dfn >= dfn {
+                debug!("on_failure: removing {:?}", key);
+                false
+            } else {
+                true
+            }
+        });
     }
 
     /// Invoked when the node at depth `depth` completed without
@@ -4194,11 +4219,24 @@ fn on_completion(
         depth: usize,
         mut op: impl FnMut(ty::PolyTraitRef<'tcx>, EvaluationResult),
     ) {
+        debug!(
+            "on_completion(depth={}, reached_depth={})",
+            depth,
+            self.reached_depth.get(),
+        );
+
         if self.reached_depth.get() < depth {
+            debug!("on_completion: did not yet reach depth to complete");
             return;
         }
 
         for (fresh_trait_ref, eval) in self.map.borrow_mut().drain() {
+            debug!(
+                "on_completion: fresh_trait_ref={:?} eval={:?}",
+                fresh_trait_ref,
+                eval,
+            );
+
             op(fresh_trait_ref, eval.result);
         }