}
}
+impl<'tcx> Relate<'tcx> for ty::BoundConstness {
+ fn relate<R: TypeRelation<'tcx>>(
+ relation: &mut R,
+ a: ty::BoundConstness,
+ b: ty::BoundConstness,
+ ) -> RelateResult<'tcx, ty::BoundConstness> {
+ if a != b {
+ Err(TypeError::ConstnessMismatch(expected_found(relation, a, b)))
+ } else {
+ Ok(a)
+ }
+ }
+}
+
+impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for ty::ConstnessAnd<T> {
+ fn relate<R: TypeRelation<'tcx>>(
+ relation: &mut R,
+ a: ty::ConstnessAnd<T>,
+ b: ty::ConstnessAnd<T>,
+ ) -> RelateResult<'tcx, ty::ConstnessAnd<T>> {
+ Ok(ty::ConstnessAnd {
+ constness: relation.relate(a.constness, b.constness)?,
+ value: relation.relate(a.value, b.value)?,
+ })
+ }
+}
+
impl<'tcx> Relate<'tcx> for ast::Unsafety {
fn relate<R: TypeRelation<'tcx>>(
relation: &mut R,
}
(ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu))
- if tcx.features().const_evaluatable_checked =>
+ if tcx.features().generic_const_exprs =>
{
- tcx.try_unify_abstract_consts(((au.def, au.substs), (bu.def, bu.substs)))
+ tcx.try_unify_abstract_consts((au.shrink(), bu.shrink()))
}
// While this is slightly incorrect, it shouldn't matter for `min_const_generics`
- // and is the better alternative to waiting until `const_evaluatable_checked` can
+ // and is the better alternative to waiting until `generic_const_exprs` can
// be stabilized.
(ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu))
if au.def == bu.def && au.promoted == bu.promoted =>
let substs = relation.relate_with_variance(
ty::Variance::Invariant,
ty::VarianceDiagInfo::default(),
- au.substs,
- bu.substs,
+ au.substs(tcx),
+ bu.substs(tcx),
)?;
return Ok(tcx.mk_const(ty::Const {
val: ty::ConstKind::Unevaluated(ty::Unevaluated {
def: au.def,
- substs,
+ substs_: Some(substs),
promoted: au.promoted,
}),
ty: a.ty,
get_slice_bytes(&tcx, a_val) == get_slice_bytes(&tcx, b_val)
}
+ (ConstValue::ByRef { alloc: alloc_a, .. }, ConstValue::ByRef { alloc: alloc_b, .. })
+ if a.ty.is_ref() || b.ty.is_ref() =>
+ {
+ if a.ty.is_ref() && b.ty.is_ref() {
+ alloc_a == alloc_b
+ } else {
+ false
+ }
+ }
(ConstValue::ByRef { .. }, ConstValue::ByRef { .. }) => {
let a_destructured = tcx.destructure_const(relation.param_env().and(a));
let b_destructured = tcx.destructure_const(relation.param_env().and(b));
}
}
+impl<'tcx> Relate<'tcx> for ty::ImplPolarity {
+ fn relate<R: TypeRelation<'tcx>>(
+ relation: &mut R,
+ a: ty::ImplPolarity,
+ b: ty::ImplPolarity,
+ ) -> RelateResult<'tcx, ty::ImplPolarity> {
+ if a != b {
+ Err(TypeError::PolarityMismatch(expected_found(relation, a, b)))
+ } else {
+ Ok(a)
+ }
+ }
+}
+
impl<'tcx> Relate<'tcx> for ty::TraitPredicate<'tcx> {
fn relate<R: TypeRelation<'tcx>>(
relation: &mut R,
a: ty::TraitPredicate<'tcx>,
b: ty::TraitPredicate<'tcx>,
) -> RelateResult<'tcx, ty::TraitPredicate<'tcx>> {
- Ok(ty::TraitPredicate { trait_ref: relation.relate(a.trait_ref, b.trait_ref)? })
+ Ok(ty::TraitPredicate {
+ trait_ref: relation.relate(a.trait_ref, b.trait_ref)?,
+ constness: relation.relate(a.constness, b.constness)?,
+ polarity: relation.relate(a.polarity, b.polarity)?,
+ })
}
}