1 error[E0308]: mismatched types
2 --> $DIR/expected-boxed-future-isnt-pinned.rs:11:5
4 LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
5 | - this type parameter ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
6 LL | // We could instead use an `async` block, but this way we have no std spans.
10 | expected struct `Pin`, found type parameter `F`
11 | help: you need to pin and box this expression: `Box::pin(x)`
13 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
14 found type parameter `F`
16 error[E0308]: mismatched types
17 --> $DIR/expected-boxed-future-isnt-pinned.rs:18:5
19 LL | fn bar<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
20 | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
22 | ^^^^^^^^^^^ expected struct `Pin`, found struct `Box`
24 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
26 = help: use `Box::pin`
28 error[E0308]: mismatched types
29 --> $DIR/expected-boxed-future-isnt-pinned.rs:22:14
31 LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
32 | - this type parameter
36 | expected struct `Box`, found type parameter `F`
37 | help: store this in the heap by calling `Box::new`: `Box::new(x)`
39 = note: expected struct `Box<dyn Future<Output = i32> + Send>`
40 found type parameter `F`
41 = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
43 error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
44 --> $DIR/expected-boxed-future-isnt-pinned.rs:22:5
47 | ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
49 = note: consider using `Box::pin`
50 = note: required by `Pin::<P>::new`
52 error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
53 --> $DIR/expected-boxed-future-isnt-pinned.rs:27:5
55 LL | Pin::new(Box::new(x))
56 | ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
58 = note: consider using `Box::pin`
59 = note: required by `Pin::<P>::new`
61 error[E0308]: mismatched types
62 --> $DIR/expected-boxed-future-isnt-pinned.rs:31:5
64 LL | fn zap() -> BoxFuture<'static, i32> {
65 | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
69 | |_____^ expected struct `Pin`, found opaque type
71 ::: $SRC_DIR/core/src/future/mod.rs:LL:COL
73 LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
74 | ------------------------------- the found opaque type
76 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
77 found opaque type `impl Future`
78 help: you need to pin and box this expression
85 error: aborting due to 6 previous errors
87 Some errors have detailed explanations: E0277, E0308.
88 For more information about an error, try `rustc --explain E0277`.