Move misplaced comment

This commit is contained in:
Tyler Mandry 2021-09-30 01:29:24 +00:00
parent 485ae9f2c0
commit 156c9222f5
2 changed files with 4 additions and 4 deletions

View File

@ -11,13 +11,13 @@ fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32>
x //~ ERROR mismatched types
}
// This case is still subpar:
// `Pin::new(x)`: store this in the heap by calling `Box::new`: `Box::new(x)`
// Should suggest changing the code from `Pin::new` to `Box::pin`.
fn bar<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
Box::new(x) //~ ERROR mismatched types
}
// This case is still subpar:
// `Pin::new(x)`: store this in the heap by calling `Box::new`: `Box::new(x)`
// Should suggest changing the code from `Pin::new` to `Box::pin`.
fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
Pin::new(x) //~ ERROR mismatched types
//~^ ERROR E0277

View File

@ -15,7 +15,7 @@ LL | Box::pin(x)
| +++++++++ +
error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:18:5
--> $DIR/expected-boxed-future-isnt-pinned.rs:15:5
|
LL | fn bar<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
| ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type