From a852fb74131af7473bafb03d0f3994a0e9f597d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 11 Feb 2020 17:35:04 -0800 Subject: [PATCH] Remove std lib `Span` from expected boxed future test --- .../expected-boxed-future-isnt-pinned.fixed | 7 ++-- .../expected-boxed-future-isnt-pinned.rs | 7 ++-- .../expected-boxed-future-isnt-pinned.stderr | 33 ++++++++----------- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.fixed b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.fixed index bddfd3ac9ccf0..9c68de7bacec6 100644 --- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.fixed +++ b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.fixed @@ -7,10 +7,9 @@ use std::pin::Pin; type BoxFuture<'a, T> = Pin + 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 + 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() {} diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs index 51818d6ae8f69..0b5200fc25ca0 100644 --- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs +++ b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs @@ -7,10 +7,9 @@ use std::pin::Pin; type BoxFuture<'a, T> = Pin + Send + 'a>>; // ^^^^^^^^^ This would come from the `futures` crate in real code. -fn foo() -> BoxFuture<'static, i32> { - async { //~ ERROR mismatched types - 42 - } +fn foo + 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() {} diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr index 5e6f5c13b7a60..5e54fc246a20f 100644 --- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr +++ b/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::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>(x: T) -> impl Future { - | ------------------------------- the found opaque type - | - = note: expected struct `std::pin::Pin + 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 + Send + 'static>(x: F) -> BoxFuture<'static, i32> { + | - this type parameter ----------------------- expected `std::pin::Pin + 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::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