Fix some unwanted uses of Debug formatting on user-facing messages

While formatting for user diagnostics used `Display` for all most cases,
some small amount of cases used `Debug` instead.  Until now, `Display`
and `Debug` yielded the same output for many types. However, with path
trimming, we want to show a shorter path for the user, these cases need
fixing.
This commit is contained in:
Dan Aloni 2020-08-28 13:38:43 +03:00
parent e36e4bd0f7
commit 75a042e74b
7 changed files with 19 additions and 18 deletions

View file

@ -260,10 +260,11 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
InstanceDef::ReifyShim(_) => write!(f, " - shim(reify)"),
InstanceDef::Intrinsic(_) => write!(f, " - intrinsic"),
InstanceDef::Virtual(_, num) => write!(f, " - virtual#{}", num),
InstanceDef::FnPtrShim(_, ty) => write!(f, " - shim({:?})", ty),
InstanceDef::FnPtrShim(_, ty) => write!(f, " - shim({})", ty),
InstanceDef::ClosureOnceShim { .. } => write!(f, " - shim"),
InstanceDef::DropGlue(_, ty) => write!(f, " - shim({:?})", ty),
InstanceDef::CloneShim(_, ty) => write!(f, " - shim({:?})", ty),
InstanceDef::DropGlue(_, None) => write!(f, " - shim(None)"),
InstanceDef::DropGlue(_, Some(ty)) => write!(f, " - shim(Some({}))", ty),
InstanceDef::CloneShim(_, ty) => write!(f, " - shim({})", ty),
}
}
}

View file

@ -174,9 +174,9 @@ pub enum LayoutError<'tcx> {
impl<'tcx> fmt::Display for LayoutError<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
LayoutError::Unknown(ty) => write!(f, "the type `{:?}` has an unknown layout", ty),
LayoutError::Unknown(ty) => write!(f, "the type `{}` has an unknown layout", ty),
LayoutError::SizeOverflow(ty) => {
write!(f, "the type `{:?}` is too big for the current architecture", ty)
write!(f, "the type `{}` is too big for the current architecture", ty)
}
}
}