]> git.proxmox.com Git - rustc.git/blame - src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
New upstream version 1.65.0+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
94222f64 8 | ^ expected struct `Pin`, found type parameter `F`
74b04a01 9 |
1b1a35ee 10 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
74b04a01 11 found type parameter `F`
94222f64
XL
12help: you need to pin and box this expression
13 |
14LL | Box::pin(x)
15 | +++++++++ +
74b04a01 16
f9f354fc 17error[E0308]: mismatched types
c295e0f8 18 --> $DIR/expected-boxed-future-isnt-pinned.rs:15:5
f9f354fc
XL
19 |
20LL | fn bar<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
1b1a35ee 21 | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
f9f354fc 22LL | Box::new(x)
1b1a35ee 23 | ^^^^^^^^^^^ expected struct `Pin`, found struct `Box`
f9f354fc 24 |
1b1a35ee
XL
25 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
26 found struct `Box<F>`
f9f354fc
XL
27 = help: use `Box::pin`
28
29error[E0308]: mismatched types
c295e0f8 30 --> $DIR/expected-boxed-future-isnt-pinned.rs:19:14
f9f354fc
XL
31 |
32LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
33 | - this type parameter
34LL | Pin::new(x)
c295e0f8
XL
35 | -------- ^ expected struct `Box`, found type parameter `F`
36 | |
923072b8 37 | arguments to this function are incorrect
c295e0f8 38 | help: use `Box::pin` to pin and box this expression: `Box::pin`
f9f354fc 39 |
1b1a35ee 40 = note: expected struct `Box<dyn Future<Output = i32> + Send>`
f9f354fc 41 found type parameter `F`
923072b8
FG
42note: associated function defined here
43 --> $SRC_DIR/core/src/pin.rs:LL:COL
44 |
45LL | pub const fn new(pointer: P) -> Pin<P> {
46 | ^^^
f9f354fc 47
1b1a35ee 48error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
f2b60f7d 49 --> $DIR/expected-boxed-future-isnt-pinned.rs:19:14
f9f354fc
XL
50 |
51LL | Pin::new(x)
f2b60f7d
FG
52 | -------- ^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
53 | |
54 | required by a bound introduced by this call
f9f354fc 55 |
cdc7bbd5 56 = note: consider using `Box::pin`
3c0e092e 57note: required by a bound in `Pin::<P>::new`
136023e0
XL
58 --> $SRC_DIR/core/src/pin.rs:LL:COL
59 |
3c0e092e
XL
60LL | impl<P: Deref<Target: Unpin>> Pin<P> {
61 | ^^^^^ required by this bound in `Pin::<P>::new`
f9f354fc 62
1b1a35ee 63error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
f2b60f7d 64 --> $DIR/expected-boxed-future-isnt-pinned.rs:24:14
f9f354fc
XL
65 |
66LL | Pin::new(Box::new(x))
f2b60f7d
FG
67 | -------- ^^^^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
68 | |
69 | required by a bound introduced by this call
f9f354fc 70 |
cdc7bbd5 71 = note: consider using `Box::pin`
3c0e092e 72note: required by a bound in `Pin::<P>::new`
136023e0
XL
73 --> $SRC_DIR/core/src/pin.rs:LL:COL
74 |
3c0e092e
XL
75LL | impl<P: Deref<Target: Unpin>> Pin<P> {
76 | ^^^^^ required by this bound in `Pin::<P>::new`
f9f354fc
XL
77
78error[E0308]: mismatched types
c295e0f8 79 --> $DIR/expected-boxed-future-isnt-pinned.rs:28:5
f9f354fc
XL
80 |
81LL | fn zap() -> BoxFuture<'static, i32> {
1b1a35ee 82 | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
f9f354fc
XL
83LL | / async {
84LL | | 42
85LL | | }
1b1a35ee 86 | |_____^ expected struct `Pin`, found opaque type
94222f64 87 |
3dfed10e 88 ::: $SRC_DIR/core/src/future/mod.rs:LL:COL
f9f354fc
XL
89 |
90LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
91 | ------------------------------- the found opaque type
92 |
1b1a35ee 93 = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
f2b60f7d 94 found opaque type `impl Future<Output = {integer}>`
f9f354fc
XL
95help: you need to pin and box this expression
96 |
94222f64 97LL ~ Box::pin(async {
f9f354fc 98LL | 42
94222f64 99LL ~ })
f9f354fc
XL
100 |
101
102error: aborting due to 6 previous errors
74b04a01 103
f9f354fc
XL
104Some errors have detailed explanations: E0277, E0308.
105For more information about an error, try `rustc --explain E0277`.