Commit graph

28380 commits

Author SHA1 Message Date
Lukas Wirth
56552f4839 Push macro-parsing error calculation out of fundamental queries 2024-05-13 16:56:26 +02:00
bors
067d9d995b Auto merge of #17195 - Veykril:unsafe-attr, r=Veykril
Implement unsafe attribute parsing
2024-05-13 09:50:52 +00:00
bors
5bf2f85c80 Auto merge of #17208 - Wilfred:log_error_from_threads, r=Veykril
fix: Report both IO errors and main_loop errors

If rust-analyzer receives a malformed LSP request, the IO thread terminates with a meaningful error, but then closes the channel.

Once the channel has closed, the main_loop also terminates, but it only has RecvError and can't show a meaningful error. As a result, rust-analyzer would incorrectly claim that the client forgot to shutdown.

```
$ buggy_lsp_client | rust-analyzer
Error: client exited without proper shutdown sequence
```

Instead, include both error messages when the server shuts down.
2024-05-09 11:59:04 +00:00
bors
7d1b3a6607 Auto merge of #17207 - Wilfred:serde_invalid_data, r=lnicola
fix: Report all LSP protocol errors with invalid_data

Previously we did not use invalid_data for serde errors, making it harder to understand errors when the client sends malformed data to the server.
2024-05-09 09:44:40 +00:00
Wilfred Hughes
d993f9d1c9 fix: Report both IO errors and main_loop errors
If rust-analyzer receives a malformed LSP request, the IO thread
terminates with a meaningful error, but then closes the channel.

Once the channel has closed, the main_loop also terminates, but it
only has RecvError and can't show a meaningful error. As a result,
rust-analyzer would incorrectly claim that the client forgot to
shutdown.

```
$ buggy_lsp_client | rust-analyzer
Error: client exited without proper shutdown sequence
```

Instead, include both error messages when the server shuts down.
2024-05-08 16:53:30 -07:00
Wilfred Hughes
84fdb72525 fix: Report all LSP protocol errors with invalid_data
Previously we did not use invalid_data for serde errors, making it
harder to understand errors when the client sends malformed data to
the server.
2024-05-08 16:08:00 -07:00
bors
9ec04ed43d Auto merge of #17192 - roife:fix-issue-17179, r=lnicola
Fix source_range for INT_NUMBER in completion

fix #17179.

Previously r-a use `TextRange::empty(self.position.offset)` as `source_range` for `INT_NUMBER`, so the `text_edit` would always be an insertion, which results in #17179.

This PR changed it by using `text_range` of `original_token` (same as `IDENT`).
2024-05-07 07:24:15 +00:00
Lukas Wirth
e1aeed3aed Implement unsafe attribute parsing 2024-05-06 12:11:29 +02:00
roife
435e83d9ad Fix source_range for INT_NUMBER in completion 2024-05-06 11:50:05 +08:00
bors
c4618fe14d Auto merge of #17190 - dfireBird:dyn_trait_with_lifetimes_in_rpit, r=Veykril
Fix: Lifetime's Bound Var Debrujin Index in Dyn Traits

Surely fixes #17182

I have tried running the analysis-stats in some of the repos mentioned in #17080. No panic in almost all of them.
2024-05-05 19:20:35 +00:00
dfireBird
8cbeb04ba2
fix lifetime bound var index in dyn trait 2024-05-05 23:40:34 +05:30
bors
1a5bb27c01 Auto merge of #17180 - lnicola:bump-gh-pages, r=lnicola
minor: bump `peaceiris/actions-gh-pages`
2024-05-03 17:26:34 +00:00
Laurențiu Nicola
dd9956fe53 Bump peaceiris/actions-gh-pages 2024-05-03 20:23:50 +03:00
bors
c80006af57 Auto merge of #17177 - hermannm:fix-run-lens-config, r=Veykril
Fix Run lens showing when lenses are disabled

I have disabled Rust Analyzer lenses in my VSCode settings, but noticed that the `Run` lens still showed. This surprised me, as the docs for `lens.run.enable` [state that it only applies when `lens.enable` is set](25f59be62f/crates/rust-analyzer/src/config.rs (L353-L355)). I then found that where we set `LensConfig::run`, we don't check `lens_enable` like for the other settings. [We did this previously](eab385e1f6/crates/rust-analyzer/src/config.rs (L1649)), so this seems like a regression from refactoring. This PR tries to fix that.
2024-05-03 07:18:04 +00:00
hermannm
d226527a8c
Fix Run lens showing when lenses are disabled
The documentation for `lens.run.enable` states that it only applies
when `lens.enable` is set. However, the config setting whether to show
the Run lens did not check `lens.enable`, so the Run lens would show
even though lenses were disabled.
2024-05-02 20:14:41 +02:00
bors
25f59be62f Auto merge of #17176 - Veykril:fix-implicit-ty-args, r=Veykril
Fix impl trait params not being counted properly

Fixes the other thing in https://github.com/rust-lang/rust-analyzer/issues/17173, this just rolls back a change from https://github.com/rust-lang/rust-analyzer/pull/17175 and adds a comment as to what it does
2024-05-02 12:05:25 +00:00
Lukas Wirth
c97ac34caa Fix impl trait params not being counted properly 2024-05-02 13:56:10 +02:00
bors
ecba59d69c Auto merge of #17175 - Veykril:fix-implicit-ty-args, r=Veykril
fix: Fix implicit ty args being lowered where they shouldn't

Fixes https://github.com/rust-lang/rust-analyzer/issues/17173
2024-05-02 10:04:13 +00:00
Lukas Wirth
8241d8a0b8 fix: Fix implicit ty args being lowered where they shouldn't 2024-05-02 11:53:53 +02:00
bors
1fb8364488 Auto merge of #17172 - Veykril:prelude, r=Veykril
fix: Correctly handle `no_core`/`no_std` for preludes

Fixes https://github.com/rust-lang/rust-analyzer/issues/17169, my previous change missed the fact that the sysroot itself depends on its own crates explicitly
2024-05-02 08:56:22 +00:00
Lukas Wirth
a268eaf053 fix: Correctly handle no_core/no_std for preludes 2024-05-02 10:50:28 +02:00
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