summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/infer
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /compiler/rustc_middle/src/infer
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_middle/src/infer')
-rw-r--r--compiler/rustc_middle/src/infer/canonical.rs59
-rw-r--r--compiler/rustc_middle/src/infer/unify_key.rs7
2 files changed, 46 insertions, 20 deletions
diff --git a/compiler/rustc_middle/src/infer/canonical.rs b/compiler/rustc_middle/src/infer/canonical.rs
index 561713149..d5e8330b3 100644
--- a/compiler/rustc_middle/src/infer/canonical.rs
+++ b/compiler/rustc_middle/src/infer/canonical.rs
@@ -82,15 +82,40 @@ impl CanonicalVarValues<'_> {
}
pub fn is_identity_modulo_regions(&self) -> bool {
- self.var_values.iter().enumerate().all(|(bv, arg)| match arg.unpack() {
- ty::GenericArgKind::Lifetime(_) => true,
- ty::GenericArgKind::Type(ty) => {
- matches!(*ty.kind(), ty::Bound(ty::INNERMOST, bt) if bt.var.as_usize() == bv)
- }
- ty::GenericArgKind::Const(ct) => {
- matches!(ct.kind(), ty::ConstKind::Bound(ty::INNERMOST, bc) if bc.as_usize() == bv)
+ let mut var = ty::BoundVar::from_u32(0);
+ for arg in self.var_values {
+ match arg.unpack() {
+ ty::GenericArgKind::Lifetime(r) => {
+ if let ty::ReLateBound(ty::INNERMOST, br) = *r
+ && var == br.var
+ {
+ var = var + 1;
+ } else {
+ // It's ok if this region var isn't unique
+ }
+ },
+ ty::GenericArgKind::Type(ty) => {
+ if let ty::Bound(ty::INNERMOST, bt) = *ty.kind()
+ && var == bt.var
+ {
+ var = var + 1;
+ } else {
+ return false;
+ }
+ }
+ ty::GenericArgKind::Const(ct) => {
+ if let ty::ConstKind::Bound(ty::INNERMOST, bc) = ct.kind()
+ && var == bc
+ {
+ var = var + 1;
+ } else {
+ return false;
+ }
+ }
}
- })
+ }
+
+ true
}
}
@@ -408,22 +433,24 @@ impl<'tcx> CanonicalVarValues<'tcx> {
|(i, info)| -> ty::GenericArg<'tcx> {
match info.kind {
CanonicalVarKind::Ty(_) | CanonicalVarKind::PlaceholderTy(_) => {
- tcx.mk_bound(ty::INNERMOST, ty::BoundVar::from_usize(i).into()).into()
+ Ty::new_bound(tcx, ty::INNERMOST, ty::BoundVar::from_usize(i).into())
+ .into()
}
CanonicalVarKind::Region(_) | CanonicalVarKind::PlaceholderRegion(_) => {
let br = ty::BoundRegion {
var: ty::BoundVar::from_usize(i),
kind: ty::BrAnon(None),
};
- tcx.mk_re_late_bound(ty::INNERMOST, br).into()
+ ty::Region::new_late_bound(tcx, ty::INNERMOST, br).into()
}
CanonicalVarKind::Const(_, ty)
- | CanonicalVarKind::PlaceholderConst(_, ty) => tcx
- .mk_const(
- ty::ConstKind::Bound(ty::INNERMOST, ty::BoundVar::from_usize(i)),
- ty,
- )
- .into(),
+ | CanonicalVarKind::PlaceholderConst(_, ty) => ty::Const::new_bound(
+ tcx,
+ ty::INNERMOST,
+ ty::BoundVar::from_usize(i),
+ ty,
+ )
+ .into(),
}
},
)),
diff --git a/compiler/rustc_middle/src/infer/unify_key.rs b/compiler/rustc_middle/src/infer/unify_key.rs
index a873854f0..85fb9214d 100644
--- a/compiler/rustc_middle/src/infer/unify_key.rs
+++ b/compiler/rustc_middle/src/infer/unify_key.rs
@@ -90,15 +90,15 @@ impl<'tcx> UnifyValue for UnifiedRegion<'tcx> {
impl ToType for ty::IntVarValue {
fn to_type<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
match *self {
- ty::IntType(i) => tcx.mk_mach_int(i),
- ty::UintType(i) => tcx.mk_mach_uint(i),
+ ty::IntType(i) => Ty::new_int(tcx, i),
+ ty::UintType(i) => Ty::new_uint(tcx, i),
}
}
}
impl ToType for ty::FloatVarValue {
fn to_type<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
- tcx.mk_mach_float(self.0)
+ Ty::new_float(tcx, self.0)
}
}
@@ -116,7 +116,6 @@ pub enum ConstVariableOriginKind {
MiscVariable,
ConstInference,
ConstParameterDefinition(Symbol, DefId),
- SubstitutionPlaceholder,
}
#[derive(Copy, Clone, Debug)]