2022-11-07 21:23:16 +00:00
|
|
|
// check-pass
|
2022-11-07 21:16:25 +00:00
|
|
|
// edition:2021
|
|
|
|
|
|
|
|
#![allow(unreachable_code)]
|
|
|
|
|
2023-05-15 09:56:31 +00:00
|
|
|
use std::fmt::{self, Display};
|
|
|
|
use std::marker::PhantomData;
|
|
|
|
|
|
|
|
struct NotSend {
|
|
|
|
marker: PhantomData<*const u8>,
|
|
|
|
}
|
|
|
|
|
|
|
|
const NOT_SEND: NotSend = NotSend { marker: PhantomData };
|
|
|
|
|
|
|
|
impl Display for NotSend {
|
|
|
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
formatter.write_str("this value does not implement Send")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-07 21:16:25 +00:00
|
|
|
async fn f(_: u8) {}
|
|
|
|
|
2023-05-15 09:56:31 +00:00
|
|
|
// Exercises this matcher in panic_2021:
|
|
|
|
// ($($t:tt)+) => $crate::panicking::panic_fmt(...)
|
|
|
|
async fn panic_fmt() {
|
|
|
|
// Panic returns `!`, so the await is never reached, and in particular the
|
2022-11-07 21:16:25 +00:00
|
|
|
// temporaries inside the formatting machinery are not still alive at the
|
|
|
|
// await point.
|
2023-05-15 09:56:31 +00:00
|
|
|
let todo = "...";
|
|
|
|
f(panic!("not yet implemented: {}", todo)).await;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exercises ("{}", $arg:expr) => $crate::panicking::panic_display(&$arg)
|
|
|
|
async fn panic_display() {
|
|
|
|
f(panic!("{}", NOT_SEND)).await;
|
2022-11-07 21:16:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn require_send(_: impl Send) {}
|
|
|
|
|
|
|
|
fn main() {
|
2023-05-15 09:56:31 +00:00
|
|
|
require_send(panic_fmt());
|
|
|
|
require_send(panic_display());
|
2022-11-07 21:16:25 +00:00
|
|
|
}
|