diff --git a/tests/ui/macros/panic-temporaries.rs b/tests/ui/macros/panic-temporaries.rs new file mode 100644 index 00000000000..5ca139daf4e --- /dev/null +++ b/tests/ui/macros/panic-temporaries.rs @@ -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 +} diff --git a/tests/ui/macros/panic-temporaries.stderr b/tests/ui/macros/panic-temporaries.stderr new file mode 100644 index 00000000000..425409dda69 --- /dev/null +++ b/tests/ui/macros/panic-temporaries.stderr @@ -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 +