Commit Graph

20960 Commits

Author SHA1 Message Date
Wang Ruochen
a19a32488d
Don't add pattern if there is a catch all afterwards 2022-01-03 09:38:45 -08:00
bors[bot]
b14af5cc6f
Merge #11115
11115: internal: refactor: avoid separate traversal in replace filter map next with find map r=Veykril a=rainy-me

fix: #7428

Co-authored-by: rainy-me <github@yue.coffee>
2022-01-03 16:00:05 +00:00
Lukas Wirth
19f1ff5c70 give resolve_derive_ident a more robust api 2022-01-03 16:00:45 +01:00
David Hotham
b7cabf1e44
fix: don't panic on seeing an unexpected offset 2022-01-03 14:49:47 +00:00
bors[bot]
1ba9a924d7
Merge #11180
11180: minor: add missing test r=matklad a=matklad

This test kills the following mutant:

diff --git a/crates/mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs
index 9d2b1da9a..055d9a733 100644
--- a/crates/mbe/src/tt_iter.rs
+++ b/crates/mbe/src/tt_iter.rs
`@@` -134,7 +134,7 `@@` impl<'a> TtIter<'a> {
         self.inner = self.inner.as_slice()[res.len()..].iter();
         let res = match res.len() {
             1 => Some(res[0].cloned()),
-            0 => None,
+            // 0 => None,
             _ => Some(tt::TokenTree::Subtree(tt::Subtree {
                 delimiter: None,
                 token_trees: res.into_iter().map(|it| it.cloned()).collect(),

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-03 14:22:37 +00:00
Aleksey Kladov
b688d84a4b minor: add missing test
This test kills the following mutant:

diff --git a/crates/mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs
index 9d2b1da9a..055d9a733 100644
--- a/crates/mbe/src/tt_iter.rs
+++ b/crates/mbe/src/tt_iter.rs
@@ -134,7 +134,7 @@ impl<'a> TtIter<'a> {
         self.inner = self.inner.as_slice()[res.len()..].iter();
         let res = match res.len() {
             1 => Some(res[0].cloned()),
-            0 => None,
+            // 0 => None,
             _ => Some(tt::TokenTree::Subtree(tt::Subtree {
                 delimiter: None,
                 token_trees: res.into_iter().map(|it| it.cloned()).collect(),
2022-01-03 17:21:43 +03:00
bors[bot]
120d76e0a3
Merge #11179
11179: minor: simplify mbe matcher r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-03 13:28:56 +00:00
Aleksey Kladov
303814189a simplify 2022-01-03 16:27:16 +03:00
Aleksey Kladov
966983c707 simplify 2022-01-03 16:22:41 +03:00
bors[bot]
29fc022d85
Merge #11178
11178: Fix replace_match_with_if_let removing unsafe blocks r=bugadani a=bugadani

If the assist encounters an unsafe block in one of the match arms, the assist generated intermediate code like the following:

```rust
if let Foo(_) = foo {
    <then branch>
} else unsafe { ... }
```

Which was then parsed back and the unsafe branch got completely removed, removing in invalid code output:

```rust
if let Foo(_) = foo {
    <then branch>
} else
```

This PR fixes this issue.

However, I'm sure there is a better, more general solution here, but I lack familiarity with rust-analyzer. `make::expr_if` looks like it expects a `BlockExpr` that, when printed, is wrapped in braces correctly, but I'm sure changing the display impl for an `unsafe` `BlockExpr` would have caused problems. I could have changed `make::expr_if` instead to special case unsafe blocks, but that would have meant some expressions getting wrapped by the caller (as previously), and some others by the function.

Co-authored-by: Dániel Buga <bugadani@gmail.com>
2022-01-03 13:09:15 +00: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
bors[bot]
8e9ccbf97a
Merge #11177
11177: internal: dont descend into comments r=Veykril a=jhgg

fixes #11176

Co-authored-by: Jake Heinz <jh@discordapp.com>
2022-01-03 02:03:03 +00:00
Jake Heinz
04decd5e6b internal: dont descend into comments 2022-01-03 01:53:58 +00:00
bors[bot]
abbc7e3a0e
Merge #11088
11088: closes #10446 hide type inlay hints r=Veykril a=Heinenen

Passes tests as described in #10446
Works for all happy cases, there may be some cases that I forgot as I am not that familiar with Rust and r-a (yet).

Co-authored-by: Heinenen <th.m.heinen@gmail.com>
2022-01-03 00:51:08 +00:00
bors[bot]
d89a4f0e93
Merge #11173
11173: Allow adding partially resolved types r=Veykril a=SomeoneToIgnore

Sometimes when writing something like `let foo = Arc::new(Mutex::new(CrazyGenerics::new(HashMap::new())))`, I want/have to specify an explicit type for the expression.
Using turbofish isn't very readable and not always appreciated by guidelines, so `let foo: T` has to be filled.

To ease that, the PR enables the `add_explicit_type` assist on types that contain unknown types and some generics.
Fully unresolved types, arrays with unknown types and other known cases behave the same.

`_` placeholder was chosen to replace an unknown type:

```rust
let foo = HashMap::new();
// after assist usage, turns into
let foo: HashMap<_, _> = HashMap::new();
```

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2022-01-03 00:40:30 +00:00
bors[bot]
df3d3d8a74
Merge #11175
11175: fix: Fix highlighting hack for self-params r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11174
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-03 00:32:31 +00:00
Lukas Wirth
087122ad1a fix: Fix highlighting hack for self-params 2022-01-03 01:32:03 +01:00
Kirill Bulatov
03291db801 Allow adding partially resolved types 2022-01-03 01:34:33 +02:00
Lukas Wirth
44b0fe8ec7 cleanup 2022-01-02 23:44:26 +01:00
Lukas Wirth
aeb5d64912 Implement ToDef for ast::Attr 2022-01-02 23:44:26 +01:00
Lukas Wirth
6b7b09d329 internal: Record unresolved derive invocations in hir 2022-01-02 23:44:23 +01:00
bors[bot]
989c06b25d
Merge #11171
11171: fix: Fix tool module classification not working correctly r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-02 22:15:30 +00:00
Lukas Wirth
762a3b3030 Fix tool module classification not working correctly 2022-01-02 23:14:18 +01:00
bors[bot]
35737eb896
Merge #11170
11170: minor: Cleanup syntax highlighting r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-02 21:24:07 +00:00
Lukas Wirth
19d894cdec minor: Cleanup syntax highlighting 2022-01-02 22:23:05 +01:00
bors[bot]
e1099aaa57
Merge #11169
11169: internal: Handle macro calls better in highlighting r=Veykril a=Veykril

Introduces a new semantic highlighting tag for the `!` character of macro calls.

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10962

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-02 18:27:16 +00:00
Lukas Wirth
22160c418b fix NameRefClass misclassifying proc-macros 2022-01-02 19:20:10 +01:00
Lukas Wirth
9eed85b171 fix syntactic highlighting for macros 2022-01-02 19:10:23 +01:00
Lukas Wirth
3a525c831f internal: Handle macro calls better in highlighting 2022-01-02 19:10:10 +01:00
bors[bot]
2e7170e07b
Merge #11166
11166: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-02 16:49:40 +00:00
Lukas Wirth
f31863b189 minor: Simplify 2022-01-02 17:37:16 +01:00
bors[bot]
367cd5ce9b
Merge #11168
11168: minor: drop dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-02 16:08:23 +00:00
Aleksey Kladov
3836b195dd minor: replace panics with types 2022-01-02 19:05:37 +03:00
Aleksey Kladov
174c439c56 minor: drop dead code 2022-01-02 19:03:38 +03:00
bors[bot]
6e3d135f7b
Merge #11167
11167: internal: check top level entry point invariants r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-02 15:50:57 +00:00
Aleksey Kladov
2e34a5e2e9 add empty input tests 2022-01-02 18:50:32 +03:00
Aleksey Kladov
c72908a201 more intuitive order 2022-01-02 18:46:01 +03:00
Aleksey Kladov
d846afdeef check top level entry point invariants 2022-01-02 18:41:32 +03:00
Aleksey Kladov
fa049d94d1 add top-level tests for expressions 2022-01-02 17:52:05 +03:00
bors[bot]
68013ee315
Merge #11165
11165: internal: start enforcing invariants for top-level entry points r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-02 14:46:05 +00:00
Aleksey Kladov
640cc27ff0 add top level tests for types 2022-01-02 17:45:18 +03:00
Aleksey Kladov
e78424846e enforce parsing invariant for patterns 2022-01-02 17:32:15 +03:00
bors[bot]
ddb420a86e
Merge #11164
11164: internal: more macro tests r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-02 14:19:07 +00:00
Aleksey Kladov
7989d567e2 internal: more macro tests 2022-01-02 17:18:21 +03:00
Aleksey Kladov
7de4b964a9 add test for macro items 2022-01-02 16:48:10 +03:00
bors[bot]
25dd65dae2
Merge #11163
11163: internal: start tests for top-level parser entry points r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-02 12:19:25 +00:00
Aleksey Kladov
bebfb83fd0 split prefix/top tests 2022-01-02 15:18:34 +03:00
Aleksey Kladov
2bd7c74706 add tests for macro statements 2022-01-02 15:17:32 +03:00
Aleksey Kladov
f2ea7853ee start top-level entry point tests 2022-01-02 15:15:04 +03:00
Aleksey Kladov
e366b3c730 minor: generalize 2022-01-02 15:01:20 +03:00