Skip to content

Commit ec0a0ca

Browse files
committed
don't check for the leak_check twice
1 parent 15e95c0 commit ec0a0ca

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

compiler/rustc_trait_selection/src/traits/coherence.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,12 @@ fn overlap<'cx, 'tcx>(
160160
);
161161

162162
selcx.infcx().probe_maybe_skip_leak_check(skip_leak_check.is_yes(), |snapshot| {
163-
overlap_within_probe(
164-
selcx,
165-
skip_leak_check,
166-
impl1_def_id,
167-
impl2_def_id,
168-
overlap_mode,
169-
snapshot,
170-
)
163+
overlap_within_probe(selcx, impl1_def_id, impl2_def_id, overlap_mode, snapshot)
171164
})
172165
}
173166

174167
fn overlap_within_probe<'cx, 'tcx>(
175168
selcx: &mut SelectionContext<'cx, 'tcx>,
176-
skip_leak_check: SkipLeakCheck,
177169
impl1_def_id: DefId,
178170
impl2_def_id: DefId,
179171
overlap_mode: OverlapMode,
@@ -207,11 +199,11 @@ fn overlap_within_probe<'cx, 'tcx>(
207199
}
208200
}
209201

210-
if !skip_leak_check.is_yes() {
211-
if infcx.leak_check(true, snapshot).is_err() {
212-
debug!("overlap: leak check failed");
213-
return None;
214-
}
202+
// We disable the leak when when creating the `snapshot` by using
203+
// `infcx.probe_maybe_disable_leak_check`.
204+
if infcx.leak_check(true, snapshot).is_err() {
205+
debug!("overlap: leak check failed");
206+
return None;
215207
}
216208

217209
let intercrate_ambiguity_causes = selcx.take_intercrate_ambiguity_causes();

0 commit comments

Comments
 (0)