|
1 | 1 | error[E0308]: mismatched types
|
2 |
| - --> $DIR/expected-boxed-future-isnt-pinned.rs:11:5 |
| 2 | + --> $DIR/expected-boxed-future-isnt-pinned.rs:12:5 |
3 | 3 | |
|
4 |
| -LL | fn foo() -> BoxFuture<'static, i32> { |
5 |
| - | ----------------------- expected `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>` because of return type |
6 |
| -LL | / async { |
7 |
| -LL | | 42 |
8 |
| -LL | | } |
9 |
| - | |_____^ expected struct `std::pin::Pin`, found opaque type |
10 |
| - | |
11 |
| - ::: $SRC_DIR/libstd/future.rs:LL:COL |
12 |
| - | |
13 |
| -LL | pub fn from_generator<T: Generator<Yield = ()>>(x: T) -> impl Future<Output = T::Return> { |
14 |
| - | ------------------------------- the found opaque type |
15 |
| - | |
16 |
| - = note: expected struct `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>` |
17 |
| - found opaque type `impl std::future::Future` |
18 |
| -help: you need to pin and box this expression |
19 |
| - | |
20 |
| -LL | Box::pin(async { |
21 |
| -LL | 42 |
22 |
| -LL | }) |
| 4 | +LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> { |
| 5 | + | - this type parameter ----------------------- expected `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>` because of return type |
| 6 | +LL | // We could instead use an `async` block, but this way we have no std spans. |
| 7 | +LL | x |
| 8 | + | ^ |
| 9 | + | | |
| 10 | + | expected struct `std::pin::Pin`, found type parameter `F` |
| 11 | + | help: you need to pin and box this expression: `Box::pin(x)` |
23 | 12 | |
|
| 13 | + = note: expected struct `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>` |
| 14 | + found type parameter `F` |
| 15 | + = help: type parameters must be constrained to match other types |
| 16 | + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters |
24 | 17 |
|
25 | 18 | error: aborting due to previous error
|
26 | 19 |
|
|
0 commit comments