Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for existing bindings when suggesting pin!() #125684

Merged
merged 2 commits into from
Jun 12, 2024

Commits on May 28, 2024

  1. 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);
       |
    ```
    estebank committed May 28, 2024
    Configuration menu
    Copy the full SHA
    1a840e7 View commit details
    Browse the repository at this point in the history
  2. Account for existing bindings when suggesting pinning

    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.
    estebank committed May 28, 2024
    Configuration menu
    Copy the full SHA
    5585f31 View commit details
    Browse the repository at this point in the history