11204: fix: `replace_qualified_name_with_use` does not use full item path for replacements r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
11195: Correctly pass through reference modifiers when extracting a variable r=Veykril a=Vannevelj
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10034
This will parse the field expression and look at whether it is marked `&` or `&mut` and include a modifier if appropriate. The original issue only mentions `&mut params` but I've found that this issue also occurs for `&mut locals` as well as `¶ms` and `&locals` so I've also added tests for them.
I'd definitely be interested in hearing where I can make my code more idiomatic for Rust.
11202: fix: Fix `apply_demorgan` assist hanging for certain binary expressions r=Veykril a=Veykril
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10963
bors r+
Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
11061: Support "move if to guard" for if else chains r=weirane a=weirane
The idea is to first parse the if else chain into a vector of `(Condition, BlockExpr)`s until we reach an iflet branch, an else branch, or the end (the tail). Then add the match arms with guard for the vector, and add the tail with no if guard.
Because the whole original match arm is replaced and the generated code doesn't have redundent commas, I removed redundent commas in some test cases.
Closes#11033.
Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>
11062: fix: Don't say "a reference to" for `Copy` types in the generate getter assist r=Veykril a=patrick-gu
This changes the generate getter assist to not say "a reference to" in the documentation stub if the type is `Copy`, as the getter does not return a reference.
To determine whether the type is `Copy`, I have added an `is_copy` method to `ReferenceConversion`.
Co-authored-by: patrick-gu <55641350+patrick-gu@users.noreply.github.com>
This changes the generate getter assist to not say "a reference to" in the documentation stub if the type is Copy, as the getter does not return a reference.
11017: Support "move if to guard" with an else branch r=Veykril a=weirane
Support the assist `move_arm_cond_to_match_guard` when there is an else branch.
I have two questions:
1. How to indent the first line of a match arm? `matcharm.indent()` doesn't seem to work. so I hard coded four spaces here:
95a0de85d5/crates/ide_assists/src/handlers/move_guard.rs (L162-L163)
2. I find a little issue in the original implementation, this code
```rust
let y = match 92 {
x => {
if x == 0 {$0
false
}
}
_ => true,
};
```
will be transformed to
```rust
let y = match 92 {
x if x == 0 => false
_ => true,
};
```
a comma is missing after the `false`. Should I also fix that? Or this can go in a separate PR.
Closes#10997.
Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>