Commit Graph

824 Commits

Author SHA1 Message Date
bors[bot]
2e33bf23c9
Merge #11204
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>
2022-01-05 22:47:30 +00:00
Lukas Wirth
2d33cdf188 fix: replace_qualified_name_with_use does not use full item path for replacements 2022-01-05 23:46:58 +01:00
bors[bot]
ada51f2ac4
Merge #11195 #11202
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 `&params` 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>
2022-01-05 21:30:50 +00:00
Lukas Wirth
b92ed115c1 fix: Fix apply_demorgan assist hanging for certain binary expressions 2022-01-05 22:30:19 +01:00
Jeroen Vannevel
035a373a6a
removed double matching 2022-01-05 21:16:24 +00:00
Jeroen Vannevel
771c87f890
no PathExpr arm 2022-01-05 21:12:09 +00:00
Jeroen Vannevel
8c0b848694
.clone() over .to_owned() 2022-01-05 21:10:03 +00:00
Jeroen Vannevel
2724b35490
less wordy ref_kind assignment 2022-01-05 21:08:46 +00:00
bors[bot]
149981fbfc
Merge #11200
11200: Always put a space after dyn in macro pretty-printing r=Veykril a=jplatte

Fixes #11100.

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-01-05 20:04:49 +00:00
Jonas Platte
f5b789b1dc
Add failing test case for issue 11100 2022-01-05 18:04:36 +01:00
Jeroen Vannevel
053ae2452c
removed trailing whitespace 2022-01-05 02:16:22 +00:00
Jeroen Vannevel
abab0154b6
comment 2022-01-05 01:48:57 +00:00
Jeroen Vannevel
fa0afb9576
additional test for a reference local (on top of mutable reference local) 2022-01-05 01:36:04 +00:00
Jeroen Vannevel
4c1a1b2570
failing test for a reference local 2022-01-05 01:27:15 +00:00
Jeroen Vannevel
cd5ad4e500
Don't include a ref if none was declared 2022-01-05 01:18:55 +00:00
Jeroen Vannevel
817f47828c
support ref params as well 2022-01-05 01:15:54 +00:00
Jeroen Vannevel
056e18fcbd
correctly handle mutable references 2022-01-05 01:03:27 +00:00
bors[bot]
ac3ea3e81c
Merge #11112
11112: Evaluate constants in array repeat expression r=HKalbasi a=HKalbasi

cc #8655 

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-01-04 21:51:37 +00:00
hkalbasi
75c2acae6e Evaluate constants in array repeat expression 2022-01-05 01:17:01 +03:30
Jeroen Vannevel
ec61abbe93 reduced the tests to their bare essence 2022-01-04 10:11:04 +00:00
Jeroen Vannevel
5beddf93e7 additional test without further usages 2022-01-04 02:12:53 +00:00
Jeroen Vannevel
95cabfd722 Correctly pass through mutable references when extracting a function 2022-01-04 01:48:08 +00:00
bors[bot]
7409880a07
Merge #11061
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>
2022-01-03 17:59:00 +00:00
Wang Ruochen
95145d5ab6
Update generated tests 2022-01-03 09:48:50 -08:00
Wang Ruochen
a19a32488d
Don't add pattern if there is a catch all afterwards 2022-01-03 09:38:45 -08:00
Dániel Buga
2e472bb746 Fix replace_match_with_if_let removing blocks with modifiers
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-03 14:07:34 +01:00
Kirill Bulatov
03291db801 Allow adding partially resolved types 2022-01-03 01:34:33 +02:00
Laurențiu Nicola
53ddf48df4 Avoid collect_vec from itertools 2022-01-02 12:06:14 +02:00
Laurențiu Nicola
fdf1136e79 Replace folds with for loops 2022-01-02 12:05:35 +02:00
Jeroen Vannevel
b04c4e76df formatting 2021-12-28 18:52:12 +00:00
Jeroen Vannevel
e299fd5475 turbo fish supports multiple type arguments 2021-12-28 18:41:34 +00:00
Aleksey Kladov
660cf34d8c dead code 2021-12-28 19:13:30 +03:00
Wang Ruochen
be5205170c
Update comment 2021-12-22 14:17:43 -08:00
Wang Ruochen
44edf63edd
Add pattern when there's no else branch 2021-12-22 10:18:37 -08:00
Wang Ruochen
2bd2960fda
Don't support if-let branches 2021-12-21 16:51:26 -08:00
Wang Ruochen
d0986cd96b
Move variables into the closure 2021-12-21 16:48:02 -08:00
Lukas Wirth
539b0c2582 fix: Fix inline local assist not working in let stmt initializer 2021-12-21 14:03:59 +01:00
Laurențiu Nicola
01143c6600 Fix typo in reformat number assist label 2021-12-21 09:45:20 +02:00
bors[bot]
f46731a230
Merge #11028
11028: Bump MSRV (1.57) r=Veykril a=iDawer

This bumps MSRV on all crates to 1.57 except `la-arena`

#10986 requires >=1.57 

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2021-12-20 13:45:35 +00:00
bors[bot]
2ca3834c9f
Merge #11062
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>
2021-12-20 09:14:38 +00:00
patrick-gu
76b50f14f7 Don't say "a reference to" for Copy types
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.
2021-12-19 17:28:31 -08:00
Wang Ruochen
71676ae89d
Support "move if to guard" for if else chains 2021-12-19 09:26:52 -08:00
ucrhh
b289f13c75 fix unwrap_block by removing double trimming 2021-12-18 23:19:53 +01:00
Aleksey Kladov
a022ad68c9 internal: move all the lexing to the parser crate 2021-12-18 17:20:38 +03:00
Laurențiu Nicola
6c799dac1e Fix some clippy lints 2021-12-17 17:46:20 +02:00
Laurențiu Nicola
8ad7c0439c Remove needless clones 2021-12-17 17:35:10 +02:00
Wang Ruochen
ee079561b1
Add comma for "move if to guard" 2021-12-15 15:26:24 -08:00
bors[bot]
4ec6bd6206
Merge #11017
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>
2021-12-15 23:04:51 +00:00
Wang Ruochen
e8d0742997
Add coverage marks 2021-12-15 14:44:47 -08:00
iDawer
676744be6e Bump MSRV (1.57) 2021-12-16 01:56:12 +05:00