about summary refs log tree commit diff
path: root/src/tools/rust-analyzer
AgeCommit message (Collapse)AuthorLines
2024-08-22Remove DescendPreference::SameKindLukas Wirth-37/+53
2024-08-22Implement floating point casts in const evalhkalbasi-3/+102
2024-08-22Drop MacroInputKindLukas Wirth-74/+24
2024-08-22Remove DescendPreference::SameTextLukas Wirth-229/+304
2024-08-22fix: Wrong `Sized` predicate for `generic_predicates_for_param`Shoyu Vanilla-0/+4
2024-08-21internal: Implement `module_path` macroLukas Wirth-71/+279
2024-08-21Run flycheck only on crate if target is binary.Ali Bektas-27/+58
2024-08-20Auto merge of #17913 - alibektas:ratoml_improvements, r=alibektasbors-113/+164
fix: Add workspace level config to ratoml
2024-08-20Auto merge of #17930 - Veykril:config-user-config, r=alibektasbors-65/+75
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-20Old configs are backAli Bektas-0/+61
2024-08-20Next up : generating configs for workspace level configsAli Bektas-110/+48
2024-08-20Define workspace level configs.Ali Bektas-90/+142
2024-08-20fix: Fix panics for semantic highlighting at startupLukas Wirth-4/+14
2024-08-19ServerStatusParams should consider 'prime caches' in quiescent statusWilfred Hughes-4/+19
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-19fix: Panic when a TAIT exists in a RPITShoyu Vanilla-11/+85
2024-08-19Allow user config to not existLukas Wirth-15/+10
2024-08-19Remove the ability to configure the user config pathLukas Wirth-66/+81
2024-08-19Improve documentation for `InvocationStrategy`Lukas Wirth-23/+29
2024-08-19Auto merge of #17928 - roife:fix-issue-17869, r=Veykrilbors-8/+89
fix: keep comments in convert_while_to_loop Fix #17869.
2024-08-19fix: keep comments in convert_while_to_looproife-8/+89
2024-08-19Auto merge of #17888 - Tyrubias:remove-invocation-location, r=Veykrilbors-173/+33
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-19chore(config): remove `invocationLocation` in favor of `invocationStrategy`Victor Song-173/+33
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-18Include generics when lowering extern typeDavid Richey-5/+21
2024-08-17Auto merge of #17915 - Veykril:offline-no-deps, r=Veykrilbors-24/+85
feat: Make rust-analyzer work partially when offline Helps out with https://github.com/rust-lang/rust-analyzer/issues/12499 a bit
2024-08-17Adress new clippy::large_enum_variant diagnosticsLukas Wirth-7/+10
2024-08-17feat: Make rust-analyzer work partially when missing an internet connectionLukas Wirth-17/+75
2024-08-17Auto merge of #17916 - ShoyuVanilla:issue-17711, r=Veykrilbors-18/+50
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();`, https://github.com/rust-lang/rust-analyzer/blob/07659783fdfd4ec0a0bffa93017e33e31e567e42/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`; https://github.com/rust-lang/rust-analyzer/blob/07659783fdfd4ec0a0bffa93017e33e31e567e42/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-17fix: Wrong BoundVar index when lowering impl trait parameter of parent genericsShoyu Vanilla-18/+50
2024-08-17Pin `rowan` to `0.15.15`Shoyu Vanilla-1/+1
2024-08-16Rollup merge of #129086 - slanterns:is_none_or, r=dtolnayMatthias Krüger-1/+1
Stabilize `is_none_or` Closes: https://github.com/rust-lang/rust/issues/126383. `@rustbot` label: +T-libs-api r? libs-api
2024-08-16Remove rust-analyzer.workspace.discoverProjectRunnerDavid Richey-12/+0
2024-08-16Auto merge of #17900 - darichey:exclude-vendored-libraries, r=davidbarskybors-19/+95
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-16Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykrilbors-1245/+2480
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-16Properly account for editions in namesChayim Refael Friedman-1245/+2480
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-16implement basic inferring of lifetimesdfireBird-85/+109
2024-08-16Auto merge of #17903 - tmandry:graceful-exit, r=Veykrilbors-1/+0
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-16Auto merge of #17908 - ChayimFriedman2:usages-word-boundaries, r=Veykrilbors-0/+14
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-16Auto merge of #17907 - ChayimFriedman2:no-once_cell, r=Veykrilbors-54/+49
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-16Test for word boundary in `FindUsages`Chayim Refael Friedman-0/+14
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!).
2024-08-16Replace once_cell with std's recently stabilized OnceCell/Lock and LazyCell/LockChayim Refael Friedman-54/+49
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-15Allow flycheck process to exit gracefullyTyler Mandry-1/+0
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.
2024-08-15Add scip/lsif flag to exclude vendored libariesDavid Richey-19/+95
2024-08-15internal: Properly check the edition for edition dependent syntax kindsLukas Wirth-129/+347
2024-08-15Auto merge of #17893 - ShoyuVanilla:issue-17871, r=flodieboldbors-8/+35
fix: Panic while hovering associated function with type annotation on generic param that not inherited from its container type Fixes #17871 We call `generic_args_sans_defaults` here; https://github.com/rust-lang/rust-analyzer/blob/64a140527b383e3a2fe95908881624fc5374c60c/crates/hir-ty/src/display.rs#L1021-L1034 but the following substitution inside that function panic in #17871; https://github.com/rust-lang/rust-analyzer/blob/64a140527b383e3a2fe95908881624fc5374c60c/crates/hir-ty/src/display.rs#L1468 it's because the `Binders.binder` inside `default_parameters` has a same length with the generics of the function we are hovering on, but the generics of it is split into two, `fn_params` and `parent_params`. Because of this, it may panic if the function has one or more default parameters and both `fn_params` and `parent_params` are non-empty, like the case in the title of this PR. So, we must call `generic_args_sans_default` first and then split it into `fn_params` and `parent_params`
2024-08-15fix: Panic while displaying associated function with a type annotationShoyu Vanilla-8/+35
2024-08-14rust-analyzer: use in-tree pattern_analysis crateNadrieril-2/+4
2024-08-15fix r-aSlanterns-1/+1
2024-08-14Auto merge of #17882 - ShoyuVanilla:issue-17866, r=lnicolabors-3/+35
fix: Panic while canonicalizing erroneous projection type Fixes #17866 The root cause of #17866 is quite horrifyng 😨 ```rust trait T { type A; } type Foo = <S as T>::A; // note that S isn't defined fn main() { Foo {} } ``` While inferencing alias type `Foo = <S as T>::A`; https://github.com/rust-lang/rust-analyzer/blob/78c2bdce860dbd996a8083224d01a96660dd6a15/crates/hir-ty/src/infer.rs#L1388-L1398 the error type `S` in it is substituted by inference var in L1396 above as below; https://github.com/rust-lang/rust-analyzer/blob/78c2bdce860dbd996a8083224d01a96660dd6a15/crates/hir-ty/src/infer/unify.rs#L866-L869 This new inference var's index is `1`, as the type inferecing procedure here previously inserted another inference var into same `InferenceTable`. But after that, the projection type made from the above then passed to the following function; https://github.com/rust-lang/rust-analyzer/blob/78c2bdce860dbd996a8083224d01a96660dd6a15/crates/hir-ty/src/traits.rs#L88-L96 here, a whole new `InferenceTable` is made, without any inference var and in the L94, this table calls; https://github.com/rust-lang/rust-analyzer/blob/78c2bdce860dbd996a8083224d01a96660dd6a15/crates/hir-ty/src/infer/unify.rs#L364-L370 And while registering `AliasEq` `obligation`, this obligation contains inference var `?1` made from the previous table, but this table has only one inference var `?0` made at L365. So, the chalk panics when we try to canonicalize that obligation to register it, because the obligation contains an inference var `?1` that the canonicalizing table doesn't have. Currently, we are calling `InferenceTable::new()` to do some normalizing, unifying or coercing things to some targets that might contain inference var that the new table doesn't have. I think that this is quite dangerous footgun because the inference var is just an index that does not contain the information which table does it made from, so sometimes this "foreign" index might cause panic like this case, or point at the wrong variable. This PR mitigates such behaviour simply by inserting sufficient number of inference vars to new table to avoid such problem. This strategy doesn't harm current r-a's intention because the inference vars that passed into new tables are just "unresolved" variables in current r-a, so this is just making sure that such "unresolved" variables exist in the new table
2024-08-14fix: Panic while canonicalizing erroneous projection typeShoyu Vanilla-3/+35
2024-08-14Auto merge of #17891 - lnicola:binop-bad-lang-items, r=flodieboldbors-9/+45
internal: Be more resilient to bad language item definitions in binop inference Fixes #16287 Fixes #16286 There's one more in `write_fn_trait_method_resolution`, but I'm not sure if it won't cause further problems in `infer_closures`.