Account for existing bindings when suggesting `pin!()` by estebank · Pull Request #125684 · rust-lang/rust

added 2 commits

May 28, 2024 20:05
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);
   |
```
When we encounter a situation where we'd suggest `pin!()`, we now account for that expression exising as part of an assignment and provide an appropriate suggestion:

```
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 mut pinned = std::pin::pin!(self.fut);
LL ~         let res = pinned.as_mut().poll(cx);
   |
```

Fix rust-lang#125661.

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

May 28, 2024

mu001999

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Jun 11, 2024

jieyouxu added a commit to jieyouxu/rust that referenced this pull request

Jun 11, 2024
…, r=pnkfelix

Account for existing bindings when suggesting `pin!()`

When we encounter a situation where we'd suggest `pin!()`, we now account for that expression existing as part of an assignment and provide an appropriate suggestion:

```
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 mut pinned = std::pin::pin!(self.fut);
LL ~         let res = pinned.as_mut().poll(cx);
   |
```

Fix rust-lang#125661.

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jun 11, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#115974 (Split core's PanicInfo and std's PanicInfo)
 - rust-lang#125659 (Remove usage of `isize` in example)
 - rust-lang#125669 (CI: Update riscv64gc-linux job to Ubuntu 22.04, rename to riscv64gc-gnu)
 - rust-lang#125684 (Account for existing bindings when suggesting `pin!()`)
 - rust-lang#126055 (Expand list of trait implementers in E0277 when calling rustc with --verbose)
 - rust-lang#126174 (Migrate `tests/run-make/prefer-dylib` to `rmake.rs`)
 - rust-lang#126256 (Add {{target}} substitution to compiletest)

r? `@ghost`
`@rustbot` modify labels: rollup

jieyouxu added a commit to jieyouxu/rust that referenced this pull request

Jun 11, 2024
…, r=pnkfelix

Account for existing bindings when suggesting `pin!()`

When we encounter a situation where we'd suggest `pin!()`, we now account for that expression existing as part of an assignment and provide an appropriate suggestion:

```
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 mut pinned = std::pin::pin!(self.fut);
LL ~         let res = pinned.as_mut().poll(cx);
   |
```

Fix rust-lang#125661.

This was referenced

Jun 11, 2024

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jun 11, 2024
Rollup of 6 pull requests

Successful merges:

 - rust-lang#115974 (Split core's PanicInfo and std's PanicInfo)
 - rust-lang#125659 (Remove usage of `isize` in example)
 - rust-lang#125669 (CI: Update riscv64gc-linux job to Ubuntu 22.04, rename to riscv64gc-gnu)
 - rust-lang#125684 (Account for existing bindings when suggesting `pin!()`)
 - rust-lang#126055 (Expand list of trait implementers in E0277 when calling rustc with --verbose)
 - rust-lang#126174 (Migrate `tests/run-make/prefer-dylib` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Jun 12, 2024
Rollup merge of rust-lang#125684 - estebank:pin-to-binding-suggestion, r=pnkfelix

Account for existing bindings when suggesting `pin!()`

When we encounter a situation where we'd suggest `pin!()`, we now account for that expression existing as part of an assignment and provide an appropriate suggestion:

```
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 mut pinned = std::pin::pin!(self.fut);
LL ~         let res = pinned.as_mut().poll(cx);
   |
```

Fix rust-lang#125661.