Only separate notes if span is multiline

This commit is contained in:
Yuki Okushi 2020-11-02 16:54:53 +09:00
parent 2da86a1bfd
commit 54d9ffc0b9
2 changed files with 17 additions and 11 deletions

View File

@ -1629,11 +1629,20 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
future_or_generator, trait_explanation, an_await_or_yield
),
);
err.span_note(scope_span, &format!("{} is later dropped here", snippet));
err.span_note(
interior_span,
&format!("this has type `{}` which {}", target_ty, trait_explanation),
);
if source_map.is_multiline(interior_span) {
err.span_note(scope_span, &format!("{} is later dropped here", snippet));
err.span_note(
interior_span,
&format!("this has type `{}` which {}", target_ty, trait_explanation),
);
} else {
let mut span = MultiSpan::from_span(scope_span);
span.push_span_label(
interior_span,
format!("has type `{}` which {}", target_ty, trait_explanation),
);
err.span_note(span, &format!("{} is later dropped here", snippet));
}
} else {
span.push_span_label(
yield_span,

View File

@ -17,12 +17,9 @@ note: `std::ptr::null()` is later dropped here
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:41
|
LL | bar(Foo(std::ptr::null())).await;
| ^
note: this has type `*const u8` which is not `Send`
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:17
|
LL | bar(Foo(std::ptr::null())).await;
| ^^^^^^^^^^^^^^^^
| ---------------- ^
| |
| has type `*const u8` which is not `Send`
help: consider moving this into a `let` binding to create a shorter lived borrow
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:13
|