]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid
[rust.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    |     ^ expected struct `Pin`, found type parameter `F`
9    |
10    = note:      expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
11            found type parameter `F`
12 help: you need to pin and box this expression
13    |
14 LL |     Box::pin(x)
15    |     +++++++++ +
16
17 error[E0308]: mismatched types
18   --> $DIR/expected-boxed-future-isnt-pinned.rs:15:5
19    |
20 LL | fn bar<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
21    |                                                         ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
22 LL |     Box::new(x)
23    |     ^^^^^^^^^^^ expected struct `Pin`, found struct `Box`
24    |
25    = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
26               found struct `Box<F>`
27    = help: use `Box::pin`
28
29 error[E0308]: mismatched types
30   --> $DIR/expected-boxed-future-isnt-pinned.rs:19:14
31    |
32 LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
33    |        - this type parameter
34 LL |     Pin::new(x)
35    |     -------- ^ expected struct `Box`, found type parameter `F`
36    |     |
37    |     help: use `Box::pin` to pin and box this expression: `Box::pin`
38    |
39    = note:      expected struct `Box<dyn Future<Output = i32> + Send>`
40            found type parameter `F`
41
42 error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
43   --> $DIR/expected-boxed-future-isnt-pinned.rs:19:5
44    |
45 LL |     Pin::new(x)
46    |     ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
47    |
48    = note: consider using `Box::pin`
49 note: required by a bound in `Pin::<P>::new`
50   --> $SRC_DIR/core/src/pin.rs:LL:COL
51    |
52 LL | impl<P: Deref<Target: Unpin>> Pin<P> {
53    |                       ^^^^^ required by this bound in `Pin::<P>::new`
54
55 error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
56   --> $DIR/expected-boxed-future-isnt-pinned.rs:24:5
57    |
58 LL |     Pin::new(Box::new(x))
59    |     ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
60    |
61    = note: consider using `Box::pin`
62 note: required by a bound in `Pin::<P>::new`
63   --> $SRC_DIR/core/src/pin.rs:LL:COL
64    |
65 LL | impl<P: Deref<Target: Unpin>> Pin<P> {
66    |                       ^^^^^ required by this bound in `Pin::<P>::new`
67
68 error[E0308]: mismatched types
69   --> $DIR/expected-boxed-future-isnt-pinned.rs:28:5
70    |
71 LL |   fn zap() -> BoxFuture<'static, i32> {
72    |               ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
73 LL | /     async {
74 LL | |         42
75 LL | |     }
76    | |_____^ expected struct `Pin`, found opaque type
77    |
78   ::: $SRC_DIR/core/src/future/mod.rs:LL:COL
79    |
80 LL |   pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
81    |                                             ------------------------------- the found opaque type
82    |
83    = note:   expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
84            found opaque type `impl Future`
85 help: you need to pin and box this expression
86    |
87 LL ~     Box::pin(async {
88 LL |         42
89 LL ~     })
90    |
91
92 error: aborting due to 6 previous errors
93
94 Some errors have detailed explanations: E0277, E0308.
95 For more information about an error, try `rustc --explain E0277`.