Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4177,7 +4177,9 @@ pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String {
if expected_str == found_str {
format!("expected {}, found a different {}", expected_str, found_str)
} else {
format!("expected {}, found {}", expected_str, found_str)
format!("expected `{}`,\n found `{}`", expected_str, found_str)
// `expected` will be preceded by either a space or a `(` so the following
// line needs 4 spaces to align both `{}` sets: issue 18946
}
}
terr_traits(values) => {
Expand Down
7 changes: 5 additions & 2 deletions src/librustc/middle/typeck/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {

self.tcx.sess.span_err(
trace.origin.span(),
format!("{}: {} ({})",
format!("{}:\n {}\n({})",
// ^ Space to align both sets of `{}`: issue 18946
message_root_str,
expected_found_str,
ty::type_err_to_str(self.tcx, terr)).as_slice());
Expand Down Expand Up @@ -417,7 +418,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
return None;
}

Some(format!("expected `{}`, found `{}`",
Some(format!("expected `{}`,\n found `{}`",
// `expected` will be preceded by either a space or a `(` so the
// following line needs 4 spaces to align both `{}` sets: issue 18946
expected.user_string(self.tcx),
found.user_string(self.tcx)))
}
Expand Down