parent
b22c152958
commit
f1ffe823cf
7 changed files with 123 additions and 16 deletions
|
@ -1724,7 +1724,19 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
.and_then(|(predicate, _, normalized_term, expected_term)| {
|
||||
self.maybe_detailed_projection_msg(predicate, normalized_term, expected_term)
|
||||
})
|
||||
.unwrap_or_else(|| format!("type mismatch resolving `{}`", predicate));
|
||||
.unwrap_or_else(|| {
|
||||
with_forced_trimmed_paths!(format!(
|
||||
"type mismatch resolving `{}`",
|
||||
self.resolve_vars_if_possible(predicate)
|
||||
.print(FmtPrinter::new_with_limit(
|
||||
self.tcx,
|
||||
Namespace::TypeNS,
|
||||
rustc_session::Limit(10),
|
||||
))
|
||||
.unwrap()
|
||||
.into_buffer()
|
||||
))
|
||||
});
|
||||
let mut diag = struct_span_err!(self.tcx.sess, obligation.cause.span, E0271, "{msg}");
|
||||
|
||||
let secondary_span = match predicate.kind().skip_binder() {
|
||||
|
@ -1755,7 +1767,20 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
kind: hir::ImplItemKind::Type(ty),
|
||||
..
|
||||
}),
|
||||
) => Some((ty.span, format!("type mismatch resolving `{}`", predicate))),
|
||||
) => Some((
|
||||
ty.span,
|
||||
with_forced_trimmed_paths!(format!(
|
||||
"type mismatch resolving `{}`",
|
||||
self.resolve_vars_if_possible(predicate)
|
||||
.print(FmtPrinter::new_with_limit(
|
||||
self.tcx,
|
||||
Namespace::TypeNS,
|
||||
rustc_session::Limit(5),
|
||||
))
|
||||
.unwrap()
|
||||
.into_buffer()
|
||||
)),
|
||||
)),
|
||||
_ => None,
|
||||
}),
|
||||
_ => None,
|
||||
|
|
|
@ -2622,11 +2622,25 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
ObligationCauseCode::ObjectCastObligation(concrete_ty, object_ty) => {
|
||||
err.note(&format!(
|
||||
"required for the cast from `{}` to the object type `{}`",
|
||||
self.ty_to_string(concrete_ty),
|
||||
self.ty_to_string(object_ty)
|
||||
));
|
||||
let (concrete_ty, concrete_file) =
|
||||
self.tcx.short_ty_string(self.resolve_vars_if_possible(concrete_ty));
|
||||
let (object_ty, object_file) =
|
||||
self.tcx.short_ty_string(self.resolve_vars_if_possible(object_ty));
|
||||
err.note(&with_forced_trimmed_paths!(format!(
|
||||
"required for the cast from `{concrete_ty}` to the object type `{object_ty}`",
|
||||
)));
|
||||
if let Some(file) = concrete_file {
|
||||
err.note(&format!(
|
||||
"the full name for the casted type has been written to '{}'",
|
||||
file.display(),
|
||||
));
|
||||
}
|
||||
if let Some(file) = object_file {
|
||||
err.note(&format!(
|
||||
"the full name for the object type has been written to '{}'",
|
||||
file.display(),
|
||||
));
|
||||
}
|
||||
}
|
||||
ObligationCauseCode::Coercion { source: _, target } => {
|
||||
err.note(&format!("required by cast to type `{}`", self.ty_to_string(target)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue