rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
0.3.1162-standalone (634cfe3 2022-08-07)
rustc version: (eg. output of rustc -V)
rustc 1.63.0 (4b91a6ea7 2022-08-08)
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTUP_HOME or CARGO_HOME)
None
When passing a reference to a function that is mutable, RA gives an assist Add reference here, which outputs incorrect code:
fn main() {
let mut a = 0;
foo(<|>&a);
}
fn foo(a: &mut i32) -> () {}
->
fn main() {
let mut a = 0;
foo(&mut &a);
}
fn foo(a: &mut i32) -> () {}
I looked at the relevant code, and it seems this can be fixed by checking if d.actual is a reference before suggesting the fix. We might also want to add an assist for fixing just the missing mut problem?
rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
0.3.1162-standalone (634cfe3 2022-08-07)
rustc version: (eg. output of
rustc -V)rustc 1.63.0 (4b91a6ea7 2022-08-08)
relevant settings: (eg. client settings, or environment variables like
CARGO,RUSTUP_HOMEorCARGO_HOME)None
When passing a reference to a function that is mutable, RA gives an assist
Add reference here, which outputs incorrect code:->
I looked at the relevant code, and it seems this can be fixed by checking if d.actual is a reference before suggesting the fix. We might also want to add an assist for fixing just the missing mut problem?