diff options
Diffstat (limited to '')
-rw-r--r-- | compiler/rustc_infer/src/infer/combine.rs | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs index c406df9e4..b5427f639 100644 --- a/compiler/rustc_infer/src/infer/combine.rs +++ b/compiler/rustc_infer/src/infer/combine.rs @@ -43,7 +43,7 @@ use rustc_span::{Span, DUMMY_SP}; #[derive(Clone)] pub struct CombineFields<'infcx, 'tcx> { - pub infcx: &'infcx InferCtxt<'infcx, 'tcx>, + pub infcx: &'infcx InferCtxt<'tcx>, pub trace: TypeTrace<'tcx>, pub cause: Option<ty::relate::Cause>, pub param_env: ty::ParamEnv<'tcx>, @@ -63,7 +63,7 @@ pub enum RelationDir { EqTo, } -impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> { +impl<'tcx> InferCtxt<'tcx> { pub fn super_combine_tys<R>( &self, relation: &mut R, @@ -147,11 +147,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> { ty::ConstKind::Infer(InferConst::Var(a_vid)), ty::ConstKind::Infer(InferConst::Var(b_vid)), ) => { - self.inner - .borrow_mut() - .const_unification_table() - .unify_var_var(a_vid, b_vid) - .map_err(|e| const_unification_error(a_is_expected, e))?; + self.inner.borrow_mut().const_unification_table().union(a_vid, b_vid); return Ok(a); } @@ -246,21 +242,17 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> { let value = ConstInferUnifier { infcx: self, span, param_env, for_universe, target_vid } .relate(ct, ct)?; - self.inner - .borrow_mut() - .const_unification_table() - .unify_var_value( - target_vid, - ConstVarValue { - origin: ConstVariableOrigin { - kind: ConstVariableOriginKind::ConstInference, - span: DUMMY_SP, - }, - val: ConstVariableValue::Known { value }, + self.inner.borrow_mut().const_unification_table().union_value( + target_vid, + ConstVarValue { + origin: ConstVariableOrigin { + kind: ConstVariableOriginKind::ConstInference, + span: DUMMY_SP, }, - ) - .map(|()| value) - .map_err(|e| const_unification_error(vid_is_expected, e)) + val: ConstVariableValue::Known { value }, + }, + ); + Ok(value) } fn unify_integral_variable( @@ -460,7 +452,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> { } struct Generalizer<'cx, 'tcx> { - infcx: &'cx InferCtxt<'cx, 'tcx>, + infcx: &'cx InferCtxt<'tcx>, /// The span, used when creating new type variables and things. cause: &'cx ObligationCause<'tcx>, @@ -742,9 +734,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> { } } } - ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }) => { - assert_eq!(promoted, ()); - + ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }) => { let substs = self.relate_with_variance( ty::Variance::Invariant, ty::VarianceDiagInfo::default(), @@ -753,7 +743,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> { )?; Ok(self.tcx().mk_const(ty::ConstS { ty: c.ty(), - kind: ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }), + kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }), })) } _ => relate::super_relate_consts(self, c, c), @@ -768,13 +758,6 @@ pub trait ConstEquateRelation<'tcx>: TypeRelation<'tcx> { fn const_equate_obligation(&mut self, a: ty::Const<'tcx>, b: ty::Const<'tcx>); } -pub fn const_unification_error<'tcx>( - a_is_expected: bool, - (a, b): (ty::Const<'tcx>, ty::Const<'tcx>), -) -> TypeError<'tcx> { - TypeError::ConstMismatch(ExpectedFound::new(a_is_expected, a, b)) -} - fn int_unification_error<'tcx>( a_is_expected: bool, v: (ty::IntVarValue, ty::IntVarValue), @@ -792,7 +775,7 @@ fn float_unification_error<'tcx>( } struct ConstInferUnifier<'cx, 'tcx> { - infcx: &'cx InferCtxt<'cx, 'tcx>, + infcx: &'cx InferCtxt<'tcx>, span: Span, @@ -964,9 +947,7 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> { } } } - ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }) => { - assert_eq!(promoted, ()); - + ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }) => { let substs = self.relate_with_variance( ty::Variance::Invariant, ty::VarianceDiagInfo::default(), @@ -976,7 +957,7 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> { Ok(self.tcx().mk_const(ty::ConstS { ty: c.ty(), - kind: ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }), + kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }), })) } _ => relate::super_relate_consts(self, c, c), |