]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | error[E0308]: mismatched types |
2 | --> $DIR/expected-boxed-future-isnt-pinned.rs:11:5 | |
3 | | | |
4 | LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> { | |
1b1a35ee | 5 | | - this type parameter ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type |
74b04a01 XL |
6 | LL | // We could instead use an `async` block, but this way we have no std spans. |
7 | LL | x | |
8 | | ^ | |
9 | | | | |
1b1a35ee | 10 | | expected struct `Pin`, found type parameter `F` |
74b04a01 XL |
11 | | help: you need to pin and box this expression: `Box::pin(x)` |
12 | | | |
1b1a35ee | 13 | = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` |
74b04a01 | 14 | found type parameter `F` |
74b04a01 | 15 | |
f9f354fc XL |
16 | error[E0308]: mismatched types |
17 | --> $DIR/expected-boxed-future-isnt-pinned.rs:18:5 | |
18 | | | |
19 | LL | fn bar<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> { | |
1b1a35ee | 20 | | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type |
f9f354fc | 21 | LL | Box::new(x) |
1b1a35ee | 22 | | ^^^^^^^^^^^ expected struct `Pin`, found struct `Box` |
f9f354fc | 23 | | |
1b1a35ee XL |
24 | = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` |
25 | found struct `Box<F>` | |
f9f354fc XL |
26 | = help: use `Box::pin` |
27 | ||
28 | error[E0308]: mismatched types | |
29 | --> $DIR/expected-boxed-future-isnt-pinned.rs:22:14 | |
30 | | | |
31 | LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> { | |
32 | | - this type parameter | |
33 | LL | Pin::new(x) | |
34 | | ^ | |
35 | | | | |
1b1a35ee | 36 | | expected struct `Box`, found type parameter `F` |
f9f354fc XL |
37 | | help: store this in the heap by calling `Box::new`: `Box::new(x)` |
38 | | | |
1b1a35ee | 39 | = note: expected struct `Box<dyn Future<Output = i32> + Send>` |
f9f354fc XL |
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 | |
42 | ||
1b1a35ee | 43 | error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned |
f9f354fc XL |
44 | --> $DIR/expected-boxed-future-isnt-pinned.rs:22:5 |
45 | | | |
46 | LL | Pin::new(x) | |
1b1a35ee | 47 | | ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send` |
f9f354fc | 48 | | |
1b1a35ee | 49 | = note: required by `Pin::<P>::new` |
f9f354fc | 50 | |
1b1a35ee | 51 | error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned |
f9f354fc XL |
52 | --> $DIR/expected-boxed-future-isnt-pinned.rs:27:5 |
53 | | | |
54 | LL | Pin::new(Box::new(x)) | |
1b1a35ee | 55 | | ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send` |
f9f354fc | 56 | | |
1b1a35ee | 57 | = note: required by `Pin::<P>::new` |
f9f354fc XL |
58 | |
59 | error[E0308]: mismatched types | |
60 | --> $DIR/expected-boxed-future-isnt-pinned.rs:31:5 | |
61 | | | |
62 | LL | fn zap() -> BoxFuture<'static, i32> { | |
1b1a35ee | 63 | | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type |
f9f354fc XL |
64 | LL | / async { |
65 | LL | | 42 | |
66 | LL | | } | |
1b1a35ee | 67 | | |_____^ expected struct `Pin`, found opaque type |
f9f354fc | 68 | | |
3dfed10e | 69 | ::: $SRC_DIR/core/src/future/mod.rs:LL:COL |
f9f354fc XL |
70 | | |
71 | LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return> | |
72 | | ------------------------------- the found opaque type | |
73 | | | |
1b1a35ee XL |
74 | = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` |
75 | found opaque type `impl Future` | |
f9f354fc XL |
76 | help: you need to pin and box this expression |
77 | | | |
78 | LL | Box::pin(async { | |
79 | LL | 42 | |
80 | LL | }) | |
81 | | | |
82 | ||
83 | error: aborting due to 6 previous errors | |
74b04a01 | 84 | |
f9f354fc XL |
85 | Some errors have detailed explanations: E0277, E0308. |
86 | For more information about an error, try `rustc --explain E0277`. |