2020-02-11 19:19:05 -06:00
error[E0308]: mismatched types
2020-02-12 13:11:55 -06:00
--> $DIR/expected-boxed-future-isnt-pinned.rs:11:5
2020-02-11 19:19:05 -06:00
|
2020-02-11 19:35:04 -06:00
LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
2020-09-02 02:40:56 -05:00
| - this type parameter ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
2020-02-11 19:35:04 -06:00
LL | // We could instead use an `async` block, but this way we have no std spans.
LL | x
| ^
| |
2020-09-02 02:40:56 -05:00
| expected struct `Pin`, found type parameter `F`
2020-02-11 19:35:04 -06:00
| help: you need to pin and box this expression: `Box::pin(x)`
2020-02-11 19:19:05 -06:00
|
2020-09-02 02:40:56 -05:00
= note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
2020-02-11 19:35:04 -06:00
found type parameter `F`
2020-02-11 19:19:05 -06:00
2020-05-01 18:53:20 -05:00
error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:18:5
|
LL | fn bar<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
2020-09-02 02:40:56 -05:00
| ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
2020-05-01 18:53:20 -05:00
LL | Box::new(x)
2020-09-02 02:40:56 -05:00
| ^^^^^^^^^^^ expected struct `Pin`, found struct `Box`
2020-05-01 18:53:20 -05:00
|
2020-09-02 02:40:56 -05:00
= note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
found struct `Box<F>`
2020-05-01 18:53:20 -05:00
= help: use `Box::pin`
error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:22:14
|
LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
| - this type parameter
LL | Pin::new(x)
| ^
| |
2020-09-02 02:40:56 -05:00
| expected struct `Box`, found type parameter `F`
2020-05-01 18:53:20 -05:00
| help: store this in the heap by calling `Box::new`: `Box::new(x)`
|
2020-09-02 02:40:56 -05:00
= note: expected struct `Box<dyn Future<Output = i32> + Send>`
2020-05-01 18:53:20 -05:00
found type parameter `F`
= 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
2020-09-02 02:40:56 -05:00
error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
2020-05-01 18:53:20 -05:00
--> $DIR/expected-boxed-future-isnt-pinned.rs:22:5
|
LL | Pin::new(x)
2020-09-02 02:40:56 -05:00
| ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
2020-05-01 18:53:20 -05:00
|
2021-03-12 04:48:05 -06:00
= note: consider using `Box::pin`
2020-09-02 02:40:56 -05:00
= note: required by `Pin::<P>::new`
2020-05-01 18:53:20 -05:00
2020-09-02 02:40:56 -05:00
error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
2020-05-01 18:53:20 -05:00
--> $DIR/expected-boxed-future-isnt-pinned.rs:27:5
|
LL | Pin::new(Box::new(x))
2020-09-02 02:40:56 -05:00
| ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
2020-05-01 18:53:20 -05:00
|
2021-03-12 04:48:05 -06:00
= note: consider using `Box::pin`
2020-09-02 02:40:56 -05:00
= note: required by `Pin::<P>::new`
2020-05-01 18:53:20 -05:00
error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:31:5
|
LL | fn zap() -> BoxFuture<'static, i32> {
2020-09-02 02:40:56 -05:00
| ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
2020-05-01 18:53:20 -05:00
LL | / async {
LL | | 42
LL | | }
2020-09-02 02:40:56 -05:00
| |_____^ expected struct `Pin`, found opaque type
2020-05-01 18:53:20 -05:00
|
2020-06-11 21:31:49 -05:00
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
2020-05-01 18:53:20 -05:00
|
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type
|
2020-09-02 02:40:56 -05:00
= note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
found opaque type `impl Future`
2020-05-01 18:53:20 -05:00
help: you need to pin and box this expression
|
LL | Box::pin(async {
LL | 42
LL | })
|
error: aborting due to 6 previous errors
2020-02-11 19:19:05 -06:00
2020-05-01 18:53:20 -05:00
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.