Overhaul Const
.
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
This commit is contained in:
parent
7eb15509ce
commit
a95fb8b150
116 changed files with 654 additions and 619 deletions
|
@ -41,7 +41,7 @@ pub fn obligations<'a, 'tcx>(
|
|||
.into()
|
||||
}
|
||||
GenericArgKind::Const(ct) => {
|
||||
match ct.val {
|
||||
match ct.val() {
|
||||
ty::ConstKind::Infer(infer) => {
|
||||
let resolved = infcx.shallow_resolve(infer);
|
||||
if resolved == infer {
|
||||
|
@ -49,7 +49,9 @@ pub fn obligations<'a, 'tcx>(
|
|||
return None;
|
||||
}
|
||||
|
||||
infcx.tcx.mk_const(ty::Const { val: ty::ConstKind::Infer(resolved), ty: ct.ty })
|
||||
infcx
|
||||
.tcx
|
||||
.mk_const(ty::ConstS { val: ty::ConstKind::Infer(resolved), ty: ct.ty() })
|
||||
}
|
||||
_ => ct,
|
||||
}
|
||||
|
@ -442,7 +444,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
GenericArgKind::Lifetime(_) => continue,
|
||||
|
||||
GenericArgKind::Const(constant) => {
|
||||
match constant.val {
|
||||
match constant.val() {
|
||||
ty::ConstKind::Unevaluated(uv) => {
|
||||
let obligations = self.nominal_obligations(uv.def.did, uv.substs);
|
||||
self.out.extend(obligations);
|
||||
|
@ -464,9 +466,9 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
if resolved != infer {
|
||||
let cause = self.cause(traits::MiscObligation);
|
||||
|
||||
let resolved_constant = self.infcx.tcx.mk_const(ty::Const {
|
||||
let resolved_constant = self.infcx.tcx.mk_const(ty::ConstS {
|
||||
val: ty::ConstKind::Infer(resolved),
|
||||
..*constant
|
||||
ty: constant.ty(),
|
||||
});
|
||||
self.out.push(traits::Obligation::with_depth(
|
||||
cause,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue