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

Add "make mutable" diagnostic / quick fix for local variables #8449

Closed
jplatte opened this issue Apr 9, 2021 · 3 comments
Closed

Add "make mutable" diagnostic / quick fix for local variables #8449

jplatte opened this issue Apr 9, 2021 · 3 comments
Labels
A-diagnostics diagnostics / error reporting S-actionable Someone could pick this issue up and work on it right now

Comments

@jplatte
Copy link
Contributor

jplatte commented Apr 9, 2021

Example:

let foo = Vec::new();

loop {
    // other code
    foo.<|>
}

To reproduce:

  • Type pu => get Vec::push suggested
  • Accept suggestion => line changes to foo.push(value)

Desired outcome: let foo = Vec::new(); is changed to let mut foo = Vec::new(); when accepting the suggestion
Actual outcome: let foo = Vec::new(); is not changed

I would love if ra did this because that would require less jumping around the code.

@Veykril Veykril added A-completion autocompletion S-actionable Someone could pick this issue up and work on it right now labels Apr 9, 2021
@matklad
Copy link
Member

matklad commented Apr 27, 2021

I don't think completion is the right place for this. This should be a quick fix for the subsequent diagnostic instead.

@matklad matklad changed the title rust-analyzer should make local methods mutable when necessary for an autocompleted method call Add "make mutable" diagnostic / quick fix for local variables Apr 27, 2021
@Veykril Veykril added A-assists A-diagnostics diagnostics / error reporting and removed A-completion autocompletion A-assists labels Apr 27, 2021
@lnicola
Copy link
Member

lnicola commented Dec 21, 2021

#10658 has more info.

@HKalbasi
Copy link
Member

HKalbasi commented Jun 4, 2023

The diagnostic is implemented in #14232 so I'm going to close this issue. About auto inserting mut, I think we should have a general fix-on-format or fix-on-save for diagnostics.

@HKalbasi HKalbasi closed this as completed Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

5 participants