1
Fork 0

Add ui test to reproduce non-Send panic temporary

This commit is contained in:
David Tolnay 2022-11-07 13:16:25 -08:00
parent 3603a84a3d
commit cbee2a1ec4
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
2 changed files with 46 additions and 0 deletions

View file

@ -0,0 +1,19 @@
// check-fail
// edition:2021
#![allow(unreachable_code)]
async fn f(_: u8) {}
async fn g() {
// Todo returns `!`, so the await is never reached, and in particular the
// temporaries inside the formatting machinery are not still alive at the
// await point.
f(todo!("...")).await;
}
fn require_send(_: impl Send) {}
fn main() {
require_send(g()); //~ future cannot be sent between threads safely
}

View file

@ -0,0 +1,27 @@
error: future cannot be sent between threads safely
--> $DIR/panic-temporaries.rs:18:18
|
LL | require_send(g());
| ^^^ future returned by `g` is not `Send`
|
= help: the trait `Sync` is not implemented for `core::fmt::Opaque`
note: future is not `Send` as this value is used across an await
--> $DIR/panic-temporaries.rs:12:20
|
LL | f(todo!("...")).await;
| ------------ ^^^^^^ await occurs here, with `$crate::format_args!($($arg)+)` maybe used later
| |
| has type `ArgumentV1<'_>` which is not `Send`
note: `$crate::format_args!($($arg)+)` is later dropped here
--> $DIR/panic-temporaries.rs:12:26
|
LL | f(todo!("...")).await;
| ^
note: required by a bound in `require_send`
--> $DIR/panic-temporaries.rs:15:25
|
LL | fn require_send(_: impl Send) {}
| ^^^^ required by this bound in `require_send`
error: aborting due to previous error