1
Fork 0

Use .name_str() to format primitive types in error messages

This commit is contained in:
Fabian Wolff 2021-05-11 18:12:36 +02:00
parent 506e75cbf8
commit f740923b8c
3 changed files with 63 additions and 2 deletions

View file

@ -159,10 +159,23 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
)
}),
IntMismatch(ref values) => {
write!(f, "expected `{:?}`, found `{:?}`", values.expected, values.found)
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(),
};
write!(f, "expected `{}`, found `{}`", expected, found)
}
FloatMismatch(ref values) => {
write!(f, "expected `{:?}`, found `{:?}`", values.expected, values.found)
write!(
f,
"expected `{}`, found `{}`",
values.expected.name_str(),
values.found.name_str()
)
}
VariadicMismatch(ref values) => write!(
f,