Simplify IntVarValue/FloatVarValue
This commit is contained in:
parent
acaf0aeed0
commit
0a83764cbd
9 changed files with 145 additions and 172 deletions
|
@ -86,21 +86,6 @@ impl<'tcx> UnifyValue for RegionVariableValue<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToType for ty::IntVarValue {
|
||||
fn to_type<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
match *self {
|
||||
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> {
|
||||
Ty::new_float(tcx, self.0)
|
||||
}
|
||||
}
|
||||
|
||||
// Generic consts.
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
@ -211,6 +196,7 @@ impl<'tcx> EffectVarValue<'tcx> {
|
|||
|
||||
impl<'tcx> UnifyValue for EffectVarValue<'tcx> {
|
||||
type Error = NoError;
|
||||
|
||||
fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
|
||||
match (*value1, *value2) {
|
||||
(EffectVarValue::Unknown, EffectVarValue::Unknown) => Ok(EffectVarValue::Unknown),
|
||||
|
|
|
@ -49,8 +49,6 @@ pub enum TypeError<'tcx> {
|
|||
|
||||
Sorts(ExpectedFound<Ty<'tcx>>),
|
||||
ArgumentSorts(ExpectedFound<Ty<'tcx>>, usize),
|
||||
IntMismatch(ExpectedFound<ty::IntVarValue>),
|
||||
FloatMismatch(ExpectedFound<ty::FloatTy>),
|
||||
Traits(ExpectedFound<DefId>),
|
||||
VariadicMismatch(ExpectedFound<bool>),
|
||||
|
||||
|
@ -155,23 +153,6 @@ impl<'tcx> TypeError<'tcx> {
|
|||
report_maybe_different(&format!("trait `{expected}`"), &format!("trait `{found}`"))
|
||||
.into()
|
||||
}
|
||||
IntMismatch(ref values) => {
|
||||
let expected = match values.expected {
|
||||
ty::IntVarValue::IntType(ty) => ty.name_str(),
|
||||
ty::IntVarValue::UintType(ty) => ty.name_str(),
|
||||
};
|
||||
let found = match values.found {
|
||||
ty::IntVarValue::IntType(ty) => ty.name_str(),
|
||||
ty::IntVarValue::UintType(ty) => ty.name_str(),
|
||||
};
|
||||
format!("expected `{expected}`, found `{found}`").into()
|
||||
}
|
||||
FloatMismatch(ref values) => format!(
|
||||
"expected `{}`, found `{}`",
|
||||
values.expected.name_str(),
|
||||
values.found.name_str()
|
||||
)
|
||||
.into(),
|
||||
VariadicMismatch(ref values) => format!(
|
||||
"expected {} fn, found {} function",
|
||||
if values.expected { "variadic" } else { "non-variadic" },
|
||||
|
@ -206,8 +187,7 @@ impl<'tcx> TypeError<'tcx> {
|
|||
match self {
|
||||
CyclicTy(_) | CyclicConst(_) | SafetyMismatch(_) | ConstnessMismatch(_)
|
||||
| PolarityMismatch(_) | Mismatch | AbiMismatch(_) | FixedArraySize(_)
|
||||
| ArgumentSorts(..) | Sorts(_) | IntMismatch(_) | FloatMismatch(_)
|
||||
| VariadicMismatch(_) | TargetFeatureCast(_) => false,
|
||||
| ArgumentSorts(..) | Sorts(_) | VariadicMismatch(_) | TargetFeatureCast(_) => false,
|
||||
|
||||
Mutability
|
||||
| ArgumentMutability(_)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue