Skip to content

Commit 1a840e7

Browse files
committed
Add test for incorrect pinning suggestion
The following suggestion is incorrect, as it doesn't account for the binding: ``` 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<F> Future for FutureWrapper<F> | - 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); | ```
1 parent 8c4db85 commit 1a840e7

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use std::{
2+
future::Future,
3+
pin::Pin,
4+
task::{Context, Poll},
5+
};
6+
7+
8+
struct FutureWrapper<F> {
9+
fut: F,
10+
}
11+
12+
impl<F> Future for FutureWrapper<F>
13+
where
14+
F: Future,
15+
{
16+
type Output = F::Output;
17+
18+
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
19+
let res = self.fut.poll(cx);
20+
//~^ ERROR no method named `poll` found for type parameter `F` in the current scope
21+
res
22+
}
23+
}
24+
25+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0599]: no method named `poll` found for type parameter `F` in the current scope
2+
--> $DIR/pin-needed-to-poll-3.rs:19:28
3+
|
4+
LL | impl<F> Future for FutureWrapper<F>
5+
| - method `poll` not found for this type parameter
6+
...
7+
LL | let res = self.fut.poll(cx);
8+
| ^^^^ method not found in `F`
9+
|
10+
help: consider pinning the expression
11+
|
12+
LL ~ let res = let mut pinned = std::pin::pin!(self.fut);
13+
LL ~ pinned.as_mut().poll(cx);
14+
|
15+
16+
error: aborting due to 1 previous error
17+
18+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)