Commit graph

260963 commits

Author SHA1 Message Date
Ali Bektas
45ef4f2c32 Remove unnec copying of source_root_ids 2024-07-29 03:46:02 +02:00
Ali Bektas
59c465b6e2 add skip_slow_tests to ratoml tests 2024-07-29 03:43:27 +02:00
Ali Bektas
adefc44f31 Combine krate_ratoml and workspace_ratomls into one 2024-07-29 03:39:47 +02:00
Ali Bektas
6c98665d91 Down to 1 failing test
And that is due to a case where we have two ratomls in a source root, one of which
is a `workspace_ratoml` and the other one is simple old ratoml. Since we are not checking to see if
the source root is already populated with workspace ratoml, this test fails. Due to principles of clear
code I believe it is reasonable to not have two HashMaps that are almost for the exact same thing.
So next commit should remove `workspace_ratoml` and merge it with `krate_ratoml`s.
2024-07-27 23:52:40 +02:00
Ali Bektas
c9cb05c412 Globals too are asking for sourcerootid 2024-07-26 03:04:29 +02:00
Ali Bektas
93e50c988e Turn root_ratoml into workspace_ratomls 2024-07-26 02:38:02 +02:00
bors
7f314c643d Auto merge of #17676 - winstxnhdw:precise-capturing, r=Veykril
feat: add preliminary support for `+ use<..>` `precise_capturing` syntax

## Summary

This PR adds basic support for the following syntax.

```rs
fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T> {}
//                                  ~~~~~~~~~~~~~~~~~~~~~~~
//                          This opaque type does not capture `'a`.

fn outlives<'o, T: 'o>(_: T) {}

fn caller<'o, 'a, 'b: 'o, T: 'o>() {
    //        ~~
    //        ^ Note that we don't need `'a: 'o`.
    outlives::<'o>(captures::<'a, 'b, T>());
}
```

Related to #17598
2024-07-25 11:10:56 +00:00
Winston H.
71e3d88281 fix: handle new TypeBoundKind variant 2024-07-25 10:58:25 +00:00
bors
0adc1e389a Auto merge of #17697 - Veykril:cargo-env, r=Veykril
fix: Support new cargo config get env format

Fixes https://github.com/rust-lang/rust-analyzer/issues/17686
2024-07-25 10:30:03 +00:00
Lukas Wirth
516a1b47b4 fix: Support new cargo config get env format 2024-07-25 12:28:31 +02:00
bors
900ca457f7 Auto merge of #17695 - Veykril:typeref-size, r=Veykril
internal: Reduce size of TypeRef by 8 bytes
2024-07-25 09:52:30 +00:00
Lukas Wirth
08f7e164cc Make legacy_const_generics_indices thin by double boxing as its seldom used 2024-07-25 11:51:15 +02:00
Lukas Wirth
b3f5af205d Reduce size of TypeRef by 8 bytes 2024-07-25 11:14:55 +02:00
bors
5bded7cac0 Auto merge of #17693 - Veykril:astidmap, r=Veykril
Remove Params and Fields from AstIdMap

These are too volatile, and the only reason for them seems to be for cfg diagnostics which does not carry the weight
2024-07-25 09:06:34 +00:00
Lukas Wirth
d744b7c71b Fix incorrect handling of cfg'd varargs 2024-07-25 11:02:19 +02:00
Lukas Wirth
8e0d60e115 Remove Params and Fields from AstIdMap 2024-07-25 10:22:05 +02:00
Lukas Wirth
896639683c Generate From impls for Any* nodes 2024-07-25 10:21:58 +02:00
winstxnhdw
113c45847a fix: temporarily use ast::GenericParamList 2024-07-25 07:40:08 +01:00
bors
3480bedcdd Auto merge of #17690 - lnicola:unsafe_op_in_unsafe_fn, r=lnicola
internal: Fix and enable unsafe_op_in_unsafe_fn

Closes #17689
2024-07-25 06:05:30 +00:00
Laurențiu Nicola
d7968e5393 Fix and enable unsafe_op_in_unsafe_fn 2024-07-25 08:41:30 +03:00
bors
5fd18ee953 Auto merge of #17674 - davidbarsky:david/add-more-information-to-status-command, r=Veykril
internal: add more output to the status command

Bit of a lazy change, but this is was pretty handy. I think I should clean up the configuration into something a bit more legible (maybe serialize as JSON?), but I think this is a good enough starting point that we might as well start asking people for it in issue reports.
2024-07-24 10:10:58 +00:00
bors
20c6698066 Auto merge of #17610 - regexident:impl-all_in_module, r=Veykril
Add method `Impl::all_in_module(…)` for allowing more localized querying

This PR is motivated by an [outside use](https://github.com/regexident/cargo-modules) of the `ra_ap_hir` crate that would benefit from being able to more efficiently query for all impls of a given module (instead of having to query for its parent crate's impls and then filtering on `impl_hir.module(db) == module_hir`).

I have the suspicion that the code as is won't quite work for file-level modules, since those don't have a block, afaict, but with all the crate-rename and version shenanigans around the `ra_ap_` release process I haven't yet been able to figure out how to patch a `ra_ap_` dependency from a third-party crate (let alone how to test this from inside of `rust-analyzer`), so haven't been able to actually run and test this. 😔

Any hints on how to make this (i.e. the code itself, as well as the testing) work are more than welcome!
2024-07-24 09:56:56 +00:00
bors
dbdf992b87 Auto merge of #17661 - alibektas:read_ratoml_on_startup, r=Veykril
minor: Read workspace root ratomls on startup
2024-07-24 09:42:49 +00:00
Winston H.
75e5dadfa5
fix: use cannot have optional generics
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2024-07-24 10:42:20 +01:00
winstxnhdw
a0e1256515 fix: move use parsing to outer match arm 2024-07-23 22:36:46 +01:00
winstxnhdw
316616af11 chore: update codegens 2024-07-23 22:36:46 +01:00
winstxnhdw
243b68def0 feat: add arm for use type bound 2024-07-23 22:36:46 +01:00
winstxnhdw
3a2f250d33 feat: add use type bound grammar 2024-07-23 22:36:46 +01:00
bors
9751cbc7f9 Auto merge of #17395 - davidbarsky:david/remove-unindexed-project-notification, r=Veykril
chore: remove `UnindexinedProject` notification

This PR is split out from https://github.com/rust-lang/rust-analyzer/pull/17246/ (and contains its changes, which is a little annoying from a review perspective...). I'd like to land this change a week or so after #17246 lands in order to give any users of the unindexed project notification time to adopt migrate.
2024-07-23 17:38:41 +00:00
David Barsky
06fe4e6b6e internal: remove UnindexedProject notification
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
2024-07-23 13:34:04 -04:00
bors
c611e440d4 Auto merge of #17483 - alibektas:ratoml/fixes, r=alibektas
minor : fixes for ratoml module

This is a follow-up PR to #17058.

- Parse errors are reflected as such by defining a new variant called `ConfigError::ParseError`
- New error collection has been added to store config level agnostic errors.

EDIT : Some things that this PR promised to solve are removed and will be addressed by other PRs
2024-07-23 14:13:45 +00:00
Ali Bektas
abdad6f45c rename config::ConfigChange::other_errors to validation_errors 2024-07-23 15:54:39 +02:00
Ali Bektas
f1e237139b minor changes 2024-07-23 15:50:12 +02:00
Vincent Esche
0cbee3bba5 Add method Impl::all_in_module(…) for supporting more localized querying 2024-07-23 14:43:38 +02:00
bors
b8e83b78eb Auto merge of #17675 - PaulDotSH:remove-lens-force-custom-commands-config, r=lnicola
Remove lens.forceCustomCommands config

Closes https://github.com/rust-lang/rust-analyzer/issues/17643
A very simple PR that removes the lens.forceCustomCommands config feature without side effects.
2024-07-23 08:25:58 +00:00
PaulDotSH
fdbd9bee57 Remove lens.forceCustomCommands config 2024-07-23 03:27:28 -04:00
David Barsky
8c6dd09507 internal: add more output to the status command 2024-07-22 15:23:49 -04:00
bors
28b8c2443b Auto merge of #17671 - Veykril:binding-size, r=Veykril
internal: Shrink size of `Binding`

This should save a bit of memory now that we LRU the source map
2024-07-22 15:16:05 +00:00
Lukas Wirth
83a3087f94 internal: Shrink size of Binding 2024-07-22 17:14:17 +02:00
bors
be1dc79ed9 Auto merge of #17670 - Veykril:mem, r=Veykril
LRU `body_with_source_map` query

This query is being invalidated all the time anyways (we have an extra query on top of it for the body incrementality that is not source dependent), so there is little reason to keep these around all the time when only some IDE features are interested in them.
2024-07-22 14:48:05 +00:00
Lukas Wirth
cdb7d3ec93 LRU body_with_source_map query 2024-07-22 16:34:59 +02:00
bors
e651da9ff3 Auto merge of #17668 - Veykril:incorrect-nevers, r=Veykril
Remove incorrect never! invocations

These can crop up when the `Future` related lang items are missing
2024-07-22 09:36:15 +00:00
bors
a187a8992d Auto merge of #17542 - roife:fix-issue-17517, r=Veykril
feat: go-to-def and find-references on control-flow keywords

fix #17517.

This PR implements **go-to-definition** and **find-references** functionalities for control flow keywords, which is similar to the behaviors in the `highlight-related` module. Besides, this PR also fixes some incorrect behaviors in `highlight-related`.

## Changes

1. **Support for go-to-definition on control flow keywords**:
   This PR introduces functionality allowing users to navigate on the definition of control flow keywords (`return`, `break`, `continue`).
   Commit: 2a3244ee147f898dd828c06352645ae1713c260f..7391e7a608634709db002a4cb09229de4d12c056.

2. **Bug fixes and refactoring in highlight-related**:
   - **Handling return/break/continue within try_blocks**:
     This PR adjusted the behavior of these keywords when they occur within `try_blocks`. When encounter these keywords, the program should exit the outer function or loop which containing the `try_blocks`, rather than the `try_blocks` itself; while the `?` will cause the program to exit `try_blocks`.
     Commit: 59d697e807f0197f59814b37dca1563959da4aa1.
   - **Support highlighting keywords in macro expansion for highlight-related**:
     Commit: 88df24f01727c23a667a763ee3ee0cec22d5ad52.
   - Detailed description for the bug fixes
     + The previous implementation of `preorder_expr` incorrectly treated `try_blocks` as new contexts, thereby r-a will not continue to traverse inner `return` and `break/continue` statements. To resolve this, a new function `preorder_expr_with_ctx_checker` has been added, allowing users to specify which expressions to skip.
       * For example, when searching for the `?` in the context, r-a should skip `try_blocks` where the `?` insides just works for `try_blocks`. But when search for the `return` keyword, r-a should collect both the `return` keywords inside and outside the `try_blocks`
     + Thus, this PR added `WalkExpandedExprCtx` (builder pattern). It offers the following improvements: customizable context skipping, maintenance of loop depth (for `break`/`continue`), and handling macro expansion during traversal.

3. **Support for find-references on control flow keywords**:
   This PR enables users to find all references to control flow keywords.
   Commit: 9202a33f81218fb9c2edb5d42e6b4de85b0323a8.
2024-07-22 09:22:13 +00:00
bors
da6e4c8f11 Auto merge of #17586 - ShoyuVanilla:tuple-arg-macro-rest, r=Veykril
Allow macro expansions into `RestPat` in tuple args work as ellipsis like plain `RestPat`

Fixes #17292

Currently, Rust Analyzer lowers `ast::Pat::RestPat` into `Pat::Missing` in general cases on the following lines;

ffbc5ad993/crates/hir-def/src/body/lower.rs (L1359-L1367)

And in some proper positions such as `TupleStruct(..)`, it is specially handed on the following lines;

ffbc5ad993/crates/hir-def/src/body/lower.rs (L1429-L1437)

This behavior is reasonable because rustc does similar things in
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L108-L111)
and
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L123-L142)

But this sometimes works differently because Rust Analyzer expands macros while ast lowering;

ffbc5ad993/crates/hir-def/src/body/lower.rs (L1386-L1398)
ffbc5ad993/crates/hir-def/src/body/lower.rs (L941-L963)
but rustc uses expanded ast in the corresponding tuple-handling process, so it does not have macro patterns there.
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L114)

So, if a macro expansion in a tuple arg results in `..`, rustc permits it like plain `..` pattern, but Rust Analyzer rejects it.
This is the root cause of #17292 and this PR allows macros expanded into `..` in a tuple arg position work as ellipsis like that.
2024-07-22 09:08:12 +00:00
bors
3e33854080 Auto merge of #17667 - Veykril:r-a-component-override, r=Veykril
Use rustup rust-analyzer component when there is a toolchain file override for the opened workspace

Fixes https://github.com/rust-lang/rust-analyzer/issues/17663
2024-07-22 08:54:06 +00:00
Lukas Wirth
d30f78730e Remove incorrect never! invocations 2024-07-22 10:53:18 +02:00
Lukas Wirth
74cc2802b9 Use rustup rust-analyzer component when there is a toolchain file override for the opened workspace 2024-07-22 10:49:32 +02:00
bors
0f45488d09 Auto merge of #17647 - joshka:jm/rename-commands, r=Veykril
Rename rust-analyzer commands

The commands `editor.action.triggerParameterHints` and
`editor.action.rename` are now renamed to
`rust-analyzer.triggerParameterHints` and `rust-analyzer.rename`

This change helps make it clear that these commands are specific to
rust-analyzer and not part of the default set of commands provided by
VSCode.

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

Note: This seems like it will be a breaking change for any RA client that previously reacted to `editor.action.triggerParameterHints` - naive search: https://github.com/search?q=editor.action.triggerParameterHints+AND+%28NOT+is%3Afork%29+rust-analyzer&type=code
2024-07-22 08:10:03 +00:00
bors
377192faab Auto merge of #17666 - Veykril:simplify, r=Veykril
Simplify
2024-07-22 07:56:04 +00:00
Lukas Wirth
69d8e32f60 Simplify 2024-07-22 09:54:31 +02:00