Commit Graph

28334 Commits

Author SHA1 Message Date
Lukas Wirth
001c387150 Don't retry position relient requests and version resolve data 2024-04-28 17:02:38 +02:00
Lukas Wirth
efb390bb94 fix: Fix doc comment desugaring for proc-macros 2024-04-27 13:30:51 +02:00
Lukas Wirth
d37c4b70d2 fix: Fix attributes on generic parameters colliding in item tree 2024-04-27 13:15:36 +02:00
Lukas Wirth
2b6f198a5e fix: Fix source roots not always being created when necessary 2024-04-26 18:55:58 +02:00
Lukas Wirth
3bc103ad88 Show workspace info in the status bar 2024-04-26 11:28:33 +02:00
bors
b2c377417e Auto merge of #17135 - Veykril:inline-const-scope, r=Veykril
fix: Fix expression scopes not being calculated for inline consts
2024-04-25 07:56:23 +00:00
Lukas Wirth
7dd3a16da8 fix: Fix expression scopes not being calculated for inline consts 2024-04-25 09:49:19 +02:00
bors
a2259bb8a2 Auto merge of #17134 - Veykril:lt-err-display, r=Veykril
internal: Don't render unknown lifetimes when rendering generic args

cc https://github.com/rust-lang/rust-analyzer/issues/17098
2024-04-25 07:36:47 +00:00
bors
d00de38599 Auto merge of #17021 - roife:add-hover-limits-for-adts, r=Veykril
Support hovering limits for adts

Fix #17009

1. Currently, r-a supports limiting the number of struct fields displayed when hovering. This PR extends it to support enum variants and union fields. Since the display of these three (ADTs) is similar, this PR extends 'hover_show_structFields' to 'hover_show_adtFieldsOrVariants'.
2. This PR also resolved the problem that the layout of ADT was not restricted by display limitations when hovering on the Self type.
3. Additionally, this PR changes the default value of display limitations to `10` (instead of the original `null`), which helps users discover this feature.
2024-04-25 07:23:27 +00:00
Lukas Wirth
10e82da69d Add inlay hints lifetime arg tests 2024-04-25 09:10:49 +02:00
bors
1709e37f18 Auto merge of #16972 - joshka:cargo-run-runnable, r=Veykril
Make `cargo run` always available for binaries

Previously, items for `cargo test` and `cargo check` would appear as in
the `Select Runnable` quick pick that appears when running
`rust-analyzer: Run`, but `run` would only appear as a runnable if a
`main`` function was selected in the editor. This change adds `cargo
run` as an always available runnable command for binary packages.

This makes it easier to develop cli / tui applications, as now users can
run application from anywhere in their codebase.
2024-04-25 07:08:24 +00:00
Lukas Wirth
ec1a29b443 Drop unknown lifetimes when rendering generic args 2024-04-24 21:22:48 +02:00
Josh McKinney
410f71fcc3
fix: move no_std check out of loop 2024-04-24 01:29:31 -07:00
bors
5a315da949 Auto merge of #17131 - bzy-debug:issue-17107, r=lnicola
different error code of "no such field" error based on variant type

fix #17107

Pass variant information down to diagnostic, so that we can get different error code based on variant type.

After fix:

- structure

  <img width="868" alt="Screenshot 2024-04-23 at 21 03 27" src="https://github.com/rust-lang/rust-analyzer/assets/71200607/c2d1e389-5b62-4e9a-a133-9ae41f80615f">

- enum's structure variant

  <img width="937" alt="Screenshot 2024-04-23 at 21 04 41" src="https://github.com/rust-lang/rust-analyzer/assets/71200607/ad8558a7-d809-4968-b290-2f6bbb8d6b8c">
2024-04-24 07:46:09 +00:00
Bao Zhiyuan
9e212e0523 different error code based on variant 2024-04-23 20:54:03 +08:00
bors
afa2a898a4 Auto merge of #17102 - davidbarsky:david/add-some-tracing-to-project-loading, r=lnicola
chore: add some `tracing` to project loading

I wanted to see what's happening during project loading and if it could be parallelized. I'm thinking maybe, but it's not this PR :)
2024-04-22 15:56:06 +00:00
David Barsky
2d4723b38b chore: add some tracing to project loading 2024-04-22 11:39:01 -04:00
bors
a200391f54 Auto merge of #17025 - lnicola:josh, r=lnicola
internal: Use josh for subtree syncs
2024-04-21 16:39:18 +00:00
bors
8ea8c7432b Auto merge of #16938 - Nilstrieb:dont-panic-tests, r=Veykril
Implement `BeginPanic` handling in const eval

for #16935, needs some figuring out of how to write these tests correctly
2024-04-21 16:22:02 +00:00
bors
7a3ad0308a Auto merge of #17115 - leviska:json_is_not_rust_better_names, r=Veykril
Try to generate more meaningful names in json converter

I just found out about rust-analyzer json converter, but I think it would be more convenient, if names were more useful, like using the names of the keys.

Let's look at some realistic arbitrary json:

```json
{
    "user": {
        "address": {
            "street": "Main St",
            "house": 3
        },
        "email": "example@example.com"
    }
}
```
I think, new generated code is much easier to read and to edit, than the old:
```rust
// Old
struct Struct1{ house: i64, street: String }
struct Struct2{ address: Struct1, email: String }
struct Struct3{ user: Struct2 }

// New
struct Address1{ house: i64, street: String }
struct User1{ address: Address1, email: String }
struct Root1{ user: User1 }
```

Ideally, if we drop the numbers, I can see it being usable just as is (may be rename root)
```rust
struct Address{ house: i64, street: String }
struct User{ address: Address, email: String }
struct Root{ user: User }
```

Sadly, we can't just drop them, because there can be multiple fields (recursive) with the same name, and we can't just easily retroactively add numbers if the name has 2 instances due to parsing being single pass.
We could ignore the `1` and add number only if it's > 1, but I will leave this open to discussion and right now made it the simpler way

In sum, even with numbers, I think this PR still helps in readability
2024-04-21 16:09:17 +00:00
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
Laurențiu Nicola
8f2138102f Use josh for subtree syncs 2024-04-21 10:07:08 +03:00
Lukas Wirth
04de0fff1e Peek for panic message in test output 2024-04-21 08:50:25 +02:00
Lev Iskandarov
846f8046b0 add test with multiple names 2024-04-20 21:04:53 +03:00
Lev Iskandarov
570c725f69 try to generate more meaningful names 2024-04-20 20:50:47 +03: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
roife
f7f02c0d12 fix: remove space within {} when no fields in struct 2024-04-20 10:07:33 +08:00
roife
0e9d845fc7 Add hovering limitations support for variants 2024-04-20 09:14:00 +08: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
roife
c1a4ba55d7 fix: add a separate setting for enum variants 2024-04-19 21:45:56 +08: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
Lukas Wirth
2efaa44acf Implement BeginPanic for mir eval 2024-04-19 12:42:32 +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