forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#114654 - estebank:suggest-pin-macro, r=davi…
…dtwco Suggest `pin!()` instead of `Pin::new()` when appropriate When encountering a type that needs to be pinned but that is `!Unpin`, suggest using the `pin!()` macro. Fix rust-lang#57994.
- Loading branch information
Showing
7 changed files
with
105 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// edition: 2021 | ||
// run-rustfix | ||
#![allow(unused_must_use, dead_code)] | ||
|
||
use std::future::Future; | ||
fn foo() -> impl Future<Output=()> { | ||
async { } | ||
} | ||
|
||
fn bar(cx: &mut std::task::Context<'_>) { | ||
let fut = foo(); | ||
let mut pinned = std::pin::pin!(fut); | ||
pinned.as_mut().poll(cx); | ||
//~^ ERROR no method named `poll` found for opaque type `impl Future<Output = ()>` in the current scope [E0599] | ||
} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
// edition: 2021 | ||
// run-rustfix | ||
#![allow(unused_must_use, dead_code)] | ||
|
||
use std::future::Future; | ||
fn foo() -> impl Future<Output=()> { | ||
async { } | ||
} | ||
|
||
fn main() { | ||
fn bar(cx: &mut std::task::Context<'_>) { | ||
let fut = foo(); | ||
fut.poll(); | ||
fut.poll(cx); | ||
//~^ ERROR no method named `poll` found for opaque type `impl Future<Output = ()>` in the current scope [E0599] | ||
} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters