Remove std lib Span
from expected boxed future test
This commit is contained in:
parent
c39b04ea85
commit
a852fb7413
3 changed files with 19 additions and 28 deletions
|
@ -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,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() {}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue