Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove std lib Span from expected boxed future test
  • Loading branch information
estebank committed Feb 12, 2020
1 parent c39b04e commit a852fb7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
Expand Up @@ -7,10 +7,9 @@ use std::pin::Pin;
type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
// ^^^^^^^^^ This would come from the `futures` crate in real code.

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

fn main() {}
7 changes: 3 additions & 4 deletions src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs
Expand Up @@ -7,10 +7,9 @@ use std::pin::Pin;
type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
// ^^^^^^^^^ This would come from the `futures` crate in real code.

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

fn main() {}
33 changes: 13 additions & 20 deletions src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
@@ -1,26 +1,19 @@
error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:11:5
--> $DIR/expected-boxed-future-isnt-pinned.rs:12:5
|
LL | fn foo() -> BoxFuture<'static, i32> {
| ----------------------- expected `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>` because of return type
LL | / async {
LL | | 42
LL | | }
| |_____^ expected struct `std::pin::Pin`, found opaque type
|
::: $SRC_DIR/libstd/future.rs:LL:COL
|
LL | pub fn from_generator<T: Generator<Yield = ()>>(x: T) -> impl Future<Output = T::Return> {
| ------------------------------- the found opaque type
|
= note: expected struct `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>`
found opaque type `impl std::future::Future`
help: you need to pin and box this expression
|
LL | Box::pin(async {
LL | 42
LL | })
LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
| - this type parameter ----------------------- expected `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>` because of return type
LL | // We could instead use an `async` block, but this way we have no std spans.
LL | x
| ^
| |
| expected struct `std::pin::Pin`, found type parameter `F`
| help: you need to pin and box this expression: `Box::pin(x)`
|
= note: expected struct `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = i32> + std::marker::Send + 'static)>>`
found type parameter `F`
= help: type parameters must be constrained to match other types
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters

error: aborting due to previous error

Expand Down

0 comments on commit a852fb7

Please sign in to comment.