Skip to content

Commit a852fb7

Browse files
committed
Remove std lib Span from expected boxed future test
1 parent c39b04e commit a852fb7

File tree

3 files changed

+19
-28
lines changed

3 files changed

+19
-28
lines changed

src/test/ui/suggestions/expected-boxed-future-isnt-pinned.fixed

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ use std::pin::Pin;
77
type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
88
// ^^^^^^^^^ This would come from the `futures` crate in real code.
99

10-
fn foo() -> BoxFuture<'static, i32> {
11-
Box::pin(async { //~ ERROR mismatched types
12-
42
13-
})
10+
fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
11+
// We could instead use an `async` block, but this way we have no std spans.
12+
Box::pin(x) //~ ERROR mismatched types
1413
}
1514

1615
fn main() {}

src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ use std::pin::Pin;
77
type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
88
// ^^^^^^^^^ This would come from the `futures` crate in real code.
99

10-
fn foo() -> BoxFuture<'static, i32> {
11-
async { //~ ERROR mismatched types
12-
42
13-
}
10+
fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
11+
// We could instead use an `async` block, but this way we have no std spans.
12+
x //~ ERROR mismatched types
1413
}
1514

1615
fn main() {}

src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
error[E0308]: mismatched types
2-
--> $DIR/expected-boxed-future-isnt-pinned.rs:11:5
2+
--> $DIR/expected-boxed-future-isnt-pinned.rs:12:5
33
|
4-
LL | fn foo() -> BoxFuture<'static, i32> {
5-
| ----------------------- expected `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>` because of return type
6-
LL | / async {
7-
LL | | 42
8-
LL | | }
9-
| |_____^ expected struct `std::pin::Pin`, found opaque type
10-
|
11-
::: $SRC_DIR/libstd/future.rs:LL:COL
12-
|
13-
LL | pub fn from_generator<T: Generator<Yield = ()>>(x: T) -> impl Future<Output = T::Return> {
14-
| ------------------------------- the found opaque type
15-
|
16-
= note: expected struct `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>`
17-
found opaque type `impl std::future::Future`
18-
help: you need to pin and box this expression
19-
|
20-
LL | Box::pin(async {
21-
LL | 42
22-
LL | })
4+
LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
5+
| - this type parameter ----------------------- expected `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::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 `std::pin::Pin`, found type parameter `F`
11+
| help: you need to pin and box this expression: `Box::pin(x)`
2312
|
13+
= note: expected struct `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>`
14+
found type parameter `F`
15+
= help: type parameters must be constrained to match other types
16+
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
2417

2518
error: aborting due to previous error
2619

0 commit comments

Comments
 (0)