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.
8 | ^ expected struct `Pin`, found type parameter `F`
10 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
11 found type parameter `F`
12 help: you need to pin and box this expression
17 error[E0308]: mismatched types
18 --> $DIR/expected-boxed-future-isnt-pinned.rs:18:5
20 LL | fn bar<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
21 | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
23 | ^^^^^^^^^^^ expected struct `Pin`, found struct `Box`
25 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
27 = help: use `Box::pin`
29 error[E0308]: mismatched types
30 --> $DIR/expected-boxed-future-isnt-pinned.rs:22:14
32 LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
33 | - this type parameter
35 | ^ expected struct `Box`, found type parameter `F`
37 = note: expected struct `Box<dyn Future<Output = i32> + Send>`
38 found type parameter `F`
39 = 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
40 help: store this in the heap by calling `Box::new`
42 LL | Pin::new(Box::new(x))
45 error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
46 --> $DIR/expected-boxed-future-isnt-pinned.rs:22:5
49 | ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
51 = note: consider using `Box::pin`
52 note: required by `Pin::<P>::new`
53 --> $SRC_DIR/core/src/pin.rs:LL:COL
55 LL | pub const fn new(pointer: P) -> Pin<P> {
56 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58 error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
59 --> $DIR/expected-boxed-future-isnt-pinned.rs:27:5
61 LL | Pin::new(Box::new(x))
62 | ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
64 = note: consider using `Box::pin`
65 note: required by `Pin::<P>::new`
66 --> $SRC_DIR/core/src/pin.rs:LL:COL
68 LL | pub const fn new(pointer: P) -> Pin<P> {
69 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71 error[E0308]: mismatched types
72 --> $DIR/expected-boxed-future-isnt-pinned.rs:31:5
74 LL | fn zap() -> BoxFuture<'static, i32> {
75 | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
79 | |_____^ expected struct `Pin`, found opaque type
81 ::: $SRC_DIR/core/src/future/mod.rs:LL:COL
83 LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
84 | ------------------------------- the found opaque type
86 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
87 found opaque type `impl Future`
88 help: you need to pin and box this expression
95 error: aborting due to 6 previous errors
97 Some errors have detailed explanations: E0277, E0308.
98 For more information about an error, try `rustc --explain E0277`.