Commit graph

28359 commits

Author SHA1 Message Date
bors
cfce2bb46d Auto merge of #17168 - kennykerr:rust-analyzer-windows-sys, r=lnicola
Update `rust-analyzer` to use `windows-sys` crate

I noticed that the `rust-analyzer` project already depends on `windows-sys`. This update merely replaces the remaining direct dependencies on the older `winapi` crate with `windows-sys` dependencies.

Originally posted here: https://github.com/rust-lang/rust/pull/124578
2024-05-01 14:10:55 +00:00
Kenny Kerr
99e2530583 Update rust-analyzer to use windows-sys crate 2024-05-01 09:04:13 -05:00
bors
49e502b277 Auto merge of #17148 - Wilfred:span_names, r=Veykril
fix: Tracing span names should match function names

When viewing traces, it's slightly confusing when the span name doesn't match the function name. Ensure the names are consistent.

(It might be worth moving most of these to use `#[tracing::instrument]` so the name can never go stale. `@davidbarsky` suggested that is marginally slower, so I've just done the simple change here.)
2024-04-30 18:33:17 +00:00
Wilfred Hughes
c981ff0944 fix: Tracing span names should match function names
When viewing traces, it's slightly confusing when the span name doesn't
match the function name. Ensure the names are consistent.

(It might be worth moving most of these to use #[tracing::instrument]
so the name can never go stale. @davidbarsky suggested that is marginally
slower, so I've just done the simple change here.)
2024-04-30 11:22:47 -07:00
bors
f660835df7 Auto merge of #17147 - Wilfred:fix_typo, r=Veykril
docs: Fix typo in VS Code setting description

Replace 'futureg' with 'future'.
2024-04-30 18:19:43 +00:00
Wilfred Hughes
b1266405ef docs: Fix typo in VS Code setting description 2024-04-30 11:17:57 -07:00
bors
1bf1f6e0a1 Auto merge of #17160 - dfireBird:fix_impl_trait, r=Veykril
Implement creating generics for impl traits in associated types

Hopefully fix #17017
2024-04-30 12:23:23 +00:00
Lukas Wirth
da0fb75d10
Use RefCell::take 2024-04-30 14:19:56 +02:00
bors
84ef3cfa91 Auto merge of #17138 - Kohei316:generate-function-assist-for-new, r=Veykril
feature: Make generate function assist generate a function as a constructor if the generated function has the name "new" and is an asscociated function.

close #17050
This PR makes `generate function assist` generate a function as a constructor if the generated function has the name "new" and is an asscociated function.
If the asscociate type is a record struct, it generates the constructor like this.
```rust
impl Foo {
    fn new() -> Self {
        Self { field_1: todo!(), field_2: todo!() }
    }
}
```
If the asscociate type is a tuple struct, it generates the constructor like this.
```rust
impl Foo {
    fn new() -> Self {
        Self(todo!(), todo!())
    }
}
```
If the asscociate type is a unit struct, it generates the constructor like this.
```rust
impl Foo {
    fn new() -> Self {
        Self
    }
}
```
If the asscociate type is another adt, it generates the constructor like this.
```rust
impl Foo {
    fn new() -> Self {
        todo!()
    }
}
```
2024-04-30 12:09:34 +00:00
bors
374ce0816c Auto merge of #17161 - l1nxy:discard-invalid-path, r=Veykril
fix: discard path when the path is invalid

Close #17158
2024-04-30 08:33:05 +00:00
morine0122
ff2629d651 Make generate function assist generate a function as a constructor if the name of function is new 2024-04-30 17:02:48 +09:00
Yu Zeng
8d4ecc169f discard when the path is invalid utf8 symbol. 2024-04-30 15:39:05 +08:00
dfireBird
40a677ddf0
implement creating generics for impl traits in associated types 2024-04-29 23:55:02 +05:30
bors
1e61ed723f Auto merge of #17144 - cbiffle:patch-1, r=Veykril
manual: remove suggestion of rust-project.json example

The manual has been linking to the repo

https://github.com/rust-analyzer/rust-project.json-example/tree/master

This repo does not contain a rust-project.json, does not appear to have _ever_ contained a rust-project.json, and my bug report about this has gone untouched: https://github.com/rust-analyzer/rust-project.json-example/issues/4

Since I can't figure out an example, this commit removes the link pending better documentation.
2024-04-29 08:16:11 +00:00
bors
7f19431102 Auto merge of #17157 - Veykril:retry, r=Veykril
fix: Don't retry position relient requests and version resolve data

Fixes https://github.com/rust-lang/rust-analyzer/issues/15907
Fixes https://github.com/rust-lang/rust-analyzer/issues/14839
Fixes https://github.com/rust-lang/rust-analyzer/issues/16536
2024-04-29 08:02:08 +00:00
Lukas Wirth
9371197182 Retry inlay hint requests 2024-04-29 09:53:12 +02:00
Lukas Wirth
29cd3a8cbf Work around completion retrying not fixing up offsets 2024-04-28 17:25:20 +02:00
Lukas Wirth
367b82f68d Don't retry position relient requests and version resolve data 2024-04-28 17:02:38 +02:00
bors
f216be4a07 Auto merge of #17153 - Veykril:doc-comment-desugaring, r=Veykril
fix: Fix doc comment desugaring for proc-macros

Fixes https://github.com/rust-lang/rust-analyzer/issues/16259
2024-04-27 11:32:40 +00:00
Lukas Wirth
36c1c77cf9 fix: Fix doc comment desugaring for proc-macros 2024-04-27 13:30:51 +02:00
bors
e6f33994fd Auto merge of #17151 - Veykril:fix-cfg-trait-params, r=Veykril
fix: Fix attributes on generic parameters colliding in item tree

Fixes https://github.com/rust-lang/rust-analyzer/issues/16141
2024-04-27 11:17:14 +00:00
Lukas Wirth
bfe59bbdc8 fix: Fix attributes on generic parameters colliding in item tree 2024-04-27 13:15:36 +02:00
bors
4ff01a24f9 Auto merge of #17150 - RalfJung:josh-pull, r=lnicola
internal: add no-new-root check to josh pull

We probably don't want a second root to show up...

Also clear the rust-version file while we are at it.
2024-04-27 07:10:12 +00:00
Ralf Jung
f95673e8d3 empty rust-version file, since no pull has happened yet 2024-04-27 09:02:52 +02:00
Ralf Jung
b4ad65b394 add no-new-root check to josh pull 2024-04-27 09:02:07 +02:00
bors
1ed7e2de05 Auto merge of #17145 - Veykril:fix-missing-source-root, r=Veykril
fix: Fix source roots not always being created when necessary

(should) fix https://github.com/rust-lang/rust-analyzer/issues/17071 and fix https://github.com/rust-lang/rust-analyzer/issues/17079
2024-04-26 16:57:46 +00:00
Lukas Wirth
2668912688 fix: Fix source roots not always being created when necessary 2024-04-26 18:55:58 +02:00
Cliff L. Biffle
898d466c2d
manual: remove suggestion of rust-project.json example
The manual has been linking to the repo

https://github.com/rust-analyzer/rust-project.json-example/tree/master

This repo does not contain a rust-project.json, does not appear to have _ever_ contained a rust-project.json, and my bug report about this has gone untouched: https://github.com/rust-analyzer/rust-project.json-example/issues/4

Since I can't figure out an example, this commit removes the link pending better documentation.
2024-04-26 08:23:50 -07:00
bors
d70e61dbac Auto merge of #17143 - Veykril:status-info, r=Veykril
internal: Show workspace info in the status bar

cc https://github.com/rust-lang/rust-analyzer/issues/17127
2024-04-26 11:21:06 +00:00
Lukas Wirth
18ca22a98e Show workspace info in the status bar 2024-04-26 11:28:33 +02:00
bors
56bee2ddaf 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
ac389ce2ef fix: Fix expression scopes not being calculated for inline consts 2024-04-25 09:49:19 +02:00
bors
935de9d773 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
65eda41e65 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
ec941e599a Add inlay hints lifetime arg tests 2024-04-25 09:10:49 +02:00
bors
c88d5dc5de 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
31304ad1ad Drop unknown lifetimes when rendering generic args 2024-04-24 21:22:48 +02:00
Josh McKinney
aa499266ad
fix: move no_std check out of loop 2024-04-24 01:29:31 -07:00
bors
73a427588a 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
5c88e98419 different error code based on variant 2024-04-23 20:54:03 +08:00
bors
e31c9f3fe1 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
2a030ba755 chore: add some tracing to project loading 2024-04-22 11:39:01 -04:00
bors
47a901b9bf Auto merge of #17025 - lnicola:josh, r=lnicola
internal: Use josh for subtree syncs
2024-04-21 16:39:18 +00:00
bors
4c08e2d32f 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
3077e6948d 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
7baabfc822 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
fa754becc4 Support flychecking for cargo scripts 2024-04-21 17:40:17 +02:00
Lukas Wirth
ff56cb6e49 Extract common fields out of ProjectWorkspace variants 2024-04-21 17:03:02 +02:00
bors
f512a5e95c 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
a2ed6837bc Allow rust files to be used linkedProjects 2024-04-21 16:26:55 +02:00