rust/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr

99 lines
3.9 KiB
Plaintext
Raw Normal View History

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