rust/tests/ui/async-await/async-closures/move-is-async-fn.rs

26 lines
601 B
Rust
Raw Normal View History

//@ aux-build:block-on.rs
//@ edition:2021
//@ build-pass
2024-01-25 11:43:35 -06:00
2024-02-26 17:06:38 -06:00
#![feature(async_closure, async_fn_traits)]
2024-01-25 11:43:35 -06:00
extern crate block_on;
fn main() {
block_on::block_on(async {
let s = String::from("hello, world");
let c = async move || {
println!("{s}");
};
c().await;
c().await;
2024-02-26 17:06:38 -06:00
fn is_static<T: 'static>(_: &T) {}
is_static(&c);
// Check that `<{async fn} as AsyncFnOnce>::CallOnceFuture` owns its captures.
fn call_once<F: async FnOnce()>(f: F) -> F::CallOnceFuture { f() }
is_static(&call_once(c));
2024-01-25 11:43:35 -06:00
});
}