fix var equality issue with old canonicalizer
This commit is contained in:
parent
8d13454498
commit
3bfcfd079d
2 changed files with 22 additions and 5 deletions
|
@ -376,9 +376,18 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, mut t: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
match *t.kind() {
|
match *t.kind() {
|
||||||
ty::Infer(ty::TyVar(vid)) => {
|
ty::Infer(ty::TyVar(mut vid)) => {
|
||||||
|
// We need to canonicalize the *root* of our ty var.
|
||||||
|
// This is so that our canonical response correctly reflects
|
||||||
|
// any equated inference vars correctly!
|
||||||
|
let root_vid = self.infcx.root_var(vid);
|
||||||
|
if root_vid != vid {
|
||||||
|
t = self.infcx.tcx.mk_ty_var(root_vid);
|
||||||
|
vid = root_vid;
|
||||||
|
}
|
||||||
|
|
||||||
debug!("canonical: type var found with vid {:?}", vid);
|
debug!("canonical: type var found with vid {:?}", vid);
|
||||||
match self.infcx.probe_ty_var(vid) {
|
match self.infcx.probe_ty_var(vid) {
|
||||||
// `t` could be a float / int variable; canonicalize that instead.
|
// `t` could be a float / int variable; canonicalize that instead.
|
||||||
|
@ -469,9 +478,18 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
fn fold_const(&mut self, mut ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||||
match ct.kind() {
|
match ct.kind() {
|
||||||
ty::ConstKind::Infer(InferConst::Var(vid)) => {
|
ty::ConstKind::Infer(InferConst::Var(mut vid)) => {
|
||||||
|
// We need to canonicalize the *root* of our const var.
|
||||||
|
// This is so that our canonical response correctly reflects
|
||||||
|
// any equated inference vars correctly!
|
||||||
|
let root_vid = self.infcx.root_const_var(vid);
|
||||||
|
if root_vid != vid {
|
||||||
|
ct = self.infcx.tcx.mk_const(ty::InferConst::Var(root_vid), ct.ty());
|
||||||
|
vid = root_vid;
|
||||||
|
}
|
||||||
|
|
||||||
debug!("canonical: const var found with vid {:?}", vid);
|
debug!("canonical: const var found with vid {:?}", vid);
|
||||||
match self.infcx.probe_const_var(vid) {
|
match self.infcx.probe_const_var(vid) {
|
||||||
Ok(c) => {
|
Ok(c) => {
|
||||||
|
|
|
@ -267,7 +267,6 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
||||||
// We need to canonicalize the *root* of our ty var.
|
// We need to canonicalize the *root* of our ty var.
|
||||||
// This is so that our canonical response correctly reflects
|
// This is so that our canonical response correctly reflects
|
||||||
// any equated inference vars correctly!
|
// any equated inference vars correctly!
|
||||||
|
|
||||||
let root_vid = self.infcx.root_var(vid);
|
let root_vid = self.infcx.root_var(vid);
|
||||||
if root_vid != vid {
|
if root_vid != vid {
|
||||||
t = self.infcx.tcx.mk_ty_var(root_vid);
|
t = self.infcx.tcx.mk_ty_var(root_vid);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue