about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates
AgeCommit message (Collapse)AuthorLines
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-111/+29
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-111/+29
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-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-47/+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-47/+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-100/+189
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`.
2024-08-14Be more resilient to bad language item definitions in binop inferenceLaurențiu Nicola-9/+45
2024-08-14Auto merge of #17885 - Wilfred:op_queue_docs, r=lnicolabors-0/+20
minor: Add a doc comment for OpQueue Add an explanatory sentence and some sample code to help readers understand why this struct exists.
2024-08-13docs: Add a doc comment for OpQueueWilfred Hughes-0/+20
Add an explanatory sentence and some sample code to help readers understand why this struct exists.
2024-08-13Merge from rust-lang/rustLaurențiu Nicola-0/+2
2024-08-13Bump `rustc_pattern_analysis`Shoyu Vanilla-8/+8
2024-08-13Temporarily remove non-working test caseShoyu Vanilla-12/+2
2024-08-13feat: `min-exhaustive-patternsShoyu Vanilla-15/+131
2024-08-13Auto merge of #17876 - Veykril:semantics-include-simplify, r=Veykrilbors-88/+18
internal: Remove unreachable logic for include token mapping Turns out https://github.com/rust-lang/rust-analyzer/pull/17863 made this obsolete 🎉
2024-08-13Remove unreachable logic for include token mappingLukas Wirth-88/+18
2024-08-13Auto merge of #17867 - ShoyuVanilla:issue-17854, r=Veykrilbors-2/+27
fix: Trailing excess comma in "Convert to named struct" assist Fixes #17854
2024-08-12Allow declaring cfg groups in rust-project.json, to help sharing common cfgsChayim Refael Friedman-4/+607
2024-08-12fix: Trailing excess comma in "Convert to named struct" assistShoyu Vanilla-2/+27
2024-08-12fix: Missing non-exhaustive let diagnostics inside async or unsafe blockShoyu Vanilla-2/+46
2024-08-12Auto merge of #17864 - Veykril:lsif, r=Veykrilbors-5/+16
fix: Build and run build scripts in lsif command
2024-08-12Build and run build scripts in lsif commandLukas Wirth-5/+16
2024-08-12Auto merge of #17863 - Veykril:include-diags, r=Veykrilbors-56/+93
fix: Resolve included files to their calling modules in IDE layer Fixes https://github.com/rust-lang/rust-analyzer/issues/17390 at the expense of reporting duplicate diagnostics for modules that have includes in them when both the calling and called file are included.
2024-08-12Resolve included files to their calling modules in IDE layerLukas Wirth-56/+93
2024-08-12Auto merge of #17850 - Veykril:rust-analyzer-crate, r=Veykrilbors-25/+69
internal: Reply to requests with defaults when vfs is still loading There is no reason for us to hit the database with queries when we certainly haven't reached a stable state yet. Instead we just reply with default request results until we are in a state where we can do meaningful work. This should save us from wasting resources while starting up at worst, and at best save us from creating query and interning entries that are non-meaningful which ultimately just end up wasting memory.
2024-08-12internal: Reply to requests with defaults when vfs is still loadingLukas Wirth-25/+69