forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#83689 - estebank:cool-bears-hot-tip, r=davi…
…dtwco Add more info for common trait resolution and async/await errors * Suggest `Pin::new`/`Box::new`/`Arc::new`/`Box::pin` in more cases * Point at `impl` and type defs introducing requirements on E0277
Showing
57 changed files
with
677 additions
and
162 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use std::{ | ||
future::Future, | ||
pin::Pin, | ||
marker::Unpin, | ||
task::{Context, Poll}, | ||
}; | ||
|
||
struct Sleep(std::marker::PhantomPinned); | ||
|
||
impl Future for Sleep { | ||
type Output = (); | ||
|
||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
Poll::Ready(()) | ||
} | ||
} | ||
|
||
impl Drop for Sleep { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
fn sleep() -> Sleep { | ||
Sleep(std::marker::PhantomPinned) | ||
} | ||
|
||
|
||
struct MyFuture { | ||
sleep: Sleep, | ||
} | ||
|
||
impl MyFuture { | ||
fn new() -> Self { | ||
Self { | ||
sleep: sleep(), | ||
} | ||
} | ||
} | ||
|
||
impl Future for MyFuture { | ||
type Output = (); | ||
|
||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
Pin::new(&mut self.sleep).poll(cx) | ||
//~^ ERROR `PhantomPinned` cannot be unpinned | ||
} | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0277]: `PhantomPinned` cannot be unpinned | ||
--> $DIR/pin-needed-to-poll-2.rs:43:9 | ||
| | ||
LL | Pin::new(&mut self.sleep).poll(cx) | ||
| ^^^^^^^^ within `Sleep`, the trait `Unpin` is not implemented for `PhantomPinned` | ||
| | ||
= note: consider using `Box::pin` | ||
note: required because it appears within the type `Sleep` | ||
--> $DIR/pin-needed-to-poll-2.rs:8:8 | ||
| | ||
LL | struct Sleep(std::marker::PhantomPinned); | ||
| ^^^^^ | ||
= note: required by `Pin::<P>::new` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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
Oops, something went wrong.