Skip to content

Commit 23a0a44

Browse files
committed
don't resolve regions in query input
fixes a soundness regression described in the PR description.
1 parent 1c8ce6a commit 23a0a44

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,21 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
202202
fn canonicalize_free_region<'tcx>(
203203
&self,
204204
canonicalizer: &mut Canonicalizer<'_, 'tcx>,
205-
r: ty::Region<'tcx>,
205+
mut r: ty::Region<'tcx>,
206206
) -> ty::Region<'tcx> {
207+
if let ty::ReVar(vid) = *r {
208+
r = canonicalizer
209+
.infcx
210+
.inner
211+
.borrow_mut()
212+
.unwrap_region_constraints()
213+
.opportunistic_resolve_var(canonicalizer.tcx, vid);
214+
debug!(
215+
"canonical: region var found with vid {vid:?}, \
216+
opportunistically resolved to {r:?}",
217+
);
218+
};
219+
207220
match *r {
208221
ty::ReLateParam(_) | ty::ReErased | ty::ReStatic | ty::ReEarlyParam(..) => r,
209222

@@ -381,25 +394,12 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
381394
}
382395
}
383396

384-
ty::ReVar(vid) => {
385-
let resolved = self
386-
.infcx
387-
.inner
388-
.borrow_mut()
389-
.unwrap_region_constraints()
390-
.opportunistic_resolve_var(self.tcx, vid);
391-
debug!(
392-
"canonical: region var found with vid {vid:?}, \
393-
opportunistically resolved to {resolved:?}",
394-
);
395-
self.canonicalize_mode.canonicalize_free_region(self, resolved)
396-
}
397-
398397
ty::ReStatic
399398
| ty::ReEarlyParam(..)
400399
| ty::ReError(_)
401400
| ty::ReLateParam(_)
402401
| ty::RePlaceholder(..)
402+
| ty::ReVar(_)
403403
| ty::ReErased => self.canonicalize_mode.canonicalize_free_region(self, r),
404404
}
405405
}

0 commit comments

Comments
 (0)