mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-14 16:03:17 +00:00
Use a label instead of a note for the drop site to create denser diagnostics
This commit is contained in:
parent
6984085088
commit
1f5cb9e50e
@ -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,
|
||||
@ -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) => {
|
||||
|
@ -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
|
||||
|
|
||||
|
@ -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
|
||||
|
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
|
||||
|
@ -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
|
||||
|
|
||||
|
Loading…
Reference in New Issue
Block a user