Commit Graph

28249 Commits

Author SHA1 Message Date
bors
1179c3ee83 Auto merge of #16639 - alibektas:13529/config_restruct, r=Veykril
internal : redesign rust-analyzer::config

This PR aims to cover the infrastructural requirements for the `rust-analyzer.toml` ( #13529 ) issue. This means, that

1. We no longer have a single config base. The once single `ConfigData` has been divided into 4 : A tree of `.ratoml` files, a set of configs coming from the client ( this is what was called before the `CrateData` except that now values do not default to anything when they are not defined) , a set of configs that will reflect what the contents of a `ratoml` file defined in user's config directory ( e.g `~/.config/rust-analyzer/.rust-analyzer.toml` and finally a tree root that is populated by default values only.
2. Configs have also been divided into 3 different blocks : `global` , `local` , `client`. The current status of a config may change until #13529 got merged.

Once again many thanks to `@cormacrelf` for doing all the serde work.
2024-04-16 07:52:07 +00:00
bors
e64610dbbe Auto merge of #17037 - davidsemakula:token-set-collisions, r=Veykril
internal: improve `TokenSet` implementation and add reserved keywords

The current `TokenSet` type represents "A bit-set of `SyntaxKind`s" as a newtype `u128`.
Internally, the flag for each `SyntaxKind` variant in the bit-set is set as the n-th LSB (least significant bit) via a bit-wise left shift operation, where n is the discriminant.

Edit: This is problematic because there's currently ~121 token `SyntaxKind`s, so adding new token kinds for missing reserved keywords increases the number of token `SyntaxKind`s above 128, thus making this ["mask"](7a8374c162/crates/parser/src/token_set.rs (L31-L33)) operation overflow.
~~This is problematic because there's currently 266 SyntaxKinds, so this ["mask"](7a8374c162/crates/parser/src/token_set.rs (L31-L33)) operation silently overflows in release mode.~~
~~This leads to a single flag/bit in the bit-set being shared by multiple `SyntaxKind`s~~.

This PR:
- Changes the wrapped type for `TokenSet` from `u128` to `[u64; 3]` ~~`[u*; N]` (currently `[u16; 17]`) where `u*` can be any desirable unsigned integer type and `N` is the minimum array length needed to represent all token `SyntaxKind`s without any collisions~~.
- Edit: Add assertion that `TokenSet`s only include token `SyntaxKind`s
- Edit: Add ~7 missing [reserved keywords](https://doc.rust-lang.org/stable/reference/keywords.html#reserved-keywords)
- ~~Moves the definition of the `TokenSet` type to grammar codegen in xtask, so that `N` is adjusted automatically (depending on the chosen `u*` "base" type) when new `SyntaxKind`s are added~~.
- ~~Updates the `token_set_works_for_tokens` unit test to include the `__LAST` `SyntaxKind` as a way of catching overflows in tests.~~

~~Currently `u16` is arbitrarily chosen as the `u*` "base" type mostly because it strikes a good balance (IMO) between unused bits and readability of the generated `TokenSet` code (especially the [`union` method](7a8374c162/crates/parser/src/token_set.rs (L26-L28))), but I'm open to other suggestions or a better methodology for choosing `u*` type.~~

~~I considered using a third-party crate for the bit-set, but a direct implementation seems simple enough without adding any new dependencies. I'm not strongly opposed to using a third-party crate though, if that's preferred.~~

~~Finally, I haven't had the chance to review issues, to figure out if there are any parser issues caused by collisions due the current implementation that may be fixed by this PR - I just stumbled upon the issue while adding "new" keywords to solve #16858~~

Edit: fixes #16858
2024-04-16 07:00:12 +00:00
bors
dcbb27aab6 Auto merge of #17081 - davidbarsky:david/revert-17073, r=Veykril
Revert #17073: Better inline preview for postfix completion

See discussion on https://github.com/rust-lang/rust-analyzer/issues/17077, but I strongly suspect that the changes to the `TextEdit` ranges caused VS Code's autocomplete to prefer the snippets over method completions. I explain why I think that [here](https://github.com/rust-lang/rust-analyzer/issues/17077#issuecomment-2057908447).
2024-04-16 05:26:34 +00:00
David Barsky
ab8c112573 Revert "Auto merge of #17073 - roife:better-inline-preview, r=Veykril"
af728741de
2024-04-15 18:24:15 -04:00
bors
90cfa8035f Auto merge of #17078 - Veykril:diags-perf, r=Veykril
internal: Improve diagnostics performance
2024-04-15 20:17:26 +00:00
Lukas Wirth
531a270d91 Generally optimize diagnostics performance 2024-04-15 22:15:41 +02:00
Lukas Wirth
94e38261b3 Optimize exhaustiveness checking perf a bit 2024-04-15 19:35:48 +02:00
bors
b223860c0e Auto merge of #17074 - Veykril:hl, r=Veykril
Add Static and Const highlighting token types
2024-04-15 15:19:56 +00:00
Lukas Wirth
597c293a69 Adjust package.json semantic highlighting items 2024-04-15 17:00:03 +02:00
Lukas Wirth
6b98e55dbb Add Static and Const highlighting token types 2024-04-15 16:54:17 +02:00
bors
af728741de Auto merge of #17073 - roife:better-inline-preview, r=Veykril
Better inline preview for postfix completion

Better inline preview for postfix completion, a proper implementation of c5686c8941.

Here editors may filter completion item with the text within `delete_range`, so we need to include the `receiver text` in the `lookup` (aka `FilterText` in LSP spec) for editors to find the completion item. (See https://github.com/rust-lang/rust-analyzer/issues/17036#issuecomment-2056614180, Thanks to [pascalkuthe](https://github.com/pascalkuthe))
2024-04-15 14:33:38 +00:00
davidsemakula
69fe457cb5 internal: simplify TokenSet implementation 2024-04-15 17:33:09 +03:00
roife
8db1c64268 tests: fix tests for postfix 2024-04-15 22:21:15 +08:00
roife
76a8a976f3 fix: better inline preview for postfix completion 2024-04-15 22:21:06 +08:00
bors
c0371309b4 Auto merge of #17072 - Veykril:hir-ty-display, r=Veykril
internal: Use `hir_fmt_args` everywhere in `hir_ty::display`
2024-04-15 14:19:04 +00:00
Lukas Wirth
91659da5a6 internal: Use hir_fmt_args everywhere in hir_ty::display 2024-04-15 16:17:29 +02:00
bors
2e7059ca58 Auto merge of #16877 - Veykril:stackoverflow, r=Veykril
fix: Fix `impl Trait<Self>` causing stackoverflows

Fixes https://github.com/rust-lang/rust-analyzer/issues/15646
2024-04-15 13:47:46 +00:00
Lukas Wirth
1915980031 fix: Fix impl Trait<Self> causing stackoverflows 2024-04-15 15:41:20 +02:00
bors
40bb8f3272 Auto merge of #16813 - wyatt-herkamp:to-from-cfg_attr-assist, r=Veykril
Wrap/Unwrap cfg_attr

https://github.com/rust-lang/rust-analyzer/assets/11785959/f5f1bb71-22e7-438b-9a22-65ebab1b362d

https://github.com/rust-lang/rust-analyzer/assets/11785959/36933a4e-0000-455a-abe3-af774cd854d0

## TODO
- [x] Add Tests
- [x] Wrap derive elements

Closes #13965
2024-04-15 12:56:55 +00:00
Lukas Wirth
60d3a7320e Differentiate between full configs and toml only config groupings 2024-04-15 14:16:43 +02:00
Ali Bektas
67d8d2d4a0 Make ConfigData Ser and TOML De
This commit makes rust-analyzer::config module TOML ser and de.

Co-Authored-By: Cormac Relf <web@cormacrelf.net>
2024-04-15 14:14:23 +02:00
davidsemakula
8e459125df internal: add auto-import assist tests for raw identifiers 2024-04-15 15:06:26 +03:00
davidsemakula
e326b634d1 internal: add reserved keywords 2024-04-15 15:06:26 +03:00
davidsemakula
89779ca55e internal: improve TokenSet implementation 2024-04-15 15:06:26 +03:00
bors
2cbc2841d8 Auto merge of #17070 - Veykril:simplify, r=Veykril
internal: Remove unnecessay `GlobalState::send_hint_refresh_query` field
2024-04-15 09:06:51 +00:00
Lukas Wirth
a37c7208b0 internal: Remove unnecessay GlobalState::send_hint_refresh_query field 2024-04-15 11:05:09 +02:00
bors
d80df712e7 Auto merge of #17069 - lnicola:fix-skip-array-dispatch, r=lnicola
minor: Fix `rustc_skip_array_during_method_dispatch` edition check

CC #16450
2024-04-15 05:56:22 +00:00
Laurențiu Nicola
f5e4eb2ef9 Fix rustc_skip_array_during_method_dispatch edition check 2024-04-15 08:54:07 +03:00
bors
5dbe3fe75c Auto merge of #17065 - Veykril:edition-parse-mac, r=Veykril
internal: Thread edition through to parsing/tt-to-syntax-tree routines for macros

Follow up to https://github.com/rust-lang/rust-analyzer/pull/16450, cc https://github.com/rust-lang/rust-analyzer/issues/16324
2024-04-14 14:13:11 +00:00
Lukas Wirth
a483d3bc37 internal: Thread edition through to parsing/tt-to-syntax-tree routines for macros 2024-04-14 16:02:38 +02:00
bors
74cef6d79b Auto merge of #16450 - Urhengulas:edition-aware-parser, r=Veykril
internal: Prepare parser interface for editions
2024-04-14 13:34:12 +00:00
Lukas Wirth
83370fe5d7 Use Edition::CURRENT 2024-04-14 15:30:29 +02:00
Lukas Wirth
9c75e9fa7d Deduplicate Edition enum 2024-04-14 15:29:01 +02:00
Johann Hemmann
e7852803c5 Mark edition field as unused 2024-04-14 15:11:38 +02:00
Johann Hemmann
2cf5d8811a Raise edition one more level 2024-04-14 15:11:33 +02:00
Johann Hemmann
454e481422 Add edition to all parse functions of the parser crate 2024-04-14 15:07:43 +02:00
Johann Hemmann
392538c830 Add edition to parser struct 2024-04-14 15:06:09 +02:00
bors
f3c7bd0c90 Auto merge of #17064 - Veykril:inlay-hints-fix, r=Veykril
minor: Carry inlay hint resolve hash as a string
2024-04-14 10:27:40 +00:00
Lukas Wirth
189aba7943 minor: Carry inlay hint resolve hash as a string 2024-04-14 10:55:20 +02:00
bors
7dad0a231e Auto merge of #17063 - Veykril:inlay-hints-fix, r=Veykril
fix: Fix inlay hint resolution being broken

So, things broke because we now store a hash (u64) in the resolution payload, but javascript and hence JSON only support integers of up to 53 bits (anything beyond gets truncated in various ways) which caused almost all hashes to always differ when resolving them. This masks the hash to 53 bits to work around that.

Fixes https://github.com/rust-lang/rust-analyzer/issues/16962
2024-04-14 06:28:40 +00:00
Lukas Wirth
2c5c12acfe fix: Fix inlay hint resolution being broken 2024-04-14 08:27:24 +02:00
bors
beb205f347 Auto merge of #17062 - Veykril:disable-unlinked-file-popup, r=Veykril
Temporarily disable unlinked file popup

Not gonna look into this until the next release, so I'd rather disable it for the time being
2024-04-13 22:55:03 +00:00
Lukas Wirth
ff9ebc747d Temporarily disable unlinked file popup 2024-04-13 22:45:22 +02:00
bors
773b4a5ac7 Auto merge of #17019 - Wilfred:source_root_prefixes, r=Veykril
fix: VFS should not confuse paths with source roots that have the same prefix

Previously, the VFS would assign paths to the source root that had the longest string prefix match. This would break when we had source roots in subdirectories:

```
/foo
/foo/bar
```

Given a file `/foo/bar_baz.rs`, we would attribute it to the `/foo/bar` source root, which is wrong.

As a result, we would attribute paths to the wrong crate when a crate was in a subdirectory of another one. This is more common in larger monorepos, but could occur in any Rust project.

Fix this in the VFS, and add a test.
2024-04-13 20:30:08 +00:00
bors
9b1946250f Auto merge of #17054 - roife:fix-issue-17036, r=Veykril
Revert "fix: set the right postfix snippets competion source range"

This reverts commit c5686c8941.

Fix #17036. See https://github.com/rust-lang/rust-analyzer/issues/17036#issuecomment-2050185641
2024-04-13 19:34:45 +00:00
bors
e1d7ce71ae Auto merge of #17051 - roife:auto-closing-for-triple-backticks, r=Veykril
fix: support auto-closing for triple backticks

It might fix #16051, see https://github.com/rust-lang/rust-analyzer/issues/16051#issuecomment-2042606030
2024-04-13 19:22:03 +00:00
bors
85542e0de3 Auto merge of #17035 - Wilfred:windows_ci_on_prs, r=Veykril
Run Windows tests on PRs too

Previously PRs would only do a build on Windows, which confusingly meant that PRs got a green tick for Windows despite not testing them.

See discussion in #17019.
2024-04-13 19:07:13 +00:00
bors
a1884b0958 Auto merge of #17030 - Veykril:bump-chalk, r=Veykril
internal: Bump chalk

And make use of the new error lifetime
2024-04-13 18:54:17 +00:00
bors
0636e7c436 Auto merge of #17059 - Kohei316:refactor-generate-function, r=Veykril
internal: make function builder create ast directly

I am working on #17050.
In the process, I noticed a place in the code that could be refactored.
Currently, the `function builder` creates the `ast` through the `function template` , but those two processes can be combined into one function.
I thought I should work on this first and created a PR.
2024-04-13 18:41:27 +00:00
morine0122
145078e09f make function builder create ast directly 2024-04-13 20:16:12 +09:00