Commit graph

13327 commits

Author SHA1 Message Date
Chayim Refael Friedman
737a969aa5 Add helper methods to retrieve Future::Output and Iterator::Item 2024-08-24 23:46:32 +03:00
Chayim Refael Friedman
2c6a521bab Provide Future::Output and Iterator lang items 2024-08-24 23:46:32 +03:00
Chayim Refael Friedman
1e0df17667 Handle associated types that are lang items
Previously we were ignoring them.
2024-08-24 23:46:32 +03:00
Chayim Refael Friedman
cf243e5211 Add gen modifier to functions
We don't yet lower or maybe even parse them, but blocks already have `gen`, so why not.
2024-08-24 23:46:32 +03:00
Chayim Refael Friedman
77ab5686c6 Preserve all spans for closure captures, not just one
This is important for the "convert closure to fn" assist, as it needs to find and modify the places the captures are used.
2024-08-24 23:46:32 +03:00
Chayim Refael Friedman
12faedd9b0 Fix few bugs in closure capture computation, and add tests
Also create a test infrastructure for capture computation.
2024-08-24 22:35:49 +03:00
bors
1b0e158df4 Auto merge of #17943 - Veykril:diags, r=Veykril
fix: Improve proc-macro panic message and workspace loading failure diagnostic
2024-08-22 16:47:56 +00:00
Lukas Wirth
0a277110b3 Improve proc-macro panic message and workspace loading failure diagnostic 2024-08-22 18:46:23 +02:00
bors
81a9956eb9 Auto merge of #17898 - Veykril:descend-2.0, r=Veykril
internal: Improve macro token mapping heuristics

Fixes https://github.com/rust-lang/rust-analyzer/issues/16235
2024-08-22 16:17:22 +00:00
Lukas Wirth
71c7ceaf52 Fix sorting order for tokens in hover 2024-08-22 18:08:36 +02:00
Lukas Wirth
f9db48f8c9 Consider interleaving hover kinds 2024-08-22 17:29:32 +02:00
Lukas Wirth
b0e7ef4031 Sort hover results by relevance 2024-08-22 17:01:51 +02:00
Lukas Wirth
d79999aaa0 Thread file id through descension API for semantic highlighting 2024-08-22 16:45:37 +02:00
Lukas Wirth
4d614444b9 Rename macro descension functions 2024-08-22 16:24:01 +02:00
Lukas Wirth
8e82e44677 Fully remove old macro descension API 2024-08-22 16:18:01 +02:00
Lukas Wirth
1179cbb258 Remove DescendPreference::SameKind 2024-08-22 16:00:57 +02:00
hkalbasi
aeb9c7b279 Implement floating point casts in const eval 2024-08-22 09:16:00 -04:00
Lukas Wirth
d893dcc43f Drop MacroInputKind 2024-08-22 12:39:53 +02:00
Lukas Wirth
f84553641c Remove DescendPreference::SameText 2024-08-22 12:34:20 +02:00
Shoyu Vanilla
db2e8e1ed0 fix: Wrong Sized predicate for generic_predicates_for_param 2024-08-22 00:32:44 +09:00
bors
9cb66c2c02 Auto merge of #17913 - alibektas:ratoml_improvements, r=alibektas
fix: Add workspace level config to ratoml
2024-08-20 11:25:19 +00:00
bors
085aac3afc Auto merge of #17930 - Veykril:config-user-config, r=alibektas
Remove the ability to configure the user config path

Being able to do this makes little sense as this is effectively a cyclic dependency (and we do not want to fixpoint this really).
2024-08-20 11:10:55 +00:00
Ali Bektas
1b2eaa59b2 Old configs are back 2024-08-20 12:35:56 +02:00
Ali Bektas
8e31598829 Next up : generating configs for workspace level configs 2024-08-20 12:35:56 +02:00
Ali Bektas
a42c732c53 Define workspace level configs. 2024-08-20 12:35:54 +02:00
Lukas Wirth
a7d15a8c3b fix: Fix panics for semantic highlighting at startup 2024-08-20 09:53:37 +02:00
Wilfred Hughes
f25cb8073c ServerStatusParams should consider 'prime caches' in quiescent status
Priming caches is a performance win, but it takes a lock on the salsa
database and prevents rust-analyzer from responding to e.g. go-to-def
requests.

This causes confusion for users, who see the spinner next to
rust-analyzer in the VS Code footer stop, so they start attempting to
navigate their code.

Instead, set the `quiescent` status in LSP to false during cache
priming, so the VS Code spinner persists until we can respond to any
LSP request.
2024-08-19 10:27:53 -07:00
Shoyu Vanilla
ea12d79b3a fix: Panic when a TAIT exists in a RPIT 2024-08-19 23:07:13 +09:00
Lukas Wirth
879fa66c88 Allow user config to not exist 2024-08-19 16:00:06 +02:00
Lukas Wirth
bd6ea758cc Remove the ability to configure the user config path 2024-08-19 15:12:33 +02:00
Lukas Wirth
b2062ea49f Improve documentation for InvocationStrategy 2024-08-19 14:23:05 +02:00
bors
05f5c7794d Auto merge of #17928 - roife:fix-issue-17869, r=Veykril
fix: keep comments in convert_while_to_loop

Fix #17869.
2024-08-19 10:20:50 +00:00
roife
036affcdee fix: keep comments in convert_while_to_loop 2024-08-19 17:27:54 +08:00
bors
85f6d15a09 Auto merge of #17888 - Tyrubias:remove-invocation-location, r=Veykril
chore(config): remove `invocationLocation` in favor of `invocationStrategy`

These flags were added to help rust-analyzer integrate with repos requiring non-Cargo invocations. The consensus is that having two independent settings are no longer needed. This change removes `invocationLocation` in favor of `invocationStrategy` and changes the internal representation of `InvocationStrategy::Once` to hold the workspace root.

Closes #17848.
2024-08-19 08:19:38 +00:00
Victor Song
1bfb362d7f chore(config): remove invocationLocation in favor of invocationStrategy
These flags were added to help rust-analyzer integrate with repos
requiring non-Cargo invocations. The consensus is that having two
independent settings are no longer needed. This change removes
`invocationLocation` in favor of `invocationStrategy` and changes
the internal representation of `InvocationStrategy::Once` to hold
the workspace root.
2024-08-19 02:25:40 -05:00
David Richey
74db4d309a Include generics when lowering extern type 2024-08-18 15:12:01 -05:00
bors
51e3775faf Auto merge of #17915 - Veykril:offline-no-deps, r=Veykril
feat: Make rust-analyzer work partially when offline

Helps out with https://github.com/rust-lang/rust-analyzer/issues/12499 a bit
2024-08-17 17:20:39 +00:00
Lukas Wirth
324cf839bd Adress new clippy::large_enum_variant diagnostics 2024-08-17 19:18:56 +02:00
Lukas Wirth
d0ce97f41d feat: Make rust-analyzer work partially when missing an internet connection 2024-08-17 19:14:46 +02:00
bors
eb12861e48 Auto merge of #17916 - ShoyuVanilla:issue-17711, r=Veykril
fix: Wrong BoundVar index when lowering impl trait parameter of parent generics

Fixes #17711

From the following test code;

```rust
//- minicore: deref
use core::ops::Deref;

struct Struct<'a, T>(&'a T);

trait Trait {}

impl<'a, T: Deref<Target = impl Trait>> Struct<'a, T> {
    fn foo(&self) -> &Self { self }

    fn bar(&self) {
        let _ = self.foo();
    }

}
```

when we call `register_obligations_for_call` for `let _ = self.foo();`,

07659783fd/crates/hir-ty/src/infer/expr.rs (L1939-L1952)

we are querying `generic_predicates` and it has `T: Deref<Target = impl Trait>` predicate from the parent `impl Struct`;

07659783fd/crates/hir-ty/src/lower.rs (L375-L399)

but as we can see above, lowering `TypeRef = impl Trait` doesn't take into account the parent generic parameters, so the `BoundVar` index here is `0`, as `fn foo` has no generic args other than parent's,

But this `BoundVar` is pointing at `'a` in `<'a, T: Deref<Target = impl Trait>>`.
So, in the first code reference `register_obligations_for_call`'s L:1948 - `.substitute(Interner, parameters)`, we are substituting `'a` with `Ty`, not `Lifetime` and this makes panic inside the chalk.

This PR fixes this wrong `BoundVar` index in such cases
2024-08-17 17:00:52 +00:00
Shoyu Vanilla
c4b8c657e4 fix: Wrong BoundVar index when lowering impl trait parameter of parent generics 2024-08-17 22:33:27 +09:00
Shoyu Vanilla
d3fa5e9c2b Pin rowan to 0.15.15 2024-08-17 21:35:07 +09:00
David Richey
6fc487d2cc Remove rust-analyzer.workspace.discoverProjectRunner 2024-08-16 09:50:45 -05:00
bors
995a014192 Auto merge of #17900 - darichey:exclude-vendored-libraries, r=davidbarsky
Add scip/lsif flag to exclude vendored libaries

#17809 changed StaticIndex to include vendored libraries. This PR adds a flag to disable that behavior.

At work, our monorepo has too many rust targets to index all at once, so we split them up into several shards. Since all of our libraries are vendored, if rust-analyzer includes them, sharding no longer has much benefit, because every shard will have to index the entire transitive dependency graphs of all of its targets. We get around the issue presented in #17809 because some other shard will index the libraries directly.
2024-08-16 14:25:36 +00:00
bors
690845109b Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykril
fix: Properly account for editions in names

This PR touches a lot of parts. But the main changes are changing `hir_expand::Name` to be raw edition-dependently and only when necessary (unrelated to how the user originally wrote the identifier), and changing `is_keyword()` and `is_raw_identifier()` to be edition-aware (this was done in #17896, but the FIXMEs were fixed here).

It is possible that I missed some cases, but most IDE parts should properly escape (or not escape) identifiers now.

The rules of thumb are:

 - If we show the identifier to the user, its rawness should be determined by the edition of the edited crate. This is nice for IDE features, but really important for changes we insert to the source code.
 - For tests, I chose `Edition::CURRENT` (so we only have to (maybe) update tests when an edition becomes stable, to avoid churn).
 - For debugging tools (helper methods and logs), I used `Edition::LATEST`.

Reviewing notes:

This is a really big PR but most of it is mechanical translation. I changed `Name` displayers to require an edition, and followed the compiler errors. Most methods just propagate the edition requirement. The interesting cases are mostly in `ide-assists`, as sometimes the correct crate to fetch the edition from requires awareness (there may be two). `ide-completions` and `ide-diagnostics` were solved pretty easily by introducing an edition field to their context. `ide` contains many features, for most of them it was propagated to the top level function and there the edition was fetched based on the file.

I also fixed all FIXMEs from #17896. Some required introducing an edition parameter (usually not for many methods after the changes to `Name`), some were changed to a new method `is_any_identifier()` because they really want any possible keyword.

Fixes #17895.
Fixes #17774.
2024-08-16 13:49:32 +00:00
Chayim Refael Friedman
3d6129dccd Properly account for editions in names
This PR touches a lot of parts. But the main changes are changing
`hir_expand::Name` to be raw edition-dependently and only when necessary
(unrelated to how the user originally wrote the identifier),
and changing `is_keyword()` and `is_raw_identifier()` to be edition-aware
(this was done in #17896, but the FIXMEs were fixed here).

It is possible that I missed some cases, but most IDE parts should properly
escape (or not escape) identifiers now.

The rules of thumb are:

 - If we show the identifier to the user, its rawness should be determined
   by the edition of the edited crate. This is nice for IDE features,
   but really important for changes we insert to the source code.
 - For tests, I chose `Edition::CURRENT` (so we only have to (maybe) update
   tests when an edition becomes stable, to avoid churn).
 - For debugging tools (helper methods and logs), I used `Edition::LATEST`.
2024-08-16 16:46:24 +03:00
dfireBird
4ca597a4a8
implement basic inferring of lifetimes 2024-08-16 16:40:32 +05:30
bors
fdd5294afb Auto merge of #17903 - tmandry:graceful-exit, r=Veykril
Allow flycheck process to exit gracefully

Assuming it isn't cancelled. Closes #17902.

The only place CommandHandle::join() is used is when the flycheck command
finishes, so this commit changes the behavior of the method itself.

The only reason I can see for the existing behavior is if the command is somehow holding onto a build lock longer than it should, this would force it to be released. But it would be a pretty heavy-handed way to solve that issue. I'm not aware of this occurring in practice.
2024-08-16 07:35:16 +00:00
bors
95f5e4b626 Auto merge of #17908 - ChayimFriedman2:usages-word-boundaries, r=Veykril
Test for word boundary in `FindUsages`

This speeds up short identifiers search significantly, while unlikely to have an effect on long identifiers (the analysis takes much longer than some character comparison).

Tested by finding all references to `eq()` (from `PartialEq`) in the rust-analyzer repo. Total time went down from 100s to 10s (a 10x reduction!).

Feel free to close this if you consider this a non-issue, as most short identifiers are local.
2024-08-16 07:20:23 +00:00
bors
b68992a510 Auto merge of #17907 - ChayimFriedman2:no-once_cell, r=Veykril
internal: Replace once_cell with std's recently stabilized OnceCell/Lock and LazyCell/Lock

This doesn't get rid of the once_cell dependency, unfortunately, since we have dependencies that use it, but it's a nice to do cleanup. And when our deps will eventually get rid of once_cell we will get rid of it for free.
2024-08-16 07:05:59 +00:00