fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
3.8 KiB93 linesraw
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> {
5   |        - this type parameter                            ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
6LL |     // We could instead use an `async` block, but this way we have no std spans.
7LL |     x
8   |     ^ expected `Pin<Box<...>>`, found type parameter `F`
9   |
10   = note:      expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
11           found type parameter `F`
12help: you need to pin and box this expression
13   |
14LL |     Box::pin(x)
15   |     +++++++++ +
16
17error[E0308]: mismatched types
18  --> $DIR/expected-boxed-future-isnt-pinned.rs:15:5
19   |
20LL | 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
22LL |     Box::new(x)
23   |     ^^^^^^^^^^^ expected `Pin<Box<...>>`, found `Box<F>`
24   |
25   = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
26              found struct `Box<F>`
27   = help: use `Box::pin`
28
29error[E0308]: mismatched types
30  --> $DIR/expected-boxed-future-isnt-pinned.rs:19:14
31   |
32LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
33   |        - this type parameter
34LL |     Pin::new(x)
35   |     -------- ^ expected `Box<dyn Future<Output = ...> + Send>`, found type parameter `F`
36   |     |
37   |     arguments to this function are incorrect
38   |     help: use `Box::pin` to pin and box this expression: `Box::pin`
39   |
40   = note:      expected struct `Box<dyn Future<Output = i32> + Send>`
41           found type parameter `F`
42note: associated function defined here
43  --> $SRC_DIR/core/src/pin.rs:LL:COL
44
45error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
46  --> $DIR/expected-boxed-future-isnt-pinned.rs:19:14
47   |
48LL |     Pin::new(x)
49   |     -------- ^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
50   |     |
51   |     required by a bound introduced by this call
52   |
53   = note: consider using the `pin!` macro
54           consider using `Box::pin` if you need to access the pinned value outside of the current scope
55note: required by a bound in `Pin::<P>::new`
56  --> $SRC_DIR/core/src/pin.rs:LL:COL
57
58error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
59  --> $DIR/expected-boxed-future-isnt-pinned.rs:24:14
60   |
61LL |     Pin::new(Box::new(x))
62   |     -------- ^^^^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
63   |     |
64   |     required by a bound introduced by this call
65   |
66   = note: consider using the `pin!` macro
67           consider using `Box::pin` if you need to access the pinned value outside of the current scope
68note: required by a bound in `Pin::<P>::new`
69  --> $SRC_DIR/core/src/pin.rs:LL:COL
70
71error[E0308]: mismatched types
72  --> $DIR/expected-boxed-future-isnt-pinned.rs:28:5
73   |
74LL |   fn zap() -> BoxFuture<'static, i32> {
75   |               ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
76LL | /     async {
77LL | |         42
78LL | |     }
79   | |_____^ expected `Pin<Box<...>>`, found `async` block
80   |
81   = note:     expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
82           found `async` block `{async block@$DIR/expected-boxed-future-isnt-pinned.rs:28:5: 30:6}`
83help: you need to pin and box this expression
84   |
85LL ~     Box::pin(async {
86LL |         42
87LL ~     })
88   |
89
90error: aborting due to 6 previous errors
91
92Some errors have detailed explanations: E0277, E0308.
93For more information about an error, try `rustc --explain E0277`.