about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2022-02-21 10:40:41 +0100
committerlcnr <rust@lcnr.de>2022-02-21 12:00:26 +0100
commitec0a0ca3f496746c188373bf2530559ec9973c19 (patch)
tree550d2f3fbc396bc41c8c2da3a4b4160a8cdd6b31
parent15e95c0b7fe5d836db3911c7a83e9afbed84c39f (diff)
downloadrust-ec0a0ca3f496746c188373bf2530559ec9973c19.tar.gz
rust-ec0a0ca3f496746c188373bf2530559ec9973c19.zip
don't check for the leak_check twice
-rw-r--r--compiler/rustc_trait_selection/src/traits/coherence.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs
index b2aa72e0e67..8b76f3f7151 100644
--- a/compiler/rustc_trait_selection/src/traits/coherence.rs
+++ b/compiler/rustc_trait_selection/src/traits/coherence.rs
@@ -160,20 +160,12 @@ fn overlap<'cx, 'tcx>(
     );
 
     selcx.infcx().probe_maybe_skip_leak_check(skip_leak_check.is_yes(), |snapshot| {
-        overlap_within_probe(
-            selcx,
-            skip_leak_check,
-            impl1_def_id,
-            impl2_def_id,
-            overlap_mode,
-            snapshot,
-        )
+        overlap_within_probe(selcx, impl1_def_id, impl2_def_id, overlap_mode, snapshot)
     })
 }
 
 fn overlap_within_probe<'cx, 'tcx>(
     selcx: &mut SelectionContext<'cx, 'tcx>,
-    skip_leak_check: SkipLeakCheck,
     impl1_def_id: DefId,
     impl2_def_id: DefId,
     overlap_mode: OverlapMode,
@@ -207,11 +199,11 @@ fn overlap_within_probe<'cx, 'tcx>(
         }
     }
 
-    if !skip_leak_check.is_yes() {
-        if infcx.leak_check(true, snapshot).is_err() {
-            debug!("overlap: leak check failed");
-            return None;
-        }
+    // We disable the leak when when creating the `snapshot` by using
+    // `infcx.probe_maybe_disable_leak_check`.
+    if infcx.leak_check(true, snapshot).is_err() {
+        debug!("overlap: leak check failed");
+        return None;
     }
 
     let intercrate_ambiguity_causes = selcx.take_intercrate_ambiguity_causes();