Rollup merge of #67011 - Aaron1011:fix/expected-found-span, r=Dylan-DPC
Include a span in more `expected...found` notes In most places, we use a span when emitting `expected...found` errors. However, there were a couple of places where we didn't use any span, resulting in hard-to-interpret error messages. This commit attaches the relevant span to these notes, and additionally switches over to using `note_expected_found` instead of manually formatting the message
This commit is contained in:
commit
7945dcdfdc
33 changed files with 325 additions and 134 deletions
|
|
@ -1809,12 +1809,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
sub_region,
|
||||
"...",
|
||||
);
|
||||
err.note(&format!(
|
||||
"...so that the {}:\nexpected {}\n found {}",
|
||||
sup_trace.cause.as_requirement_str(),
|
||||
sup_expected.content(),
|
||||
sup_found.content()
|
||||
err.span_note(sup_trace.cause.span, &format!(
|
||||
"...so that the {}",
|
||||
sup_trace.cause.as_requirement_str()
|
||||
));
|
||||
|
||||
err.note_expected_found(
|
||||
&"",
|
||||
sup_expected,
|
||||
&"",
|
||||
sup_found
|
||||
);
|
||||
err.emit();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
match *origin {
|
||||
infer::Subtype(ref trace) => {
|
||||
if let Some((expected, found)) = self.values_str(&trace.values) {
|
||||
let expected = expected.content();
|
||||
let found = found.content();
|
||||
err.note(&format!("...so that the {}:\nexpected {}\n found {}",
|
||||
trace.cause.as_requirement_str(),
|
||||
expected,
|
||||
found));
|
||||
err.span_note(
|
||||
trace.cause.span,
|
||||
&format!(
|
||||
"...so that the {}",
|
||||
trace.cause.as_requirement_str()
|
||||
)
|
||||
);
|
||||
|
||||
err.note_expected_found(
|
||||
&"",
|
||||
expected,
|
||||
&"",
|
||||
found
|
||||
);
|
||||
} else {
|
||||
// FIXME: this really should be handled at some earlier stage. Our
|
||||
// handling of region checking when type errors are present is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue