Commit Graph

16326 Commits

Author SHA1 Message Date
Allan Brondum Rasmussen
bce3b63700 check reference is a NameRef (and not Name) 2022-12-02 23:50:39 +01:00
Jonas Schievink
335cb26050 Version the inlay hint resolve data 2022-11-29 19:20:32 +01:00
Jonas Schievink
b65b02fd97 Fix signature help not showing up when cursor is between )) or >> 2022-11-29 18:50:21 +01:00
Wilco Kusee
16bf32fcdd Update Chalk to version 87 2022-11-29 15:25:09 +01:00
bors
acd06de16a Auto merge of #13690 - Crauzer:vararg-type, r=Veykril
feat: Implement vararg parameter type inference

This PR implements the "collection" of the `va_list` type into the function parameter types list.
2022-11-29 07:55:57 +00:00
bors
3769cc35fa Auto merge of #13686 - MariaSolOs:test-lenses, r=Veykril
Don't show runnable code lenses in libraries outside of the workspace

Addresses #13664. For now I'm just disabling runnable code lenses since the ones that display the number of references and implementations do work correctly with external code.

Also made a tiny TypeScript change to use the typed `sendNotification` overload.
2022-11-29 07:42:35 +00:00
Maria José Solano
9914d30450 Fix formatting 2022-11-28 19:10:16 -08:00
Crauzer
b3bd5a471e implement vararg type collection from function params 2022-11-29 00:32:13 +01:00
Maria José Solano
2174aca8f8 Check for workspace root in runnable codelens 2022-11-27 10:07:09 -08:00
bors
6d61be8e65 Auto merge of #13681 - lowr:fix/extract-function-tail-expr, r=Veykril
fix: check tail expressions more precisely in `extract_function`

Fixes #13620

When extracting expressions with control flows into a function, we can avoid wrapping tail expressions in `Option` or `Result` when they are also tail expressions of the container we're extracting from (see #7840, #9773). This is controlled by `ContainerInfo::is_in_tail`, but we've been computing it by checking if the tail expression of the range to extract is contained in the container's syntactically last expression, which may be a block that contains both tail and non-tail expressions (e.g. in #13620, the range to be extracted is not a tail expression but we set the flag to true).

This PR tries to compute the flag as precise as possible by utilizing `for_each_tail_expr()` (and also moves the flag to `Function` struct as it's more of a property of the function to be extracted than of the container).
2022-11-27 12:18:42 +00:00
bors
34e2bc6a54 Auto merge of #13611 - yue4u:fix/completion-after-colon, r=yue4u
fix: filter unnecessary completions after colon

close #13597
related: #10173

This PR also happens to fix two extra issues:

1. The test case in https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-completion/src/tests/attribute.rs#L778-L801 was never triggered in previous behavior.

after:

https://user-images.githubusercontent.com/26110087/201476995-56adf955-0fa7-4f75-ab32-28a8e6cb9504.mp4

<del>
2. completions were triggered even in invalid paths, like

```rust
fn main() {
    core:::::$0
}
```

```rust
#[:::::$0]
struct X;
```

</del>

only `:::` is excluded as discussed in https://github.com/rust-lang/rust-analyzer/pull/13611#discussion_r1031845205
2022-11-26 17:55:00 +00:00
yue4u
1ca5cb7ed9 fix: also exclude 2 coloncolon in a row 2022-11-27 02:39:38 +09:00
yue4u
e1de04d60c fix: only special casing 3 colon in a row 2022-11-27 01:53:45 +09:00
Ryo Yoshida
8e03f18e37
fix: check if range contains tail expression 2022-11-27 00:31:02 +09:00
Ryo Yoshida
822c61f559
refactor: remove unnecessary stuff 2022-11-27 00:01:16 +09:00
Lukas Wirth
7bf2a25dfe Encode the variants of HirFileId in a u32 with MSB as the tag 2022-11-25 23:28:35 +01:00
bors
b651646510 Auto merge of #13676 - fasterthanlime:subtree-fix, r=Veykril
Mega-sync from `rust-lang/rust`

This essentially implements `@oli-obk's` suggestion here https://github.com/rust-lang/rust-analyzer/pull/13459#issuecomment-1297285607, with `@eddyb's` help.

This PR is equivalent to 14 syncs (back and forth) between `rust-lang/rust` and `rust-lang/rust-analyzer`.

Working from this list (from bottom to top):

```
(x) a2a1d9954 ⬆️ rust-analyzer
(x) 79923c382 ⬆️ rust-analyzer
(x) c60b1f641 ⬆️ rust-analyzer
(x) 8807fc4cc ⬆️ rust-analyzer
(x) a99a48e78 ⬆️ rust-analyzer
(x) 4f55ebbd4 ⬆️ rust-analyzer
(x) f5fde4df4 ⬆️ rust-analyzer
(x) 459bbb422 ⬆️ rust-analyzer
(x) 65e1dc4d9 ⬆️ rust-analyzer
(x) 3e358a682 ⬆️ rust-analyzer
(x) 31519bb39 ⬆️ rust-analyzer
(x) 8231fee46 ⬆️ rust-analyzer
(x) 22c8c9c40 ⬆️ rust-analyzer
(x) 9d2cb42a4 ⬆️ rust-analyzer
```

(This listed was assembled by doing a `git subtree push`, which made a branch, and looking at the new commits in that branch, picking only those that were `⬆️ rust-analyzer` commits)

We used the following commands to simulate merges in both directions:

```shell
TO_MERGE=22c8c9c40 # taken from the list above, bottom to top
git merge --no-edit --no-ff $TO_MERGE
git merge --no-edit --no-ff $(git -C ../rust log --pretty=format:'%cN | %s | %ad => %P' | rg -m1 -F "$(git show --no-patch --pretty=format:%ad $TO_MERGE)" | tee /dev/stderr | rg '.* => \S+ (\S+)$' --replace '$1')
```

We encountered no merge conflicts that Git wasn't able to solve by doing it this way.

Here's what the commit graph looks like (as shown in the Git Lens VSCode extension):

<img width="1345" alt="image" src="https://user-images.githubusercontent.com/7998310/203984523-7c1a690a-8224-416c-8015-ed6e49667066.png">

This PR closes #13459

## Does this unbreak `rust->ra` syncs?

Yes, here's how we tried:

In `rust-analyzer`:

  * check out `subtree-fix` (this PR's branch)
  * make a new branch off of it: `git checkout -b subtree-fix-merge-test`
  * simulate this PR getting merged with `git merge master`

In `rust`:

  * pull latest master
  * make a new branch: `git checkout -b test-change`
  * mess with rust-analyzer (I added a comment to `src/tools/rust-analyzer/Cargo.toml`)
  * commit
  * run `git subtree push -P src/tools/rust-analyzer ra-local final-sync` (this follows the [Clippy sync guide](https://doc.rust-lang.org/nightly/clippy/development/infrastructure/sync.html))

This created a `final-sync` branch in `rust-analyzer`.

In `rust-analyzer`:

  * `git merge --no-ff final-sync` (this follows the [Clippy sync guide](https://doc.rust-lang.org/nightly/clippy/development/infrastructure/sync.html))

Now `git log` in `rust-analyzer` shows this:

```
commit 460128387e46ddfc2b95921b2d7f6e913a3d2b9f (HEAD -> subtree-fix-merge-test)
Merge: 0513fc02a 9ce6a734f
Author: Amos Wenger <amoswenger@gmail.com>
Date:   Fri Nov 25 13:28:24 2022 +0100

    Merge branch 'final-sync' into subtree-fix-merge-test

commit 0513fc02a08ea9de952983624bd0a00e98044b36
Merge: 38c98d1ff 6918009fe
Author: Amos Wenger <amoswenger@gmail.com>
Date:   Fri Nov 25 13:28:02 2022 +0100

    Merge branch 'master' into subtree-fix-merge-test

commit 9ce6a734f37ef8e53689f1c6f427a9efafe846bd (final-sync)
Author: Amos Wenger <amoswenger@gmail.com>
Date:   Fri Nov 25 13:26:26 2022 +0100

    Mess with rust-analyzer just for fun
```

And `git diff 0513fc02a08ea9de952983624bd0a00e98044b36` shows this:

```patch
diff --git a/Cargo.toml b/Cargo.toml
index 286ef1e7d..c9e24cd19 100644
--- a/Cargo.toml
+++ b/Cargo.toml
`@@` -32,3 +32,5 `@@` debug = 0
 # ungrammar = { path = "../ungrammar" }

 # salsa = { path = "../salsa" }
+
+# lol, hi
```

## Does this unbreak `ra->rust` syncs?

Yes, here's how we tried.

From `rust`:

  * `git checkout -b sync-from-ra`
  * `git subtree pull -P src/tools/rust-analyzer ra-local subtree-fix-merge-test` (this is adapted from the [Clippy sync guide](https://doc.rust-lang.org/nightly/clippy/development/infrastructure/sync.html#performing-the-sync-from-clippy-to-rust-langrust), you would normally use `ra-upstream master` but we're simulating things here)

A commit editor pops up, there was no merge conflicts.

## How do we prevent this from happening again?

Like `@bjorn3` said in https://github.com/rust-lang/rust-analyzer/pull/13459#issuecomment-1293587848

> Whenever syncing from rust-analyzer -> rust you have to immediately sync the merge commit from rust -> rust-analyzer to prevent merge conflicts in the future.

But if we get it wrong again, at least now we have a not-so-painful way to fix it.
2022-11-25 21:27:46 +00:00
Amos Wenger
e96c0b1d53 Merge commit 'a2a1d9954' into HEAD 2022-11-25 13:06:31 +01:00
Amos Wenger
ae43043aab Merge commit '79923c382' into HEAD 2022-11-25 13:06:01 +01:00
Amos Wenger
e070dc5129 Merge commit 'c60b1f641' into HEAD 2022-11-25 13:05:26 +01:00
Amos Wenger
2f65294569 Merge commit '8807fc4cc' into HEAD 2022-11-25 13:04:50 +01:00
Amos Wenger
251b18ac6c Merge commit 'a99a48e78' into HEAD 2022-11-25 13:03:59 +01:00
Amos Wenger
e6540cff74 Merge commit '4f55ebbd4' into HEAD 2022-11-25 13:03:10 +01:00
Amos Wenger
969e25033b Merge commit 'f5fde4df4' into HEAD 2022-11-25 13:02:44 +01:00
Amos Wenger
dec148e6eb Merge commit '459bbb422' into HEAD 2022-11-25 13:02:06 +01:00
Amos Wenger
318fdacaf8 Merge commit '65e1dc4d9' into HEAD 2022-11-25 12:58:18 +01:00
Amos Wenger
ff2b468b55 Merge commit '3e358a682' into HEAD 2022-11-25 12:58:00 +01:00
Amos Wenger
6ac43ecf17 Merge commit '31519bb39' into HEAD 2022-11-25 12:57:38 +01:00
Amos Wenger
2374c0b368 Merge commit '8231fee46' into HEAD 2022-11-25 12:55:08 +01:00
Amos Wenger
db84a00d03 Merge commit '22c8c9c40' into HEAD 2022-11-25 12:13:34 +01:00
Amos Wenger
2566e06da1 Merge commit '8e38833c3674c1be7d81c6069c62e6ed52b18b27' into HEAD 2022-11-25 12:01:49 +01:00
bors
e668eca632 Auto merge of #13647 - nyz93:fix/tuple-to-named-struct, r=Veykril
fix: tuple to named struct inside macros

seems to fix #13634
2022-11-25 09:41:21 +00:00
bors
99daf23e11 Auto merge of #13671 - Veykril:goto-decl, r=Veykril
Improve goto declaration

Closes https://github.com/rust-lang/rust-analyzer/issues/13599

- goto decl now goes to assoc items of trait declarations over the items of trait implementations
- goto decl now goes to the field declaration (opposed to goto def which shows both the field decl and binding created/local being used)
- also adds back the goto definition fallback that seems to have been dropped at some point.
2022-11-25 09:28:39 +00:00
Lukas Wirth
ae0bdffcc9 Go to declaration goes to field declaration in pattern and expression shorthands 2022-11-25 10:27:54 +01:00
Lukas Wirth
3c794a34da Go to declaration goes to assoc items of trait declarations 2022-11-25 10:27:49 +01:00
bors
6918009fea Auto merge of #13638 - DesmondWillowbrook:hover-rest-pat-mvp, r=Veykril
feat: adds hover hint to ".." in record pattern

Hovering on the "rest" pattern in struct destructuring,
```rust
struct Baz {
    a: u32,
    b: u32,
    c: u32,
    d: u32
}

let Baz { a, b, ..$0} = Baz { a: 1, b: 2, c: 3, d: 4 };
```
shows:

```
.., c: u32, d: u32
```

Currently only works with struct patterns.

![image](https://user-images.githubusercontent.com/51814158/202837115-f424cc26-c2d7-4027-8eea-eeb7749ad146.png)
2022-11-25 07:41:05 +00:00
Kartavya Vashishtha
a26aef9055
fix formatting 2022-11-25 12:22:06 +05:30
Kartavya Vashishtha
91e7624de0
add hover tests 2022-11-25 12:20:38 +05:30
Kartavya Vashishtha
e86d451484
fix token method call 2022-11-25 12:20:34 +05:30
Kartavya Vashishtha
132d5ffc7d
add back [] in hover documentation 2022-11-25 12:04:14 +05:30
Kartavya Vashishtha
f64feeb11a
Correct node traversal to look at parent instead
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-11-24 22:32:15 -08:00
bors
76e2e41121 Auto merge of #13652 - jhgg:hir-expand/fix-compile-error-expansion, r=Veykril
hir-expand: fix compile_error! expansion not unquoting strings

expanding `compile_error!` would not properly unquote strings, leading to quite ugly diagnostic messages:

![image](https://user-images.githubusercontent.com/5489149/202893481-2486ede8-c79a-4972-9713-416d6a704064.png)

this fixes it, using the conveniently placed `unquote_str` function, which now makes errors look like:

![image](https://user-images.githubusercontent.com/5489149/202893466-0763efad-9240-4d55-80a6-6c62000d5d2b.png)

additionally, using `unquote_str` has the cool side-effect of *also* handling raw strings, so this fixes a fixme too!
2022-11-24 21:00:48 +00:00
bors
5e3ad5ddf6 Auto merge of #13592 - MihailMihov:trait_impl_assist, r=Veykril
Add assist to generate trait impl's

resolves #13553

This pull request adds a `generate_trait_impl` assist, which generates trait impl's for a type. It is almost the same as the one to generate impl's and I also reduced the trigger range to only outside the `RecordFieldList`. Also moved all the tests into separate test functions. A few of the old tests seemed redundant, so I didn't port them.
2022-11-24 20:44:33 +00:00
bors
fbc0f7a771 Auto merge of #13669 - Veykril:jod-child, r=Veykril
Properly implement Drop for JodGroupChild
2022-11-24 20:31:38 +00:00
Lukas Wirth
c8b6fef70f Properly implement Drop for JodGroupChild 2022-11-24 21:30:15 +01:00
bors
e9f6087965 Auto merge of #13661 - iredelmeier:fix-null-checkonsave-target, r=jonas-schievink
Fix: Handle empty `checkOnSave/target` values

This fixes a regression introduced by #13290, in which failing to set `checkOnSave/target` (or `checkOnSave/targets`) would lead to an invalid config.

[Fixes #13660]
2022-11-24 15:52:27 +00:00
bors
63a676eedf Auto merge of #13576 - Bben01:supress_missing_impl_inside_block, r=jonas-schievink
Suppress "Implement default members" inside contained items

Fixes #13561
2022-11-24 15:16:36 +00:00
bors
81d26e730e Auto merge of #13667 - Veykril:detached-files-sysroot, r=Veykril
Handle sysroot config in detached-files workspaces
2022-11-24 09:21:44 +00:00
Lukas Wirth
2300c9de83 Handle sysroot config in detached-files workspaces 2022-11-24 10:21:19 +01:00
Laurențiu Nicola
a2a1d99545 ⬆️ rust-analyzer 2022-11-23 17:24:03 +02:00