Skip to content

Commit

Permalink
don't resolve regions in query input
Browse files Browse the repository at this point in the history
fixes a soundness regression described in the PR description.
  • Loading branch information
aliemjay committed Dec 13, 2023
1 parent a1459c3 commit fafe66d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,21 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
fn canonicalize_free_region<'tcx>(
&self,
canonicalizer: &mut Canonicalizer<'_, 'tcx>,
r: ty::Region<'tcx>,
mut r: ty::Region<'tcx>,
) -> ty::Region<'tcx> {
if let ty::ReVar(vid) = *r {
r = canonicalizer
.infcx
.inner
.borrow_mut()
.unwrap_region_constraints()
.opportunistic_resolve_var(canonicalizer.tcx, vid);
debug!(
"canonical: region var found with vid {vid:?}, \
opportunistically resolved to {r:?}",
);
};

match *r {
ty::ReLateParam(_) | ty::ReErased | ty::ReStatic | ty::ReEarlyParam(..) => r,

Expand Down Expand Up @@ -381,25 +394,12 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
}
}

ty::ReVar(vid) => {
let resolved = self
.infcx
.inner
.borrow_mut()
.unwrap_region_constraints()
.opportunistic_resolve_var(self.tcx, vid);
debug!(
"canonical: region var found with vid {vid:?}, \
opportunistically resolved to {resolved:?}",
);
self.canonicalize_mode.canonicalize_free_region(self, resolved)
}

ty::ReStatic
| ty::ReEarlyParam(..)
| ty::ReError(_)
| ty::ReLateParam(_)
| ty::RePlaceholder(..)
| ty::ReVar(_)
| ty::ReErased => self.canonicalize_mode.canonicalize_free_region(self, r),
}
}
Expand Down

0 comments on commit fafe66d

Please sign in to comment.