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

Suggest borrowing on fn argument that is impl AsRef #124599

Merged
merged 1 commit into from
Jul 12, 2024

Commits on May 9, 2024

  1. Suggest borrowing on fn argument that is impl AsRef

    When encountering a move conflict, on an expression that is `!Copy` passed as an argument to an `fn` that is `impl AsRef`, suggest borrowing the expression.
    
    ```
    error[E0382]: use of moved value: `bar`
      --> f204.rs:14:15
       |
    12 |     let bar = Bar;
       |         --- move occurs because `bar` has type `Bar`, which does not implement the `Copy` trait
    13 |     foo(bar);
       |         --- value moved here
    14 |     let baa = bar;
       |               ^^^ value used here after move
       |
    help: borrow the value to avoid moving it
       |
    13 |     foo(&bar);
       |         +
    ```
    
    Fix rust-lang#41708
    estebank committed May 9, 2024
    Configuration menu
    Copy the full SHA
    2df4f7d View commit details
    Browse the repository at this point in the history