Commit Graph

28297 Commits

Author SHA1 Message Date
bors
23f19a2fb6 Auto merge of #17119 - Veykril:linked-rust-files, r=Veykril
internal: Extract common fields out of `ProjectWorkspace` variants
2024-04-21 15:54:24 +00:00
Lukas Wirth
0a29e6fc85 Support flychecking for cargo scripts 2024-04-21 17:40:17 +02:00
Lukas Wirth
92ace4b139 Extract common fields out of ProjectWorkspace variants 2024-04-21 17:03:02 +02:00
bors
3c0f2dbcae Auto merge of #17118 - Veykril:linked-rust-files, r=Veykril
feat: Allow rust files to be used linkedProjects

With this, script files become more usable as the user can at least add them manually to the linked projects, allowing them to be used "on the (manual) fly" without having to open a separate vscode window that only has files open and no folder.

Also makes build scripts work for them (though no proc-macros, for some reason the dylib field is not populated in the output)
2024-04-21 14:51:51 +00:00
Lukas Wirth
7c39263450 Allow rust files to be used linkedProjects 2024-04-21 16:26:55 +02:00
bors
55d9a533b3 Auto merge of #17114 - lnicola:hir-expand-in-tree, r=Veykril
minor: Add in-rust-tree feature to hir-expand

CC https://github.com/rust-lang/rust/pull/124199#issuecomment-2067701168
2024-04-20 16:02:57 +00:00
Laurențiu Nicola
4c94e69115 Add in-rust-tree feature to hir-expand 2024-04-20 18:44:27 +03:00
bors
c83d8cf584 Auto merge of #17110 - Veykril:cargo-script-mvp, r=Veykril
Cargo script mvp

Based on https://github.com/rust-lang/rust-analyzer/pull/15456,

As the original PR stated, detached files are still horrendous to work with.
2024-04-19 20:51:10 +00:00
bors
8621e79fa7 Auto merge of #17104 - hamirmahal:fix/usage-of-deprecated-version-of-node-in-metrics-yml, r=lnicola
fix: usage of `deprecated` version of `Node.js`

fixes #17103.
2024-04-19 18:36:33 +00:00
Hamir Mahal
3d6bd24dcb
fix: usage of deprecated version of Node.js 2024-04-19 11:18:25 -07:00
Lukas Wirth
0ce7179e6b Correctly populate detached files roots 2024-04-19 18:25:10 +02:00
Lukas Wirth
46f05543a2 Patch cargo script root files back to manifest 2024-04-19 18:25:10 +02:00
Lukas Wirth
0b24599cf9 Re-implement dependecny tracking for cargo script 2024-04-19 18:25:06 +02:00
hkalbasi
2f828073aa Add minimal support for cargo scripts 2024-04-19 18:23:06 +02:00
bors
50bdeaad07 Auto merge of #17108 - Veykril:rustc-ws-hacks, r=Veykril
internal: Cleanup cfg and env handling in project-model

Fixes https://github.com/rust-lang/rust-analyzer/issues/16122#issuecomment-2065794340

`miri` and `debug_assertions` are now enabled via the `cargo.cfgs` config by default, allowing them to be disabled by overwriting the config.
2024-04-19 16:00:54 +00:00
bors
05428c5640 Auto merge of #17024 - roife:fix-issue-16980, r=Veykril
fix: handle escaped chars in doc comments

fix #16980.

For `ast::LiteralKind::String`, store the original string value.
2024-04-19 13:19:22 +00:00
roife
3e232bb78a fix: replace unescape fn with the one in ra-ap-rustc_lexer 2024-04-19 20:32:53 +08:00
Lukas Wirth
cdb8c3a327 Fix tests being non-deterministic 2024-04-19 13:22:00 +02:00
bors
77ce295006 Auto merge of #17094 - Lindronics:convert-from-to-tryfrom, r=Veykril
feat: Add convert From to TryFrom assist

Adds a new code assist to convert a `From` impl into a `TryFrom` impl.

This is useful in situations where it turns out after or halfway through writing a `From` implementation that the conversion is actually fallible.

## Example

https://github.com/rust-lang/rust-analyzer/assets/26360861/872ec7c4-c9ff-451c-9453-4baaaad47326
2024-04-19 09:15:20 +00:00
Lukas Wirth
0485a85ee2 Set debug_assertions and miri cfgs as config defaults, allowing them to be overwritten 2024-04-19 11:06:55 +02:00
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
Niklas Lindorfer
1aba0002df
Add convert From to TryFrom assist 2024-04-19 08:29:20 +01:00
bors
eea61bd4d1 Auto merge of #16726 - Veykril:rustc-ws-hacks, r=Veykril
internal: Remove rustc core test cfg hacks

cc https://github.com/rust-lang/rust-analyzer/issues/16538
2024-04-19 07:28:50 +00:00
Lukas Wirth
2e54c0af40 Remove rustc core test cfg hacks 2024-04-19 09:27:05 +02:00
bors
9b4fb7ce91 Auto merge of #17105 - kpreid:nocapture, r=Veykril
Make test harness arguments configurable and not `--nocapture`.

* Added config `runnables.extraTestBinaryArgs` to control the args.
* The default is `--show-output` rather than `--nocapture` to prevent unreadable output when 2 or more tests fail or print output at once.
* Renamed variables in `CargoTargetSpec::runnable_args()` for clarity.

Fixes #12737.

Suggested changelog info:

> New Features
>
> * add `rust-analyzer.runnables.extraTestBinaryArgs` to configure test harness options when running tests; replaces a previously hard-coded `--nocapture` option.

I'm not sure I made the right choices in vocabulary, between “binary”, “executable”, and “runnable”, and “launch” vs. “execute”, so let me know if I missed something to be consistent with in the naming and documentation.
2024-04-19 07:02:15 +00:00
roife
a543516ea4 fix: handle escaped chars in doc comments 2024-04-19 14:57:37 +08:00
Kevin Reid
db292bd89e Make test harness arguments configurable and not --nocapture.
* Added config `runnables.extraTestBinaryArgs` to control the args.
* The default is `--show-output` rather than `--nocapture` to prevent
  unreadable output when 2 or more tests fail or print output at once.
* Renamed variables in `CargoTargetSpec::runnable_args()` for clarity.

Fixes <https://github.com/rust-lang/rust-analyzer/issues/12737>.
2024-04-18 18:37:09 -07:00
bors
af1fd88c4d Auto merge of #16257 - lnicola:rustc-check-cfg, r=Veykril
internal: Teach cargo about `cfg(rust_analyzer)`

r? `@Urgau` is this a good idea?, CC `@Veykril`
2024-04-18 12:13:06 +00:00
bors
08c706f2f8 Auto merge of #16057 - Veykril:macro-arm, r=Veykril
Render matched macro arm on hover of macro calls

Fixes https://github.com/rust-lang/rust-analyzer/issues/4028, its a different take on the idea. I don't like go to being changed here simply because we can't point the focus range on the name anymore as we usually do, and some editors might use this feature (and the focus range) for certain other things. We could instead add a new hover action for this to move to the arm directly (or maybe make `go to implementation` jump to the arm?)
2024-04-18 09:02:39 +00:00
Lukas Wirth
4135696ea7 Cleanup 2024-04-18 11:00:22 +02:00
Lukas Wirth
6bfdd38c69 Render matched macro arm on hover of macro calls 2024-04-18 10:51:58 +02:00
bors
68b1a2861f Auto merge of #17095 - Veykril:contributing.md, r=Veykril
Add CONTRIBUTING.md

I'm not great with these kinds of documents, but the main point I want to be able to raise is that feature implementations should have an issue raised first for discussion.
2024-04-18 08:30:42 +00:00
Lukas Wirth
d12bad650b Add CONTRIBUTING.md 2024-04-18 10:24:40 +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