]> git.proxmox.com Git - rustc.git/blame - src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / suggestions / expected-boxed-future-isnt-pinned.stderr
CommitLineData
74b04a01
XL
1error[E0308]: mismatched types
2 --> $DIR/expected-boxed-future-isnt-pinned.rs:11:5
3 |
4LL | 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
6LL | // We could instead use an `async` block, but this way we have no std spans.
7LL | 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
16error[E0308]: mismatched types
17 --> $DIR/expected-boxed-future-isnt-pinned.rs:18:5
18 |
19LL | 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 21LL | 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
28error[E0308]: mismatched types
29 --> $DIR/expected-boxed-future-isnt-pinned.rs:22:14
30 |
31LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
32 | - this type parameter
33LL | 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 43error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
f9f354fc
XL
44 --> $DIR/expected-boxed-future-isnt-pinned.rs:22:5
45 |
46LL | 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 51error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
f9f354fc
XL
52 --> $DIR/expected-boxed-future-isnt-pinned.rs:27:5
53 |
54LL | 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
59error[E0308]: mismatched types
60 --> $DIR/expected-boxed-future-isnt-pinned.rs:31:5
61 |
62LL | fn zap() -> BoxFuture<'static, i32> {
1b1a35ee 63 | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
f9f354fc
XL
64LL | / async {
65LL | | 42
66LL | | }
1b1a35ee 67 | |_____^ expected struct `Pin`, found opaque type
f9f354fc 68 |
3dfed10e 69 ::: $SRC_DIR/core/src/future/mod.rs:LL:COL
f9f354fc
XL
70 |
71LL | 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
76help: you need to pin and box this expression
77 |
78LL | Box::pin(async {
79LL | 42
80LL | })
81 |
82
83error: aborting due to 6 previous errors
74b04a01 84
f9f354fc
XL
85Some errors have detailed explanations: E0277, E0308.
86For more information about an error, try `rustc --explain E0277`.