Commit graph

20187 commits

Author SHA1 Message Date
Young-Flash
e8941dae46 internal: tweak test case 2024-06-09 20:55:40 +08:00
Lukas Wirth
2ced362e57 Fix divide by zero 2024-06-09 13:03:01 +02:00
Lukas Wirth
d4dc3ca83b Register virtual workspace Cargo.toml files in the VFS 2024-06-09 12:54:50 +02:00
Lukas Wirth
e972dd2385 Allow choosing logical cores for num threads config 2024-06-09 12:04:28 +02:00
Lukas Wirth
7f1f85ac16 feat: Compute native diagnostics in parallel 2024-06-09 11:44:44 +02:00
Young-Flash
dcbc76b967 internal: better print style for hir 2024-06-09 12:00:43 +08:00
DropDemBits
4e6d908382
internal: Expose snippet capability to diagnostic quickfixes 2024-06-07 21:29:48 -04:00
Lukas Wirth
379f885373 fix: Fix renaming imports of foreign items touching foreign sources 2024-06-07 14:36:37 +02:00
bors
7c5d496ef8 Auto merge of #17058 - alibektas:13529/ratoml, r=Veykril
feat: TOML based config for rust-analyzer

> Important
>
> We don't promise _**any**_ stability with this feature yet, any configs exposed may be removed again, the grouping may change etc.

# TOML Based Config for RA

This PR ( addresses #13529 and this is a follow-up PR on #16639 ) makes rust-analyzer configurable by configuration files called `rust-analyzer.toml`. Files **must** be named `rust-analyzer.toml`. There is not a strict rule regarding where the files should be placed, but it is recommended to put them near a file that triggers server to start (i.e., `Cargo.{toml,lock}`, `rust-project.json`).

## Configuration Types

Previous configuration keys are now split into three different classes.

1. Client keys: These keys only make sense when set by the client (e.g., by setting them in `settings.json` in VSCode). They are but a small portion of this list. One such example is `rust_analyzer.files_watcher`, based on which either the client or the server will be responsible for watching for changes made to project files.
2. Global keys: These keys apply to the entire workspace and can only be set on the very top layers of the hierarchy. The next section gives instructions on which layers these are.
3. Local keys: Keys that can be changed for each crate if desired.

### How Am I Supposed To Know If A Config Is Gl/Loc/Cl ?

#17101

## Configuration Hierarchy

There are 5 levels in the configuration hierarchy. When a key is searched for, it is searched in a bottom-up depth-first fashion.

### Default Configuration

**Scope**: Global, Local, and Client

This is a hard-coded set of configurations. When a configuration key could not be found, then its default value applies.

### User configuration

**Scope**: Global, Local

If you want your configurations to apply to **every** project you have, you can do so by setting them in your `$CONFIG_DIR/rust-analyzer/rust-analyzer.toml` file, where `$CONFIG_DIR` is :

| Platform | Value                                 | Example                                  |
| ------- | ------------------------------------- | ---------------------------------------- |
| Linux   | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config                      |
| macOS   | `$HOME`/Library/Application Support   | /Users/Alice/Library/Application Support |
| Windows | `{FOLDERID_RoamingAppData}`           | C:\Users\Alice\AppData\Roaming           |

### Client configuration

**Scope**: Global, Local, and Client

Previously, the only way to configure rust-analyzer was to configure it from the settings of the Client you are using. This level corresponds to that.

> With this PR, you don't need to port anything to benefit from new features. You can continue to use your old settings as they are.

### Workspace Root Configuration

**Scope**: Global, Local

Rust-analyzer already used the path of the workspace you opened in your Client. We used this information to create a configuration file that won't affect your other projects and define global level configurations at the same time.

### Local Configuration

**Scope**: Local

You can also configure rust-analyzer on a crate level. Although it is not an error to define global ( or client ) level keys in such files, they won't be taken into consideration by the server. Defined local keys will affect the crate in which they are defined and crate's descendants. Internally, a Rust project is split into what we call `SourceRoot`s. This, although with exceptions, is equal to splitting a project into crates.

> You may choose to have more than one `rust-analyzer.toml` files within a `SourceRoot`, but among them, the one closer to the project root will be
2024-06-07 10:49:02 +00:00
bors
26c1638bfb Auto merge of #17308 - mathew-horner:prefer-workspace, r=Veykril
Add preference modifier for workspace-local crates when using auto import.

`@joshka` pointed out some odd behavior of auto import ordering. It doesn't seem that the current heuristics were applying any sort of precedence to imports from the workspace. I've went ahead and added that.

I hope to get some feedback on the modifier numbers here. I just went with something that felt like it balanced giving more power to workspace crates without completely ignoring relative path distance.

closes https://github.com/rust-lang/rust-analyzer/issues/17303
2024-06-07 10:35:49 +00:00
Lukas Wirth
5a7bf1d147 Fix processing of ratoml files 2024-06-07 12:31:50 +02:00
Wilfred Hughes
27182bb96b chore: Prefer tracing span shorthand macros 2024-06-06 16:52:25 -07:00
roife
4a4b13cbda fix: incorrect formatting of hover actions 2024-06-06 21:07:59 +08:00
bors
af488c971f Auto merge of #17352 - roife:fix-issue-17338, r=Veykril
fix: do not resolve prelude within block modules

fix #17338 (continuing from #17251).

In #17251, we injected preludes into non-top-level modules, which leading to r-a to directly resolve names in preludes in block modules. This PR fix it by checking whether the module is a pseudo-module introduced by blocks. (similar to what we do for extern preludes)
2024-06-06 09:40:39 +00:00
roife
22e82c72ac test: add regression test for prelude shadowing in block modules 2024-06-06 17:03:40 +08:00
roife
c330c62aa2 fix: do not resolve prelude within block modules 2024-06-06 16:55:09 +08:00
Lukas Wirth
3178e5fb5a Fix file loading of r-a toml files 2024-06-06 10:40:41 +02:00
bors
577b0becd0 Auto merge of #17346 - ChosenName:master, r=Veykril
Changed package.json so vscode extension settings have submenus

There are a lot of options that are a part of rust-analyzer, sometimes it can be hard to find an option that you are looking for. To fix this I have put all configurations into categories based on their names. I have also changed the schema in `crates/rust-analyzer/src/config.rs` to reflect this.

Currently for each generated entry the title is redeclared, this does function but I am prepared to change this if it is a problem.
2024-06-06 08:03:17 +00:00
Wilfred Hughes
fcecbc5467 fix: Highlight unlinked files consistently with inactive files
Currently, rust-analyzer highlights the entire region when a `cfg` is
inactive (e.g. `#[cfg(windows)]` on a Linux machine). However,
unlinked files only highlight the first three characters of the file.

This was introduced in #8444, but users have repeatedly found
themselves with no rust-analyzer support for a file and unsure
why (see e.g. #13226 and the intentionally prominent pop-up added in
PR #14366).

(Anecdotally, we see this issue bite our users regularly, particularly
people new to Rust.)

Instead, highlight the entire inactive file, but mark it as all as
unused. This allows users to hover and run the quickfix from any line.

Whilst this is marginally more prominent, it's less invasive than a
pop-up, and users do want to know why they're getting no rust-analyzer
support in certain files.
2024-06-05 17:44:07 -07:00
Lukas Wirth
047b8d9f29 Keep config diagnostics across changes 2024-06-05 14:56:07 +02:00
Lukas Wirth
d537941d1b Diagnose most incorrect ra-toml config errors 2024-06-05 13:09:49 +02:00
bors
48bbdd6a74 Auto merge of #17348 - regexident:fix-type-or-const-param-source, r=Veykril
Use `.get(…)` instead of `[…]` in `TypeOrConstParam::source(…)` and `LifetimeParam::source(…)`

Resolves #17344.
2024-06-05 10:34:31 +00:00
Vincent Esche
78f31696da Resolve #17344 by using .get(…) instead of […] in TypeOrConstParam::source(…)
(… and `LifetimeParam::source(…)`)
2024-06-05 11:03:56 +02:00
Lukas Wirth
c791a3d709 Fix local configs allowing to contain global changes 2024-06-05 10:47:53 +02:00
Lukas Wirth
fb8a2c334f Shuffle around some of the configs between the levels 2024-06-05 10:47:33 +02:00
Ali Bektas
75409f79fd Apply requested changes round 3 2024-06-05 10:45:22 +02:00
Ali Bektas
cf97aac994 Apply requested changes round 2 2024-06-05 10:45:22 +02:00
Ali Bektas
23a5f31ff4 Apply suggested changes 2024-06-05 10:45:19 +02:00
Lukas Wirth
5a7f2dd4b0 Add debug info to invalid offset error 2024-06-05 10:20:05 +02:00
ChosenName
60f67368fe fmt 2024-06-04 22:12:54 -06:00
ChosenName
55540f1f85
Update config.rs 2024-06-04 21:39:37 -06:00
ChosenName
82a8e2a357
Fix typos 2024-06-04 21:30:36 -06:00
ChosenName
49806f9ab9
Update config.rs 2024-06-04 21:09:21 -06:00
Lukas Wirth
9349045e09 Use dyn cache for Semantics macro resolution 2024-06-04 16:25:38 +02:00
Lukas Wirth
7d40763c88 Cache parse trees in Semantics 2024-06-04 15:29:24 +02:00
Lukas Wirth
c12f093716 Cache file_to_def in SourceToDefCtx 2024-06-04 15:23:02 +02:00
Lukas Wirth
97b58f2846 Try caching macro calls more aggressively 2024-06-04 15:23:00 +02:00
bors
f28f15ac6e Auto merge of #17341 - Veykril:inert-attr, r=Veykril
internal: Cleanup some inert attribute stuff
2024-06-04 10:42:15 +00:00
Lukas Wirth
6f0207d594 Cleanup some inert attribute stuff 2024-06-04 12:38:20 +02:00
bors
6bae8e333b Auto merge of #17282 - jkelleyrtp:jk/filter-by-underscorte, r=Veykril
Feat: hide double underscored symbols from symbol search

Fixes #17272 by changing the default behavior of query to skip results that start with `__` (two underscores).

Not sure if this has any far reaching implications - a review would help to understand if this is the right place to do the filtering, and if it's fine to do it by default on the query.

If you type `__` as your search, then we'll show the matching double unders, just in case you actually need the symbol.
2024-06-04 08:37:56 +00:00
Lukas Wirth
0110cfcae0 Recognize __ prefixes for symbol search query 2024-06-04 10:36:04 +02:00
Lukas Wirth
f1dbb958c8 Add fuel to find_path 2024-06-03 20:07:00 +02:00
Lukas Wirth
f94d34bd72 Remove an allocation in find_path::find_local_import_locations 2024-06-03 19:57:49 +02:00
Lukas Wirth
48822e0941 Simplify 2024-06-03 19:46:40 +02:00
Lukas Wirth
426d01eab0 Deduplicate 2024-06-03 19:26:11 +02:00
Lukas Wirth
db80216dac Fix find_path search not reducing scope appropriately for foreign items 2024-06-03 19:21:19 +02:00
Lukas Wirth
60fa981df1 Simplify 2024-06-03 19:06:58 +02:00
bors
89218cf29c Auto merge of #17329 - Nilstrieb:rustc_deprecated_safe_2024, r=Veykril
Don't mark `#[rustc_deprecated_safe_2024]` functions as unsafe

`std::env::set_var` will be unsafe in edition 2024, but not before it. I couldn't quite figure out how to check for the span properly, so for now we just turn the false positives into false negatives, which are less bad.
2024-06-03 12:44:21 +00:00
bors
cb6b808185 Auto merge of #17315 - hamirmahal:style/simplify-string-interpolation, r=Veykril
style: simplify string interpolation
2024-06-03 12:29:27 +00:00
bors
9edc30a42b Auto merge of #17312 - regexident:function-fn-ptr-type, r=Veykril
Add `Function::fn_ptr_type(…)` for obtaining name-erased function type

The use case of this function if being able to group functions by their function ptr type.

cc `@flodiebold`
2024-06-03 12:16:29 +00:00
bors
5ac4be8167 Auto merge of #17333 - DropDemBits:extract-format-args-snippet-cap, r=Veykril
fix: Only generate snippets for `extract_expressions_from_format_string` if snippets are supported

Part of #17332

Fixes `extract_expressions_from_format_string` so that it doesn't generate snippets if the client doesn't support it.
2024-06-03 12:03:18 +00:00
Lukas Wirth
cdb4f9631c Add path info to AbsPathBuf::assert's assert 2024-06-02 21:28:25 +02:00
DropDemBits
a741bb2055
fix typos & formatting 2024-06-02 14:09:36 -04:00
DropDemBits
cf9401049c
Make extract_expressions_from_format_string only use snippets when available 2024-06-02 11:47:05 -04:00
DropDemBits
e989f22015
Add ast::Expr::parse 2024-06-02 11:17:52 -04:00
DropDemBits
c4573b26f6
minor: tidy up Parse a little bit
- Add doc comments to some `Parse` methods
- Uses `Parse::new` more
2024-06-02 11:10:39 -04:00
DropDemBits
3b763a847a
Add tt_from_syntax
Used for inserting syntax nodes into existing token trees
2024-06-02 11:10:07 -04:00
Nilstrieb
0e1353bebd Don't mark #[rustc_deprecated_safe_2024] functions as unsafe
`std::env::set_var` will be unsafe in edition 2024, but not before it.
I couldn't quite figure out how to check for the span properly, so for now
we just turn the false positives into false negatives, which are less bad.
2024-06-02 15:04:26 +02:00
bors
6b9baed80e Auto merge of #17328 - Veykril:derive-helper-completions, r=Veykril
feat: Enable completions within derive helper attributes

![Code_zG5qInoQ6B](https://github.com/rust-lang/rust-analyzer/assets/3757771/db30b98d-4981-45e3-83a5-7ff23fbd3f66)
2024-06-02 07:47:13 +00:00
Lukas Wirth
3116f76fba feat: Enable completions within derive helper attributes 2024-06-02 09:45:57 +02:00
bors
ca5568182d Auto merge of #17326 - Veykril:fix-attr-derive-container, r=Veykril
fix: Fix container search failing for tokens originating within derive attributes
2024-06-01 18:58:59 +00:00
Lukas Wirth
c0171bdd32 fix: Fix container search failing for tokens originating within derive attributes 2024-06-01 20:57:29 +02:00
bors
58a8f1b185 Auto merge of #17302 - mladedav:dm/fix-clear, r=Veykril
fix diagnostics clearing when flychecks run per-workspace

This might be causing #17300 or it's a different bug with the same functionality.

I wonder if the decision to clear diagnostics should stay in the main loop or maybe the flycheck itself should track it and tell the mainloop?

I have used a hash map but we could just as well use a vector since the IDs are `usizes` in some given range starting at 0. It would be probably faster but this just felt a bit cleaner and it allows us to change the ID to newtype later and we can just use a hasher that returns the underlying integer.
2024-06-01 14:14:14 +00:00
David Mládek
a0b2f39273 Move state trackig of diagnostic clearing inside FlycheckActor 2024-06-01 15:59:23 +02:00
bors
5a509cc39f Auto merge of #17278 - chenx97:flycheck-process-wrap, r=lnicola
internal: replace command-group with process-wrap

Because command-group no longer receives updates and depends on an older version of nix.
2024-06-01 08:39:22 +00:00
Luke Franceschini
8c5ef9c15f
docs: Missing word typo 2024-05-31 11:24:26 -04:00
Henry Chen
3c6c5cd0bf minor: replace command-group with process-wrap
Because command-group no longer receives updates and depends on an
older version of nix.
2024-05-31 12:43:40 +08:00
Hamir Mahal
7fa555f8ba
fix: formatting in handlers/unresolved_method.rs 2024-05-30 16:39:41 -07:00
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
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
6de838c255 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
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
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
Lukas Wirth
a9140e197c Fix #[rustc_const_panic_str] functions not actually being hooked 2024-04-18 15:49:08 +02: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
Lukas Wirth
5df690e13f Fixup some issues with minicore 2024-04-18 12:20:54 +02:00
Lukas Wirth
563bb6bd6c Fix missing function body in minicore 2024-04-18 12:20:54 +02:00
Nilstrieb
805f569adc Handle panicking like rustc CTFE does
Instead of using `core::fmt::format` to format panic messages, which may in turn
panic too and cause recursive panics and other messy things, redirect
`panic_fmt` to `const_panic_fmt` like CTFE, which in turn goes to
`panic_display` and does the things normally. See the tests for the full
call stack.
2024-04-18 12:20:54 +02: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
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
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
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
roife
6bb85985d7 fix: adjust the limitation for ADTs' fields to 5 2024-04-16 16:28:23 +08:00
roife
c06d670f8f fix: the fields or variants of ADT was not restricted by limitations when hovering on Self type 2024-04-16 16:27:57 +08:00
roife
01c3559bf3 Update tests and docs for hover_show_adtFieldsOrVariants 2024-04-16 16:27:56 +08:00
roife
21da6c6164 Add config hover_show_adtFieldsOrVariants to handle hovering limitation for ADTs 2024-04-16 16:26:23 +08:00