Canonicalize const variables correctly
This commit is contained in:
parent
72e74d7b9c
commit
012910dab2
4 changed files with 11 additions and 14 deletions
|
@ -425,7 +425,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
|
||||||
// FIXME: perf problem described in #55921.
|
// FIXME: perf problem described in #55921.
|
||||||
ui = ty::UniverseIndex::ROOT;
|
ui = ty::UniverseIndex::ROOT;
|
||||||
return self.canonicalize_const_var(
|
return self.canonicalize_const_var(
|
||||||
CanonicalVarInfo { kind: CanonicalVarKind::Const(ui) },
|
CanonicalVarInfo { kind: CanonicalVarKind::Const(ui, ct.ty) },
|
||||||
ct,
|
ct,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,12 +137,9 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||||
self.tcx.mk_region(ty::RePlaceholder(placeholder_mapped)).into()
|
self.tcx.mk_region(ty::RePlaceholder(placeholder_mapped)).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
CanonicalVarKind::Const(ui) => self
|
CanonicalVarKind::Const(ui, ty) => self
|
||||||
.next_const_var_in_universe(
|
.next_const_var_in_universe(
|
||||||
self.next_ty_var_in_universe(
|
ty,
|
||||||
TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span },
|
|
||||||
universe_map(ui),
|
|
||||||
),
|
|
||||||
ConstVariableOrigin { kind: ConstVariableOriginKind::MiscVariable, span },
|
ConstVariableOrigin { kind: ConstVariableOriginKind::MiscVariable, span },
|
||||||
universe_map(ui),
|
universe_map(ui),
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
use crate::infer::MemberConstraint;
|
use crate::infer::MemberConstraint;
|
||||||
use crate::ty::subst::GenericArg;
|
use crate::ty::subst::GenericArg;
|
||||||
use crate::ty::{self, BoundVar, List, Region, TyCtxt};
|
use crate::ty::{self, BoundVar, List, Region, Ty, TyCtxt};
|
||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
@ -104,7 +104,7 @@ impl<'tcx> CanonicalVarInfo<'tcx> {
|
||||||
CanonicalVarKind::PlaceholderTy(_) => false,
|
CanonicalVarKind::PlaceholderTy(_) => false,
|
||||||
CanonicalVarKind::Region(_) => true,
|
CanonicalVarKind::Region(_) => true,
|
||||||
CanonicalVarKind::PlaceholderRegion(..) => false,
|
CanonicalVarKind::PlaceholderRegion(..) => false,
|
||||||
CanonicalVarKind::Const(_) => true,
|
CanonicalVarKind::Const(..) => true,
|
||||||
CanonicalVarKind::PlaceholderConst(_) => false,
|
CanonicalVarKind::PlaceholderConst(_) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ pub enum CanonicalVarKind<'tcx> {
|
||||||
PlaceholderRegion(ty::PlaceholderRegion),
|
PlaceholderRegion(ty::PlaceholderRegion),
|
||||||
|
|
||||||
/// Some kind of const inference variable.
|
/// Some kind of const inference variable.
|
||||||
Const(ty::UniverseIndex),
|
Const(ty::UniverseIndex, Ty<'tcx>),
|
||||||
|
|
||||||
/// A "placeholder" that represents "any const".
|
/// A "placeholder" that represents "any const".
|
||||||
PlaceholderConst(ty::PlaceholderConst<'tcx>),
|
PlaceholderConst(ty::PlaceholderConst<'tcx>),
|
||||||
|
@ -147,7 +147,7 @@ impl<'tcx> CanonicalVarKind<'tcx> {
|
||||||
CanonicalVarKind::PlaceholderTy(placeholder) => placeholder.universe,
|
CanonicalVarKind::PlaceholderTy(placeholder) => placeholder.universe,
|
||||||
CanonicalVarKind::Region(ui) => ui,
|
CanonicalVarKind::Region(ui) => ui,
|
||||||
CanonicalVarKind::PlaceholderRegion(placeholder) => placeholder.universe,
|
CanonicalVarKind::PlaceholderRegion(placeholder) => placeholder.universe,
|
||||||
CanonicalVarKind::Const(ui) => ui,
|
CanonicalVarKind::Const(ui, _) => ui,
|
||||||
CanonicalVarKind::PlaceholderConst(placeholder) => placeholder.universe,
|
CanonicalVarKind::PlaceholderConst(placeholder) => placeholder.universe,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ crate fn evaluate_goal<'tcx>(
|
||||||
chalk_ir::VariableKind::Lifetime,
|
chalk_ir::VariableKind::Lifetime,
|
||||||
chalk_ir::UniverseIndex { counter: ui.index() },
|
chalk_ir::UniverseIndex { counter: ui.index() },
|
||||||
),
|
),
|
||||||
CanonicalVarKind::Const(_ui) => unimplemented!(),
|
CanonicalVarKind::Const(_ui, _ty) => unimplemented!(),
|
||||||
CanonicalVarKind::PlaceholderConst(_pc) => unimplemented!(),
|
CanonicalVarKind::PlaceholderConst(_pc) => unimplemented!(),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
@ -127,9 +127,9 @@ crate fn evaluate_goal<'tcx>(
|
||||||
chalk_ir::VariableKind::Lifetime => CanonicalVarKind::Region(
|
chalk_ir::VariableKind::Lifetime => CanonicalVarKind::Region(
|
||||||
ty::UniverseIndex::from_usize(var.skip_kind().counter),
|
ty::UniverseIndex::from_usize(var.skip_kind().counter),
|
||||||
),
|
),
|
||||||
chalk_ir::VariableKind::Const(_) => CanonicalVarKind::Const(
|
// FIXME(compiler-errors): We don't currently have a way of turning
|
||||||
ty::UniverseIndex::from_usize(var.skip_kind().counter),
|
// a Chalk ty back into a rustc ty, right?
|
||||||
),
|
chalk_ir::VariableKind::Const(_) => todo!(),
|
||||||
};
|
};
|
||||||
CanonicalVarInfo { kind }
|
CanonicalVarInfo { kind }
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue