Commit graph

20019 commits

Author SHA1 Message Date
Hamir Mahal
7c34eb3880
style: simplify string interpolation 2024-05-30 16:18:49 -07:00
Vincent Esche
7b75f1113c Add Function::fn_ptr_type(…) for obtaining name-erased function type 2024-05-29 19:41:55 +02:00
Mathew Horner
4bf51eb496
Add preference modifier for workspace-local crates when using auto import. 2024-05-28 23:05:27 -05:00
David Mládek
8e2f379a5d add FlycheckStatus to global state 2024-05-28 20:45:13 +02:00
David Mládek
80b4368ded fix diagnostics clearing when flychecks run per-workspace 2024-05-28 11:07:57 +02:00
bors
b32f181f47 Auto merge of #17258 - maxwase:code-assist-async-sugar, r=Veykril
Add `toggle_async_sugar` assist code action

Implement code action for sugaring and de-sugaring asynchronous functions.

This code action does not import `Future` trait when de-sugaring and does not touch function boby, I guess this can be implemented later if needed. This action also does not take into consideration other bounds because IMO it's usually "let me try to use sugared version here".

Feel free to request changes, that's my first code action implementation 😄

Closes #17010
Relates to #16195
2024-05-27 16:40:04 +00:00
bors
f59ca41f23 Auto merge of #17253 - ThouCheese:master, r=Veykril
Implement assist to switch between doc and normal comments

Hey first PR to rust-analyzer to get my feet wet with the code base. It's an assist to switch a normal comment to a doc comment and back, something I've found myself doing by hand a couple of times.

I shamelessly stole `relevant_line_comments` from `convert_comment_block`, because I didn't see any inter-assist imports happening in the files I peeked at so I thought this would be preferable.
2024-05-27 16:27:23 +00:00
bors
16fd9aa373 Auto merge of #17291 - kilpkonn:master, r=Veykril
Fix `data_constructor` ignoring generics for struct

Previously didn't work for structs with generics due to `field.ty()` having placeholders in type.
_Enums were handeled correctly already._

Also renamed `type_constructor -> data_constructor` as this is more correct name for it
2024-05-27 16:15:10 +00:00
Mathew Horner
333bedd70f
Avoid clone when constructing runnable label. 2024-05-25 15:00:15 -05:00
Tavo Annus
0f6842700f Fix data_constructor ignoring generics for struct 2024-05-25 13:09:26 +03:00
Luuk Wester
9e5ff0dce7 remove nested match with and_then 2024-05-24 22:57:35 +02:00
Luuk Wester
f5d740aa3d add test for every keyword, fix bug 2024-05-24 22:41:49 +02:00
Luuk Wester
2400673ca6 cosmetic and performance fixes, and drop support for adding //! comments anywhere, except
for at the top of files.
2024-05-24 21:56:55 +02:00
maxwase
61f8ef5d57 Review fixes: Assist scope, trait qualify 2024-05-24 02:17:44 +03:00
maxwase
624f99b4b9 Review fixes: Split into 2, check tuple fields 2024-05-24 01:10:18 +03:00
maxwase
2657078573 Add toggle_async_sugar assist code action 2024-05-24 01:08:21 +03:00
roife
a8031e33fd tests: update test for runnables 2024-05-24 03:53:38 +08:00
roife
c43d59c709 Add cwd to CargoRunnable 2024-05-24 03:51:04 +08:00
bors
f6fc109fcb Auto merge of #17287 - Veykril:sysroot-encode-empty, r=Veykril
Allow sysroots to only consist of the source root dir

Fixes https://github.com/rust-lang/rust-analyzer/issues/17159

This PR encodes the `None` case of an optional sysroot into `Sysroot` itself. This simplifies a lot of things and allows us to have sysroots that consist of nothing, only standard library sources, everything but the standard library sources or everything. This makes things a lot more flexible. Additionally, this removes the workspace status bar info again, as it turns out that that can be too much information for the status bar to handle (this is better rendered somewhere else, like in the status view).
2024-05-23 18:13:47 +00:00
Lukas Wirth
bd37e2790b Allow sysroots to only consist of the source root dir 2024-05-23 20:12:31 +02:00
bors
f372a8a117 Auto merge of #17284 - Veykril:doc-links, r=Veykril
fix: Use correct toolchain channel when generating builtin type doc links
2024-05-23 08:55:08 +00:00
Lukas Wirth
5717622c95 Use correct toolchain channel when generating builtin type doc links 2024-05-23 10:42:15 +02:00
bors
dec43b6cb3 Auto merge of #17174 - Kohei316:fix-infer-async-block-with-tail-return-expr, r=Veykril
Fix: infer type of async block with tail return expr

Fixes #17106
The `infer_async_block` method calls the `infer_block` method internally, which returns the never type without coercion when `tail_expr` is `None` and `ctx.diverges` is `Diverges::Always`.This is the reason for the bug in this issue.
cfce2bb46d/crates/hir-ty/src/infer/expr.rs (L1411-L1413)

This PR solves the bug by adding a process to coerce after calling `infer_block` method.

This code passes all the tests, including tests I added for this isuue, however, I am not sure if this solution is right. I think that this solution is an ad hoc solution. So, I would appreciate to have your review.
I apologize if I'm off the mark, but `infer_async_block` method should be rewritten to share code with the process of infering type of `expr::Closure` instead of the `infer_block` method. That way it will be closer to the infer process of rustc.
2024-05-23 08:42:09 +00:00
Lukas Wirth
ac3b2d4b54
Update crates/hir-ty/src/infer/expr.rs 2024-05-23 10:36:57 +02:00
bors
e3e22c67e0 Auto merge of #17140 - harrysarson:harry-unused-self, r=Veykril
handle {self} when removing unused imports

Fixes #17139

On master

```rs
mod inner {
    pub struct X();
    pub struct Y();
}

mod z {
    use super::inner::{self, X}$0;

    fn f() {
        let y = inner::Y();
    }
}
```

becomes

```rs
mod inner {
    pub struct X();
    pub struct Y();
}

mod z {
    use super::inner:self;

    fn f() {
        let y = inner::Y();
    }
}
```

with this fix it instead becomes

```

```rs
mod inner {
    pub struct X();
    pub struct Y();
}

mod z {
    use super::inner;

    fn f() {
        let y = inner::Y();
    }
}
```
2024-05-23 08:30:10 +00:00
Jonathan Kelley
042bd0b78d
Fix: clippy 2024-05-22 14:39:16 -07:00
Jonathan Kelley
bdfcae556d
Allow searching with prefix 2024-05-22 13:47:05 -07:00
Jonathan Kelley
28ddddd091
Feat: hide double underscored symbols from symbol search 2024-05-22 13:43:07 -07:00
bors
653b69eb42 Auto merge of #17270 - davidbarsky:david/fix-completions-from-associated-types, r=Veykril
fix: ensure implied bounds from associated types are considered in autocomplete

closes: #16989

rust-analyzer needs to consider implied bounds from associated types in order to get all methods suggestions people expect. A pretty easy way to do that is to keep the `candidate_trait_id`'s receiver if it matches `TyFingerprint::Unnameable`.  When benchmarking this change, I didn't notice a meaningful difference in autocomplete latency.

(`TyFingerprint::Unnameable` corresponds to `TyKind::AssociatedType`, `TyKind::OpaqueType`, `TyKind::FnDef`, `TyKind::Closure`, `TyKind::Coroutine`, and `TyKind::CoroutineWitness`.)
2024-05-22 20:38:28 +00:00
David Barsky
a0d3a81a19 fix: ensure implied bounds from associated types are considered in autocomplete 2024-05-22 16:16:20 -04:00
bors
d4da3f925c Auto merge of #17251 - roife:fix-issue-17057, r=Veykril
fix: resolve extern prelude for local mods in block modules

fix https://github.com/rust-lang/rust-analyzer/issues/17057, https://github.com/rust-lang/rust-analyzer/issues/17032.

We should use `ModuleOrigin` to check if the current module is a pseudo-module introduced by blocks (where names might be shadowed), rather than checking `block_def_map`.
2024-05-22 20:11:24 +00:00
Lukas Wirth
3a7dcf91c4 Simplify 2024-05-22 21:57:44 +02:00
David Barsky
b75301cec8 internal: refactor prefer_no_std/prefer_prelude bools into a struct 2024-05-22 20:46:30 +02:00
roife
d9cc159b26 fix: check pseudo-block by local_id instead of ModuleOrigin 2024-05-23 02:39:53 +08:00
bors
6a16749eb0 Auto merge of #17277 - Veykril:find-path-fixes, r=Veykril
fix: Various find path fixes

Fixes https://github.com/rust-lang/rust-analyzer/issues/17271
2024-05-22 18:22:32 +00:00
bors
42a8500ebf Auto merge of #17279 - Veykril:format_args-escape, r=Veykril
fix: Fix format_args lowering passing incorrect parameters to `rustc_parse_format`
2024-05-22 14:12:22 +00:00
Lukas Wirth
4f17d07e69 fix: Fix format_args lowering passing incorrect parameters to rustc_parse_format 2024-05-22 16:11:06 +02:00
bors
2dc22c658a Auto merge of #17248 - mladedav:dm/delay-clear, r=Veykril
Clear diagnostics only after new ones were received

Closes #15934

This adds a flag inside the global state which controls when old diagnostics are cleared. Now, old diagnostics should be cleared only after at least one new diagnostic is available.
2024-05-22 13:01:08 +00:00
bors
daf66ad8eb Auto merge of #17268 - Veykril:signatures, r=Veykril
feat: More callable info

With this PR we retain more info about callables other than functions, allowing for closure parameter type inlay hints to be linkable as well as better signature help around closures and `Fn*` implementors.
2024-05-22 12:48:17 +00:00
Lukas Wirth
760ad445e2 Update assists test fixtures 2024-05-22 14:46:33 +02:00
Lukas Wirth
ca06b090d7 expectify find_path tests 2024-05-22 14:05:24 +02:00
Lukas Wirth
c88b421853 fix: Fix general find-path inconsistencies 2024-05-22 14:05:24 +02:00
roife
48dc20f80d test: add tests for extern preludes resolving in local mods 2024-05-21 20:35:55 +08:00
Laurențiu Nicola
49cae17fa2 Merge from rust-lang/rust 2024-05-19 11:20:26 +03:00
Lukas Wirth
7bd343e085 Show fn traits in signature info for trait implementors 2024-05-18 16:22:59 +02:00
Lukas Wirth
0de904d539 Enable linked locations for closure param inlay hints 2024-05-18 15:06:46 +02:00
Lukas Wirth
ff79903cf6 Render closure fn trait kind in siganture help 2024-05-18 15:01:37 +02:00
Lukas Wirth
7c6f31a45b Allow hir::Param to refer to other entity params aside from functions 2024-05-18 12:35:55 +02:00
Lukas Wirth
cd9e90cc71 Update builtin tool list 2024-05-18 10:52:05 +02:00
Luuk Wester
537b4c6305 implement assist to switch between doc and normal comments 2024-05-18 02:38:41 +02:00
roife
55db9530eb fix: resolve extern prelude for local mods in block modules 2024-05-17 23:29:00 +08:00
David Mládek
4d9346922a Clear diagnostics only after new ones were received 2024-05-17 01:30:01 +02:00
bors
83ba420431 Auto merge of #17243 - Veykril:static-lt-hir, r=Veykril
internal: Add StaticLifetime to hir API
2024-05-16 06:04:52 +00:00
Lukas Wirth
aaa5426fec internal: Add StaticLifetime to hir API 2024-05-16 08:02:51 +02:00
blyxyas
66f62836ae Fix typos 2024-05-15 18:55:27 +02:00
bors
c0732c9f0f Auto merge of #17232 - Veykril:build-scripts-keep-going, r=Veykril
fix: Don't emit --keep-going for custom build script commands

Might be the cause for https://github.com/rust-lang/rust-analyzer/issues/17231
2024-05-14 19:28:22 +00:00
Lukas Wirth
eac2e512a1 fix: Don't emit --keep-going for custom build script commands 2024-05-14 21:26:37 +02:00
bors
07d71c05c3 Auto merge of #17216 - Young-Flash:mod_with_path, r=Veykril
fix: extract mod to file should respect path attribute

close https://github.com/rust-lang/rust-analyzer/issues/17181
2024-05-14 14:29:00 +00:00
bors
77c7886283 Auto merge of #17227 - Veykril:build-deps-changed-hashes, r=Veykril
fix: Hash file contents to verify whether file actually changed

Fixes https://github.com/rust-lang/rust-analyzer/issues/16580
2024-05-14 10:48:18 +00:00
Lukas Wirth
465ebbc102 internal: Sort computed runnables 2024-05-14 12:32:48 +02:00
Lukas Wirth
1ca97ba896 Hash file contents to verify whether file actually changed 2024-05-14 11:55:12 +02:00
bors
7afd8d8a1a Auto merge of #17225 - Veykril:expand-macro-interlocked, r=Veykril
Expand macro recursively expands both fp-like and attribute macros when intertwined
2024-05-14 09:22:04 +00:00
Lukas Wirth
793396c624 Track hashes for file contents 2024-05-14 11:21:04 +02:00
bors
d28111dce8 Auto merge of #17224 - Veykril:lock-bump, r=Veykril
Bump Cargo.lock
2024-05-14 08:59:34 +00:00
Lukas Wirth
580b8dab1a Expand macro recursively expands both fp-like and attribute macros intertwined 2024-05-14 10:58:18 +02:00
Lukas Wirth
2a4be8d1f7 Bump Cargo.lock 2024-05-14 10:57:02 +02:00
bors
b98690ba74 Auto merge of #17221 - Veykril:lazier-validation, r=Veykril
internal: Lazier macro parse tree validation
2024-05-13 15:16:46 +00:00
Lukas Wirth
caddcccea5 parse_macro_expansion_error almost never contains values so Option it 2024-05-13 17:02:08 +02:00
Lukas Wirth
56552f4839 Push macro-parsing error calculation out of fundamental queries 2024-05-13 16:56:26 +02:00
bors
40ab5e5f8c Auto merge of #17220 - Veykril:hov-lit, r=Veykril
fix: Improve confusing literal hovers
2024-05-13 10:58:29 +00:00
Lukas Wirth
5b696bac5c Don't render multi-line literal values 2024-05-13 12:56:02 +02:00
Lukas Wirth
a39c0493a1 Render literal escaping errors in hovers 2024-05-13 12:51:57 +02:00
bors
9db1258dbe Auto merge of #17203 - kilpkonn:collapse_terms, r=Veykril
Fix OOM caused by term search

The issue came from multi Cartesian product for exprs with many (25+) arguments, each having multiple options.
The solution is two fold:
### Avoid blowing up in Cartesian product
**Before the logic was:**
    1. Find expressions for each argument/param - there may be many
    2. Take the Cartesian product (which blows up in some cases)
    4. If there are more than 2 options throw them away by squashing them to `Many`
**Now the logic is:**
    1. Find expressions for each argument/param and squash them to `Many` if there are more than 2 as otherwise we are guaranteed to also have more than 2 after taking the product which means squashing them anyway.
    2. Take the Cartesian product on iterator
    3. Start consuming it one by one
    4. If there are more than 2 options throw them away by squashing them to `Many`  (same as before)

This is also why I had to update some tests as the expressions get squashed to many more eagerly.

### Use fuel to avoid long search times and high memory usage
Now all the tactics use `should_continue:  Fn() -> bool` to chech if they should keep iterating _(Similarly to chalk)_.
This reduces the search times by a magnitude, for example from ~139ms/hole to ~14ms/hole for `ripgrep` crate.
There are slightly less expressions found, but I think speed gain worth it for usability.
Also note that syntactic hits decreases more because of squashing so you simple need to run search multiple times to get full terms.
Also the worst case time (For example `nalgebra` crate cus it has tons of generics) has search times mostly under 200ms.

Benchmarks on `ripgrep` crate
Before:
```
Tail Expr syntactic hits: 291/1692 (17%)
Tail Exprs found: 1253/1692 (74%)
Term search avg time: 139ms
````
After:
```
Tail Expr syntactic hits: 239/1692 (14%)
Tail Exprs found: 1226/1692 (72%)
Term search avg time: 14ms
```
2024-05-13 10:30:12 +00:00
Lukas Wirth
253929f6ae Fix literal hovers being confusing and wrong for floats 2024-05-13 12:26:45 +02:00
bors
bf53c472ed Auto merge of #17188 - szabgab:patch-1, r=Veykril
use the repository field to link to the repository
2024-05-13 10:16:45 +00:00
bors
7aecf1ae35 Auto merge of #17187 - roife:fix-issue-17185, r=Veykril
fix: keep parentheses when the precedence of inner expr is lower than the outer one

fix #17185

Additionally, this PR simplifies some code in `apply_demorgan`.
2024-05-13 10:03:40 +00:00
bors
067d9d995b Auto merge of #17195 - Veykril:unsafe-attr, r=Veykril
Implement unsafe attribute parsing
2024-05-13 09:50:52 +00:00
Young-Flash
3e57aabf85 test: add test case extract_with_specified_path_attr 2024-05-12 11:48:17 +08:00
Young-Flash
0c13f0cd5b fix: extract mod to file should respect path attribute 2024-05-12 11:48:17 +08: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
Tavo Annus
ab18604309 Make term search fuel configurable 2024-05-08 19:46:33 +03:00
Tavo Annus
9e1adc76e5 Use unit of work as fuel instead of time 2024-05-07 22:13:27 +03: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
Tavo Annus
d253617bba Add time based fuel to term search 2024-05-06 22:13:09 +03:00
Tavo Annus
c3ab435b54 Collapse term search exprs before Cartesian product to avoid OOM 2024-05-06 20:29:34 +03:00
beetrees
861cca5249
Refactor float Primitives to a separate Float type 2024-05-06 14:56:10 +01: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
dfireBird
8cbeb04ba2
fix lifetime bound var index in dyn trait 2024-05-05 23:40:34 +05:30
roife
4ada8265e6 tests: update test in assist apply_demorgan 2024-05-05 23:44:52 +08:00
Gábor Szabó
d0c0660b9b
use the repository field to link to the repository 2024-05-05 17:59:27 +03:00
roife
a42818f393 fix: keep parentheses when the precedence of inner expr is lower than the outer one 2024-05-05 21:39:26 +08: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
Martin Nordholts
938e1a0e2c Change SIGPIPE ui from #[unix_sigpipe = "..."] to -Zon-broken-pipe=...
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern
was raised related to using a language attribute for the feature: Long
term, we want `fn lang_start()` to be definable by any crate, not just
libstd. Having a special language attribute in that case becomes
awkward.

So as a first step towards towards the next stabilization attempt, this
PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag
`-Zon-broken-pipe=...` to remove that concern, since now the language
is not "contaminated" by this feature.

Another point was also raised, namely that the ui should not leak
**how** it does things, but rather what the **end effect** is. The new
flag uses the proposed naming. This is of course something that can be
iterated on further before stabilization.
2024-05-02 19:48:29 +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
Lukas Wirth
a268eaf053 fix: Correctly handle no_core/no_std for preludes 2024-05-02 10:50:28 +02: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
Wilfred Hughes
b1266405ef docs: Fix typo in VS Code setting description 2024-04-30 11:17:57 -07:00
Harry Sarson
a653ddf940
braces around {self} in UseTree are not unnecessary
Before this commit `UseTree::remove_unnecessary_braces` removed the braces
around `{self}` in `use x::y::{self};` but `use x::y::self;` is not valid
rust.
2024-04-30 18:17:32 +01: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
morine0122
da3fa2b7f0 Fix coercion of async block 2024-04-30 18:31:10 +09: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
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
Lukas Wirth
36c1c77cf9 fix: Fix doc comment desugaring for proc-macros 2024-04-27 13:30:51 +02:00
Lukas Wirth
bfe59bbdc8 fix: Fix attributes on generic parameters colliding in item tree 2024-04-27 13:15:36 +02:00
Lukas Wirth
2668912688 fix: Fix source roots not always being created when necessary 2024-04-26 18:55:58 +02: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
Oli Scherer
83e28486dc Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +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
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
Lukas Wirth
a2ed6837bc Allow rust files to be used linkedProjects 2024-04-21 16:26:55 +02:00
Laurențiu Nicola
c38295993b Use josh for subtree syncs 2024-04-21 10:07:08 +03:00
Lukas Wirth
3b9a2af21f Peek for panic message in test output 2024-04-21 08:50:25 +02:00
Lev Iskandarov
029c7108e0 add test with multiple names 2024-04-20 21:04:53 +03:00
Lev Iskandarov
ce18438cfd try to generate more meaningful names 2024-04-20 20:50:47 +03:00
Laurențiu Nicola
c8c635a3f8 Merge commit '55d9a533b309119c8acd13061581b43ae8840823' into sync-from-ra 2024-04-20 19:17:08 +03:00
Laurențiu Nicola
4c94e69115 Add in-rust-tree feature to hir-expand 2024-04-20 18:44:27 +03:00
roife
aa1f1344cc fix: remove space within {} when no fields in struct 2024-04-20 10:07:33 +08:00
roife
43576989a1 Add hovering limitations support for variants 2024-04-20 09:14:00 +08: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
e0e28ec856 fix: add a separate setting for enum variants 2024-04-19 21:45:56 +08:00