|
7 | 7 | use crate::infer::{CombinedSnapshot, InferOk};
|
8 | 8 | use crate::traits::select::IntercrateAmbiguityCause;
|
9 | 9 | use crate::traits::IntercrateMode;
|
| 10 | +use crate::traits::SkipLeakCheck; |
10 | 11 | use crate::traits::{self, Normalized, Obligation, ObligationCause, SelectionContext};
|
11 | 12 | use crate::ty::fold::TypeFoldable;
|
12 | 13 | use crate::ty::subst::Subst;
|
@@ -53,6 +54,7 @@ pub fn overlapping_impls<F1, F2, R>(
|
53 | 54 | impl1_def_id: DefId,
|
54 | 55 | impl2_def_id: DefId,
|
55 | 56 | intercrate_mode: IntercrateMode,
|
| 57 | + skip_leak_check: SkipLeakCheck, |
56 | 58 | on_overlap: F1,
|
57 | 59 | no_overlap: F2,
|
58 | 60 | ) -> R
|
|
70 | 72 |
|
71 | 73 | let overlaps = tcx.infer_ctxt().enter(|infcx| {
|
72 | 74 | let selcx = &mut SelectionContext::intercrate(&infcx, intercrate_mode);
|
73 |
| - overlap(selcx, impl1_def_id, impl2_def_id).is_some() |
| 75 | + overlap(selcx, skip_leak_check, impl1_def_id, impl2_def_id).is_some() |
74 | 76 | });
|
75 | 77 |
|
76 | 78 | if !overlaps {
|
|
83 | 85 | tcx.infer_ctxt().enter(|infcx| {
|
84 | 86 | let selcx = &mut SelectionContext::intercrate(&infcx, intercrate_mode);
|
85 | 87 | selcx.enable_tracking_intercrate_ambiguity_causes();
|
86 |
| - on_overlap(overlap(selcx, impl1_def_id, impl2_def_id).unwrap()) |
| 88 | + on_overlap(overlap(selcx, skip_leak_check, impl1_def_id, impl2_def_id).unwrap()) |
87 | 89 | })
|
88 | 90 | }
|
89 | 91 |
|
@@ -113,12 +115,15 @@ fn with_fresh_ty_vars<'cx, 'tcx>(
|
113 | 115 | /// where-clauses)? If so, returns an `ImplHeader` that unifies the two impls.
|
114 | 116 | fn overlap<'cx, 'tcx>(
|
115 | 117 | selcx: &mut SelectionContext<'cx, 'tcx>,
|
| 118 | + skip_leak_check: SkipLeakCheck, |
116 | 119 | a_def_id: DefId,
|
117 | 120 | b_def_id: DefId,
|
118 | 121 | ) -> Option<OverlapResult<'tcx>> {
|
119 | 122 | debug!("overlap(a_def_id={:?}, b_def_id={:?})", a_def_id, b_def_id);
|
120 | 123 |
|
121 |
| - selcx.infcx().probe(|snapshot| overlap_within_probe(selcx, a_def_id, b_def_id, snapshot)) |
| 124 | + selcx.infcx().probe_maybe_skip_leak_check(skip_leak_check.is_yes(), |snapshot| { |
| 125 | + overlap_within_probe(selcx, a_def_id, b_def_id, snapshot) |
| 126 | + }) |
122 | 127 | }
|
123 | 128 |
|
124 | 129 | fn overlap_within_probe(
|
@@ -146,7 +151,9 @@ fn overlap_within_probe(
|
146 | 151 | .eq_impl_headers(&a_impl_header, &b_impl_header)
|
147 | 152 | {
|
148 | 153 | Ok(InferOk { obligations, value: () }) => obligations,
|
149 |
| - Err(_) => return None, |
| 154 | + Err(_) => { |
| 155 | + return None; |
| 156 | + } |
150 | 157 | };
|
151 | 158 |
|
152 | 159 | debug!("overlap: unification check succeeded");
|
|
0 commit comments