]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trait_selection/traits/select/mod.rs
move leak-check to during coherence, candidate eval
[rust.git] / src / librustc_trait_selection / traits / select / mod.rs
index e90acbbce67ba17643d3674309e03ff7463f6a12..e5960e731033f0f0852ad09d42c618c975a64157 100644 (file)
@@ -347,6 +347,12 @@ fn evaluation_probe(
     ) -> Result<EvaluationResult, OverflowError> {
         self.infcx.probe(|snapshot| -> Result<EvaluationResult, OverflowError> {
             let result = op(self)?;
+
+            match self.infcx.leak_check(true, snapshot) {
+                Ok(()) => {}
+                Err(_) => return Ok(EvaluatedToErr),
+            }
+
             match self.infcx.region_constraints_added_in_snapshot(snapshot) {
                 None => Ok(result),
                 Some(_) => Ok(result.max(EvaluatedToOkModuloRegions)),
@@ -2402,11 +2408,7 @@ fn head(&self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
     }
 
     fn depth(&self) -> usize {
-        if let Some(head) = self.head {
-            head.depth
-        } else {
-            0
-        }
+        if let Some(head) = self.head { head.depth } else { 0 }
     }
 }