review comments
This commit is contained in:
parent
d59f74aeaf
commit
64dea33a3d
5 changed files with 37 additions and 17 deletions
|
@ -1735,16 +1735,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
// | |
|
// | |
|
||||||
// LL | | foo(tx.clone());
|
// LL | | foo(tx.clone());
|
||||||
// LL | | }).await;
|
// LL | | }).await;
|
||||||
// | | - ^^^^^^- value is later dropped here
|
// | | - ^^^^^^ await occurs here, with value maybe used later
|
||||||
// | | | |
|
// | |__________|
|
||||||
// | |__________| await occurs here, with value maybe used later
|
|
||||||
// | has type `closure` which is not `Send`
|
// | has type `closure` which is not `Send`
|
||||||
|
// note: value is later dropped here
|
||||||
|
// LL | | }).await;
|
||||||
|
// | | ^
|
||||||
//
|
//
|
||||||
// If available, use the scope span to annotate the drop location.
|
|
||||||
if let Some(scope_span) = scope_span {
|
|
||||||
let scope_span = source_map.end_point(scope_span);
|
|
||||||
span.push_span_label(scope_span, format!("{} is later dropped here", snippet));
|
|
||||||
}
|
|
||||||
span.push_span_label(
|
span.push_span_label(
|
||||||
yield_span,
|
yield_span,
|
||||||
format!("{} occurs here, with {} maybe used later", await_or_yield, snippet),
|
format!("{} occurs here, with {} maybe used later", await_or_yield, snippet),
|
||||||
|
@ -1753,6 +1750,18 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
interior_span,
|
interior_span,
|
||||||
format!("has type `{}` which {}", target_ty, trait_explanation),
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
err.span_note(
|
err.span_note(
|
||||||
span,
|
span,
|
||||||
&format!(
|
&format!(
|
||||||
|
@ -1760,6 +1769,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
future_or_generator, trait_explanation, an_await_or_yield
|
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 {
|
match interior_or_upvar_span {
|
||||||
|
|
|
@ -12,10 +12,14 @@ LL | baz(|| async{
|
||||||
| _____________-
|
| _____________-
|
||||||
LL | | foo(tx.clone());
|
LL | | foo(tx.clone());
|
||||||
LL | | }).await;
|
LL | | }).await;
|
||||||
| | - ^^^^^^- the value is later dropped here
|
| | - ^^^^^^ await occurs here, with the value maybe used later
|
||||||
| | | |
|
| |_________|
|
||||||
| |_________| await occurs here, with the value maybe used later
|
|
||||||
| has type `[closure@$DIR/issue-70935-complex-spans.rs:13:13: 15:10]` which is not `Send`
|
| has type `[closure@$DIR/issue-70935-complex-spans.rs:13:13: 15:10]` which is not `Send`
|
||||||
|
note: the value is later dropped here
|
||||||
|
--> $DIR/issue-70935-complex-spans.rs:15:17
|
||||||
|
|
|
||||||
|
LL | }).await;
|
||||||
|
| ^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,14 @@ note: future is not `Send` as this value is used across an await
|
||||||
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:35
|
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:35
|
||||||
|
|
|
|
||||||
LL | bar(Foo(std::ptr::null())).await;
|
LL | bar(Foo(std::ptr::null())).await;
|
||||||
| ---------------- ^^^^^^- `std::ptr::null()` is later dropped here
|
| ---------------- ^^^^^^ await occurs here, with `std::ptr::null()` maybe used later
|
||||||
| | |
|
| |
|
||||||
| | await occurs here, with `std::ptr::null()` maybe used later
|
|
||||||
| has type `*const u8` which is not `Send`
|
| has type `*const u8` which is not `Send`
|
||||||
|
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;
|
||||||
|
| ^
|
||||||
help: consider moving this into a `let` binding to create a shorter lived borrow
|
help: consider moving this into a `let` binding to create a shorter lived borrow
|
||||||
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:13
|
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:13
|
||||||
|
|
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue