Skip to content

Commit b93c9a7

Browse files
authored
Rollup merge of #102128 - oli-obk:const_unification, r=lcnr
Const unification is already infallible, remove the error handling logic r? `@lcnr` is this expected to be used in the future? Right now it is dead code.
2 parents c5d2230 + 13438ee commit b93c9a7

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

compiler/rustc_infer/src/infer/combine.rs

+11-26
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
147147
ty::ConstKind::Infer(InferConst::Var(a_vid)),
148148
ty::ConstKind::Infer(InferConst::Var(b_vid)),
149149
) => {
150-
self.inner
151-
.borrow_mut()
152-
.const_unification_table()
153-
.unify_var_var(a_vid, b_vid)
154-
.map_err(|e| const_unification_error(a_is_expected, e))?;
150+
self.inner.borrow_mut().const_unification_table().union(a_vid, b_vid);
155151
return Ok(a);
156152
}
157153

@@ -246,21 +242,17 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
246242
let value = ConstInferUnifier { infcx: self, span, param_env, for_universe, target_vid }
247243
.relate(ct, ct)?;
248244

249-
self.inner
250-
.borrow_mut()
251-
.const_unification_table()
252-
.unify_var_value(
253-
target_vid,
254-
ConstVarValue {
255-
origin: ConstVariableOrigin {
256-
kind: ConstVariableOriginKind::ConstInference,
257-
span: DUMMY_SP,
258-
},
259-
val: ConstVariableValue::Known { value },
245+
self.inner.borrow_mut().const_unification_table().union_value(
246+
target_vid,
247+
ConstVarValue {
248+
origin: ConstVariableOrigin {
249+
kind: ConstVariableOriginKind::ConstInference,
250+
span: DUMMY_SP,
260251
},
261-
)
262-
.map(|()| value)
263-
.map_err(|e| const_unification_error(vid_is_expected, e))
252+
val: ConstVariableValue::Known { value },
253+
},
254+
);
255+
Ok(value)
264256
}
265257

266258
fn unify_integral_variable(
@@ -768,13 +760,6 @@ pub trait ConstEquateRelation<'tcx>: TypeRelation<'tcx> {
768760
fn const_equate_obligation(&mut self, a: ty::Const<'tcx>, b: ty::Const<'tcx>);
769761
}
770762

771-
pub fn const_unification_error<'tcx>(
772-
a_is_expected: bool,
773-
(a, b): (ty::Const<'tcx>, ty::Const<'tcx>),
774-
) -> TypeError<'tcx> {
775-
TypeError::ConstMismatch(ExpectedFound::new(a_is_expected, a, b))
776-
}
777-
778763
fn int_unification_error<'tcx>(
779764
a_is_expected: bool,
780765
v: (ty::IntVarValue, ty::IntVarValue),

compiler/rustc_middle/src/infer/unify_key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'tcx> UnifyKey for ty::ConstVid<'tcx> {
129129
}
130130

131131
impl<'tcx> UnifyValue for ConstVarValue<'tcx> {
132-
type Error = (ty::Const<'tcx>, ty::Const<'tcx>);
132+
type Error = NoError;
133133

134134
fn unify_values(&value1: &Self, &value2: &Self) -> Result<Self, Self::Error> {
135135
Ok(match (value1.val, value2.val) {

0 commit comments

Comments
 (0)