Commit Graph

28265 Commits

Author SHA1 Message Date
Lukas Wirth
8989dcffd6 Support cfg overrides in all workspace kind 2024-04-19 10:59:32 +02:00
Lukas Wirth
ee10f9f5cd Cleanup cfg and env handling in project-model 2024-04-19 10:41:08 +02:00
Lukas Wirth
2e54c0af40 Remove rustc core test cfg hacks 2024-04-19 09:27:05 +02:00
bors
062e1b9b81 Auto merge of #17093 - Wilfred:vfs_ignore_symlink_cycles, r=Veykril
fix: VFS should not walk circular symlinks

As of #6246, rust-analyzer follows symlinks. This can introduce an infinite loop if symlinks point to parent directories.

Considering that #6246 was added in 2020 without many bug reports, this is clearly a rare occurrence. However, I am observing rust-analyzer hang on projects that have symlinks of the form:

```
test/a_symlink -> ../../
```

Ignore symlinks that only point to the parent directories, as this is more robust but still allows typical symlink usage patterns.
2024-04-18 07:38:32 +00:00
Wilfred Hughes
bd133eecda fix: VFS should not walk circular symlinks
As of #6246, rust-analyzer follows symlinks. This can introduce an
infinite loop if symlinks point to parent directories.

Considering that #6246 was added in 2020 without many bug reports,
this is clearly a rare occurrence. However, I am observing
rust-analyzer hang on projects that have symlinks of the form:

```
test/a_symlink -> ../../
```

Ignore symlinks that only point to the parent directories, as this is
more robust but still allows typical symlink usage patterns.
2024-04-17 14:40:01 -07:00
bors
46702ffc1a Auto merge of #17087 - davidbarsky:david/fix-some-tracing-spans, r=Veykril
chore: fix a few spans without `.entered()`
2024-04-17 16:59:33 +00:00
bors
b256807c3e Auto merge of #17092 - Veykril:per-queries, r=Veykril
minor: Update `per_query_memory_usage` query listing
2024-04-17 16:46:21 +00:00
Lukas Wirth
011c2127c8 Update per_query_memory_usage query listing 2024-04-17 18:44:50 +02:00
David Barsky
5ba37f3f8e chore: fix a few spans without .entered() 2024-04-17 12:44:49 -04:00
bors
91b8441b3a Auto merge of #17055 - wyatt-herkamp:fix_panic_at_unused_variable, r=Veykril
fix: Replace Just the variable name in Unused Variable Diagnostic Fix

Changes Unused Variable diagnostic to just look at the variable name, not the entire syntax range.

Also added a test for an unused variable in an array destructure.

Closes #17053
2024-04-17 10:11:03 +00:00
Lukas Wirth
0eb7b6c7b5 Don't show unused_variables fixes if the name comes from a macro definition 2024-04-17 12:05:35 +02:00
bors
d07f0240fd Auto merge of #17083 - matklad:matklad/test-search, r=lnicola
ide: improve ReferenceCategoryType

It is bitset semantically --- many categorical things can be true about a reference at the same time.

In parciular, a reference can be a "test" and a "write" at the same time.
2024-04-16 16:36:41 +00:00
Alex Kladov
f852a6fc7d ide: add a new test 2024-04-16 17:17:46 +01:00
Alex Kladov
9bd8eee21e ide: improve ReferenceCategoryType
It is bitset semantically --- many categorical things can be true about
a reference at the same time.

In parciular, a reference can be a "test" and a "write" at the same
time.
2024-04-16 17:17:46 +01:00
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
Wyatt Herkamp
701068daf2 Verify we are not in a macro attempt 2 2024-04-15 14:11:45 -04: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
Wyatt Herkamp
0faa2940c7 Use the text range for the name. Not the entire syntax in Unused Variable Diagnostic. 2024-04-15 10:46:21 -04: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