Skip to content

Commit 54d9ffc

Browse files
committed
Only separate notes if span is multiline
1 parent 2da86a1 commit 54d9ffc

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -1629,11 +1629,20 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
16291629
future_or_generator, trait_explanation, an_await_or_yield
16301630
),
16311631
);
1632-
err.span_note(scope_span, &format!("{} is later dropped here", snippet));
1633-
err.span_note(
1634-
interior_span,
1635-
&format!("this has type `{}` which {}", target_ty, trait_explanation),
1636-
);
1632+
if source_map.is_multiline(interior_span) {
1633+
err.span_note(scope_span, &format!("{} is later dropped here", snippet));
1634+
err.span_note(
1635+
interior_span,
1636+
&format!("this has type `{}` which {}", target_ty, trait_explanation),
1637+
);
1638+
} else {
1639+
let mut span = MultiSpan::from_span(scope_span);
1640+
span.push_span_label(
1641+
interior_span,
1642+
format!("has type `{}` which {}", target_ty, trait_explanation),
1643+
);
1644+
err.span_note(span, &format!("{} is later dropped here", snippet));
1645+
}
16371646
} else {
16381647
span.push_span_label(
16391648
yield_span,

src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr

+3-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ note: `std::ptr::null()` is later dropped here
1717
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:41
1818
|
1919
LL | bar(Foo(std::ptr::null())).await;
20-
| ^
21-
note: this has type `*const u8` which is not `Send`
22-
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:17
23-
|
24-
LL | bar(Foo(std::ptr::null())).await;
25-
| ^^^^^^^^^^^^^^^^
20+
| ---------------- ^
21+
| |
22+
| has type `*const u8` which is not `Send`
2623
help: consider moving this into a `let` binding to create a shorter lived borrow
2724
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:13
2825
|

0 commit comments

Comments
 (0)