about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-02-11 17:35:04 -0800
committerEsteban Küber <esteban@kuber.com.ar>2020-02-12 15:13:04 -0800
commita852fb74131af7473bafb03d0f3994a0e9f597d5 (patch)
tree9f41a3e027dc493e578805a08400c29235e9c7a1
parentc39b04ea851b821359534b540c0babb97de24122 (diff)
downloadrust-a852fb74131af7473bafb03d0f3994a0e9f597d5.tar.gz
rust-a852fb74131af7473bafb03d0f3994a0e9f597d5.zip
Remove std lib `Span` from expected boxed future test
-rw-r--r--src/test/ui/suggestions/expected-boxed-future-isnt-pinned.fixed7
-rw-r--r--src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs7
-rw-r--r--src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr33
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 bddfd3ac9cc..9c68de7bace 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<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() {}
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 51818d6ae8f..0b5200fc25c 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<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() {}
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 5e6f5c13b7a..5e54fc246a2 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::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