3 use std::future::Future;
6 type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
7 // ^^^^^^^^^ This would come from the `futures` crate in real code.
9 fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
10 // We could instead use an `async` block, but this way we have no std spans.
11 x //~ ERROR mismatched types
14 fn bar<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
15 Box::new(x) //~ ERROR mismatched types
18 fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
19 Pin::new(x) //~ ERROR mismatched types
23 fn qux<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
24 Pin::new(Box::new(x)) //~ ERROR E0277
27 fn zap() -> BoxFuture<'static, i32> {
28 async { //~ ERROR mismatched types