Skip to content

Commit

Permalink
Use a label instead of a note for the drop site to create denser diag…
Browse files Browse the repository at this point in the history
…nostics
  • Loading branch information
oli-obk committed Dec 13, 2022
1 parent 6984085 commit 1f5cb9e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2212,17 +2212,11 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
interior_span,
format!("has type `{}` which {}", target_ty, trait_explanation),
);
// If available, use the scope span to annotate the drop location.
let mut scope_note = None;
if let Some(scope_span) = scope_span {
let scope_span = source_map.end_point(scope_span);

let msg = format!("{} is later dropped here", snippet);
if source_map.is_multiline(yield_span.between(scope_span)) {
span.push_span_label(scope_span, msg);
} else {
scope_note = Some((scope_span, msg));
}
span.push_span_label(scope_span, msg);
}
err.span_note(
span,
Expand All @@ -2231,9 +2225,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
future_or_generator, trait_explanation, an_await_or_yield
),
);
if let Some((span, msg)) = scope_note {
err.span_note(span, &msg);
}
};
match interior_or_upvar_span {
GeneratorInteriorOrUpvar::Interior(interior_span, interior_extra_info) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,10 @@ note: future is not `Send` as this value is used across an await
--> $DIR/async-await-let-else.rs:33:28
|
LL | (Rc::new(()), bar().await);
| ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later
| |
| ----------- ^^^^^^ - `Rc::new(())` is later dropped here
| | |
| | await occurs here, with `Rc::new(())` maybe used later
| has type `Rc<()>` which is not `Send`
note: `Rc::new(())` is later dropped here
--> $DIR/async-await-let-else.rs:33:35
|
LL | (Rc::new(()), bar().await);
| ^
note: required by a bound in `is_send`
--> $DIR/async-await-let-else.rs:19:15
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,10 @@ note: future is not `Send` as this value is used across an await
--> $DIR/async-await-let-else.rs:33:28
|
LL | (Rc::new(()), bar().await);
| ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later
| |
| ----------- ^^^^^^ - `Rc::new(())` is later dropped here
| | |
| | await occurs here, with `Rc::new(())` maybe used later
| has type `Rc<()>` which is not `Send`
note: `Rc::new(())` is later dropped here
--> $DIR/async-await-let-else.rs:33:35
|
LL | (Rc::new(()), bar().await);
| ^
note: required by a bound in `is_send`
--> $DIR/async-await-let-else.rs:19:15
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ LL | baz(|| async{
| _____________-
LL | | foo(tx.clone());
LL | | }).await;
| | - ^^^^^^ await occurs here, with the value maybe used later
| |_________|
| | - ^^^^^^- the value is later dropped here
| | | |
| |_________| await occurs here, with the value maybe used later
| has type `[closure@$DIR/issue-70935-complex-spans.rs:17:13: 17:15]` which is not `Send`
note: the value is later dropped here
--> $DIR/issue-70935-complex-spans.rs:19:17
|
LL | }).await;
| ^

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ note: future is not `Send` as this value is used across an await
--> $DIR/issue-65436-raw-ptr-not-send.rs:18:35
|
LL | bar(Foo(std::ptr::null())).await;
| ---------------- ^^^^^^ await occurs here, with `std::ptr::null()` maybe used later
| |
| ---------------- ^^^^^^- `std::ptr::null()` is later dropped here
| | |
| | await occurs here, with `std::ptr::null()` maybe used later
| has type `*const u8` which is not `Send`
note: `std::ptr::null()` is later dropped here
--> $DIR/issue-65436-raw-ptr-not-send.rs:18:41
|
LL | bar(Foo(std::ptr::null())).await;
| ^
help: consider moving this into a `let` binding to create a shorter lived borrow
--> $DIR/issue-65436-raw-ptr-not-send.rs:18:13
|
Expand Down
10 changes: 3 additions & 7 deletions src/test/ui/async-await/issues/issue-67893.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ note: future is not `Send` as this value is used across an await
--> $DIR/auxiliary/issue_67893.rs:9:26
|
LL | f(*x.lock().unwrap()).await;
| ----------------- ^^^^^^ await occurs here, with `x.lock().unwrap()` maybe used later
| |
| ----------------- ^^^^^^- `x.lock().unwrap()` is later dropped here
| | |
| | await occurs here, with `x.lock().unwrap()` maybe used later
| has type `MutexGuard<'_, ()>` which is not `Send`
note: `x.lock().unwrap()` is later dropped here
--> $DIR/auxiliary/issue_67893.rs:9:32
|
LL | f(*x.lock().unwrap()).await;
| ^
note: required by a bound in `g`
--> $DIR/issue-67893.rs:6:14
|
Expand Down

0 comments on commit 1f5cb9e

Please sign in to comment.