Skip to content

Commit 1f5cb9e

Browse files
committed
Use a label instead of a note for the drop site to create denser diagnostics
1 parent 6984085 commit 1f5cb9e

6 files changed

+16
-45
lines changed

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

+1-10
Original file line numberDiff line numberDiff line change
@@ -2212,17 +2212,11 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
22122212
interior_span,
22132213
format!("has type `{}` which {}", target_ty, trait_explanation),
22142214
);
2215-
// If available, use the scope span to annotate the drop location.
2216-
let mut scope_note = None;
22172215
if let Some(scope_span) = scope_span {
22182216
let scope_span = source_map.end_point(scope_span);
22192217

22202218
let msg = format!("{} is later dropped here", snippet);
2221-
if source_map.is_multiline(yield_span.between(scope_span)) {
2222-
span.push_span_label(scope_span, msg);
2223-
} else {
2224-
scope_note = Some((scope_span, msg));
2225-
}
2219+
span.push_span_label(scope_span, msg);
22262220
}
22272221
err.span_note(
22282222
span,
@@ -2231,9 +2225,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
22312225
future_or_generator, trait_explanation, an_await_or_yield
22322226
),
22332227
);
2234-
if let Some((span, msg)) = scope_note {
2235-
err.span_note(span, &msg);
2236-
}
22372228
};
22382229
match interior_or_upvar_span {
22392230
GeneratorInteriorOrUpvar::Interior(interior_span, interior_extra_info) => {

src/test/ui/async-await/async-await-let-else.drop-tracking.stderr

+3-7
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,10 @@ note: future is not `Send` as this value is used across an await
6868
--> $DIR/async-await-let-else.rs:33:28
6969
|
7070
LL | (Rc::new(()), bar().await);
71-
| ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later
72-
| |
71+
| ----------- ^^^^^^ - `Rc::new(())` is later dropped here
72+
| | |
73+
| | await occurs here, with `Rc::new(())` maybe used later
7374
| has type `Rc<()>` which is not `Send`
74-
note: `Rc::new(())` is later dropped here
75-
--> $DIR/async-await-let-else.rs:33:35
76-
|
77-
LL | (Rc::new(()), bar().await);
78-
| ^
7975
note: required by a bound in `is_send`
8076
--> $DIR/async-await-let-else.rs:19:15
8177
|

src/test/ui/async-await/async-await-let-else.no-drop-tracking.stderr

+3-7
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,10 @@ note: future is not `Send` as this value is used across an await
5353
--> $DIR/async-await-let-else.rs:33:28
5454
|
5555
LL | (Rc::new(()), bar().await);
56-
| ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later
57-
| |
56+
| ----------- ^^^^^^ - `Rc::new(())` is later dropped here
57+
| | |
58+
| | await occurs here, with `Rc::new(())` maybe used later
5859
| has type `Rc<()>` which is not `Send`
59-
note: `Rc::new(())` is later dropped here
60-
--> $DIR/async-await-let-else.rs:33:35
61-
|
62-
LL | (Rc::new(()), bar().await);
63-
| ^
6460
note: required by a bound in `is_send`
6561
--> $DIR/async-await-let-else.rs:19:15
6662
|

src/test/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr

+3-7
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@ LL | baz(|| async{
1212
| _____________-
1313
LL | | foo(tx.clone());
1414
LL | | }).await;
15-
| | - ^^^^^^ await occurs here, with the value maybe used later
16-
| |_________|
15+
| | - ^^^^^^- the value is later dropped here
16+
| | | |
17+
| |_________| await occurs here, with the value maybe used later
1718
| has type `[closure@$DIR/issue-70935-complex-spans.rs:17:13: 17:15]` which is not `Send`
18-
note: the value is later dropped here
19-
--> $DIR/issue-70935-complex-spans.rs:19:17
20-
|
21-
LL | }).await;
22-
| ^
2319

2420
error: aborting due to previous error
2521

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

+3-7
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ note: future is not `Send` as this value is used across an await
1313
--> $DIR/issue-65436-raw-ptr-not-send.rs:18:35
1414
|
1515
LL | bar(Foo(std::ptr::null())).await;
16-
| ---------------- ^^^^^^ await occurs here, with `std::ptr::null()` maybe used later
17-
| |
16+
| ---------------- ^^^^^^- `std::ptr::null()` is later dropped here
17+
| | |
18+
| | await occurs here, with `std::ptr::null()` maybe used later
1819
| has type `*const u8` which is not `Send`
19-
note: `std::ptr::null()` is later dropped here
20-
--> $DIR/issue-65436-raw-ptr-not-send.rs:18:41
21-
|
22-
LL | bar(Foo(std::ptr::null())).await;
23-
| ^
2420
help: consider moving this into a `let` binding to create a shorter lived borrow
2521
--> $DIR/issue-65436-raw-ptr-not-send.rs:18:13
2622
|

src/test/ui/async-await/issues/issue-67893.stderr

+3-7
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@ note: future is not `Send` as this value is used across an await
99
--> $DIR/auxiliary/issue_67893.rs:9:26
1010
|
1111
LL | f(*x.lock().unwrap()).await;
12-
| ----------------- ^^^^^^ await occurs here, with `x.lock().unwrap()` maybe used later
13-
| |
12+
| ----------------- ^^^^^^- `x.lock().unwrap()` is later dropped here
13+
| | |
14+
| | await occurs here, with `x.lock().unwrap()` maybe used later
1415
| has type `MutexGuard<'_, ()>` which is not `Send`
15-
note: `x.lock().unwrap()` is later dropped here
16-
--> $DIR/auxiliary/issue_67893.rs:9:32
17-
|
18-
LL | f(*x.lock().unwrap()).await;
19-
| ^
2016
note: required by a bound in `g`
2117
--> $DIR/issue-67893.rs:6:14
2218
|

0 commit comments

Comments
 (0)