diff --git a/tests/ui/async-await/pin-needed-to-poll-3.rs b/tests/ui/async-await/pin-needed-to-poll-3.rs new file mode 100644 index 00000000000..11ba7d29aba --- /dev/null +++ b/tests/ui/async-await/pin-needed-to-poll-3.rs @@ -0,0 +1,25 @@ +use std::{ + future::Future, + pin::Pin, + task::{Context, Poll}, +}; + + +struct FutureWrapper { + fut: F, +} + +impl Future for FutureWrapper +where + F: Future, +{ + type Output = F::Output; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + let res = self.fut.poll(cx); + //~^ ERROR no method named `poll` found for type parameter `F` in the current scope + res + } +} + +fn main() {} diff --git a/tests/ui/async-await/pin-needed-to-poll-3.stderr b/tests/ui/async-await/pin-needed-to-poll-3.stderr new file mode 100644 index 00000000000..83a0808c4ec --- /dev/null +++ b/tests/ui/async-await/pin-needed-to-poll-3.stderr @@ -0,0 +1,18 @@ +error[E0599]: no method named `poll` found for type parameter `F` in the current scope + --> $DIR/pin-needed-to-poll-3.rs:19:28 + | +LL | impl Future for FutureWrapper + | - method `poll` not found for this type parameter +... +LL | let res = self.fut.poll(cx); + | ^^^^ method not found in `F` + | +help: consider pinning the expression + | +LL ~ let res = let mut pinned = std::pin::pin!(self.fut); +LL ~ pinned.as_mut().poll(cx); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`.