]> git.proxmox.com Git - rustc.git/blob - src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
New upstream version 1.53.0+dfsg1
[rustc.git] / src / test / ui / suggestions / expected-boxed-future-isnt-pinned.stderr
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> {
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.
7 LL | x
8 | ^
9 | |
10 | expected struct `Pin`, found type parameter `F`
11 | help: you need to pin and box this expression: `Box::pin(x)`
12 |
13 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
14 found type parameter `F`
15
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> {
20 | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
21 LL | Box::new(x)
22 | ^^^^^^^^^^^ expected struct `Pin`, found struct `Box`
23 |
24 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
25 found struct `Box<F>`
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 | |
36 | expected struct `Box`, found type parameter `F`
37 | help: store this in the heap by calling `Box::new`: `Box::new(x)`
38 |
39 = note: expected struct `Box<dyn Future<Output = i32> + Send>`
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
43 error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
44 --> $DIR/expected-boxed-future-isnt-pinned.rs:22:5
45 |
46 LL | Pin::new(x)
47 | ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
48 |
49 = note: consider using `Box::pin`
50 = note: required by `Pin::<P>::new`
51
52 error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
53 --> $DIR/expected-boxed-future-isnt-pinned.rs:27:5
54 |
55 LL | Pin::new(Box::new(x))
56 | ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
57 |
58 = note: consider using `Box::pin`
59 = note: required by `Pin::<P>::new`
60
61 error[E0308]: mismatched types
62 --> $DIR/expected-boxed-future-isnt-pinned.rs:31:5
63 |
64 LL | fn zap() -> BoxFuture<'static, i32> {
65 | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
66 LL | / async {
67 LL | | 42
68 LL | | }
69 | |_____^ expected struct `Pin`, found opaque type
70 |
71 ::: $SRC_DIR/core/src/future/mod.rs:LL:COL
72 |
73 LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
74 | ------------------------------- the found opaque type
75 |
76 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
77 found opaque type `impl Future`
78 help: you need to pin and box this expression
79 |
80 LL | Box::pin(async {
81 LL | 42
82 LL | })
83 |
84
85 error: aborting due to 6 previous errors
86
87 Some errors have detailed explanations: E0277, E0308.
88 For more information about an error, try `rustc --explain E0277`.