1705 Commits

Author SHA1 Message Date
Chayim Refael Friedman
99ce53b1d7 Add two new diagnostics: one for mismatch in generic arguments count, and another for mismatch in their kind
Also known as E0747 and E0107.

And by the way, rewrite how we lower generic arguments and deduplicate it between paths and method calls. The new version is taken almost straight from rustc.

This commit also changes the binders of `generic_defaults()`, to only include the binders of the arguments up to (and not including) the current argument. This make it easier to handle it in the rewritten lowering of generic args. It's also how rustc does it.
2025-04-22 14:55:43 +03:00
Lukas Wirth
9a9f4e7f63
Merge pull request #19624 from jackh726/chalk-update
Update chalk
2025-04-22 10:58:31 +00:00
Chayim Refael Friedman
0f325c7ff8 Remove unnecessary predefined symbol clones
Now that they're const it's no longer needed.

Nothing manual was performed: only a regexp search of `sym::([\w][\w\d]*)\.clone\(\)` and replace by `sym::$1`.
2025-04-21 03:10:13 +03:00
Chayim Refael Friedman
9477e46bec Get rid of static predefined symbols
Make them all `const`.
2025-04-21 03:07:35 +03:00
jackh726
6daa791fab Update chalk 2025-04-20 16:20:08 +00:00
Chayim Refael Friedman
150bb4a00f
Merge pull request #19617 from ChayimFriedman2/more-actual
internal: Make `HirFileId`, `EditionedFileId` and macro files Salsa struct
2025-04-19 19:21:53 +00:00
Chayim Refael Friedman
c58ddafe90 Make HirFileId, EditionedFileId and macro files Salsa struct
And make more queries non-interned.

Also flip the default for queries, now the default is to not intern and to intern a query you need to say `invoke_interned`.
2025-04-19 22:10:52 +03:00
Chayim Refael Friedman
346f2d7559 Fix a panic when a trait method in an impl declares a lifetime parameter not in the trait declaration
Shuffle the code a bit.
2025-04-18 06:28:17 +03:00
Lukas Wirth
40076b577f internal: Render sigantures with view hir command 2025-04-13 12:13:28 +02:00
Chayim Refael Friedman
96925d5105
Merge pull request #19570 from ChayimFriedman2/fix-store-panic
fix: Fix an incorrect `ExpressionStore` that was passed
2025-04-10 21:46:18 +00:00
Chayim Refael Friedman
8bde16dcce Fix an incorrect ExpressionStore that was passed
It caused panics everywhere.
2025-04-11 00:34:13 +03:00
Lukas Wirth
4fdc2507c6 fix: Fix invalid signature bitflags 2025-04-10 15:39:27 +02:00
Lukas Wirth
f880acd18c
Merge pull request #19461 from Hmikihiro/shadow_by_module
fix: shadow type by module
2025-04-10 12:20:14 +00:00
Chayim Refael Friedman
8a9a1e3345 Remove all upcasts!
It turns out there were a lot redundant too.
2025-04-10 11:08:38 +03:00
Hayashi Mikihiro
1b471ebfd5 TypeNs contain module
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-04-10 16:29:10 +09:00
Hayashi Mikihiro
a7dc60a2c4 return single option
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-04-10 16:29:10 +09:00
Hayashi Mikihiro
2854ad9a41 fix: shadow type by module
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-04-10 16:29:10 +09:00
Lukas Wirth
07212140db refactor: Turn LifetimeRef into an enum
This makes things more structured
2025-04-09 15:58:06 +02:00
Lukas Wirth
1fd9520c92 refactor: Lower type-refs before type inference
This refactors how we deal with items in hir-def lowering.

- It now lowers all of them through an "ExpressionStore" (kind of a misnomer as this point) as their so called *Signatures.
- We now uniformly lower type AST into TypeRefs before type inference.
- Likewise, this moves macro expansion out of type inference, resulting in a single place where we do non-defmap macro expansion.
- Finally, this PR removes a lot of information from ItemTree, making the DefMap a lot less likely to be recomputed and have it only depend on actual early name resolution related information (not 100% true, we still have ADT fields in there but thats a follow up removal).
2025-04-09 10:43:23 +02:00
Lukas Wirth
e7ce86ddea fix: Fix format_args lowering for >=1.87 2025-04-06 10:05:56 +02:00
Lukas Wirth
1e1571e1c8 fix: Fix new nightly lints 2025-03-31 13:27:54 +02:00
Lukas Wirth
2b382eb772 fix: Cleanup param name inlay hint filtering 2025-03-31 09:40:57 +02:00
Chayim Refael Friedman
7b584ef9bf Allow crate authors to control completion of their things
Via the new `#[rust_analyzer::completions(...)]` attribute.

Also fix a bug with existing settings for that where the paths wouldn't resolve correctly.
2025-03-27 14:01:26 +02:00
Lukas Wirth
500ea05aef chore: Bump dependencies 2025-03-23 08:46:10 +01:00
Lukas Wirth
3086e5fe90 chore: Remove some unnecessary usage of Semantics 2025-03-21 20:09:03 +01:00
Chayim Refael Friedman
ced6ea5cd0 Remove unnecessary expansions
In the body source map, we record each macro call with the `ExprOrPatId` it resolved to, so to lookup the `ExprId` of some node, we don't need to expand it!
2025-03-20 21:49:18 +02:00
Lukas Wirth
8b5816b4f5
Merge pull request #19363 from euclio/varargs-detail
display varargs in completion detail
2025-03-16 13:43:11 +00:00
Lukas Wirth
918740358b
Merge pull request #19354 from ChayimFriedman2/rtn-prep
Preparation to Return Type Notation (RTN)
2025-03-16 13:21:23 +00:00
Lukas Wirth
b5eedad8e3 refactor: Remove unnecessary Arc 2025-03-16 10:27:48 +01:00
Andy Russell
e9403853c0
display varargs in completion detail 2025-03-15 16:36:14 -04:00
BenjaminBrienen
7535bb4661 cargo fmt 2025-03-15 21:32:01 +01:00
BenjaminBrienen
aad66c7bf1 Fix 2024 syntax errors 2025-03-15 21:32:01 +01:00
Lukas Wirth
02a793bd59 chore: Remove legacy SyntaxContextId re-export 2025-03-15 17:09:17 +01:00
Lukas Wirth
2ea09b2e47 Split variant_data into its own query 2025-03-14 14:16:33 +01:00
Lukas Wirth
8e8d997304 Split enum variants out of enum_data query 2025-03-14 13:32:53 +01:00
Lukas Wirth
12f54eec27 Split assoc items out of trait_data/impl_data queries 2025-03-14 13:31:41 +01:00
David Barsky
788232b355 internal: don't panic when the crate graph isn't ready #19351 2025-03-13 15:14:08 -04:00
Chayim Refael Friedman
5076ef7d9b Emit an error when RTN is used in an incorrect place
We miss one place: associated type bindings aka. `impl Trait<Type(..): Send>`, but we also miss it for Fn-style parenthesizes error so I left it out for now.
2025-03-12 23:34:16 +02:00
Chayim Refael Friedman
c94e9efbef Salsify the crate graph
I.e. make it not one giant input but multiple, for incrementality and decreased memory usage for Salsa 3 reasons.
2025-03-12 21:02:30 +02:00
David Barsky
74620e64ec internal: port rust-analyzer to new Salsa 2025-03-10 13:30:51 -04:00
Lukas Wirth
27a5b1ba0c
Merge pull request #19330 from ChayimFriedman2/normalize-projection
fix: Normalize projections in evaluated const display and layout calculation
2025-03-10 09:15:35 +00:00
Lukas Wirth
cf255a61d5
Merge pull request #19079 from ChayimFriedman2/rename-conflict
feat: Warn the user when a rename will change the meaning of the program
2025-03-10 08:59:43 +00:00
Lukas Wirth
5249b8bf7e
Merge pull request #19327 from Veykril/push-qyyvkulltzpz
Fix `path` macro hygiene
2025-03-10 08:45:04 +00:00
Lukas Wirth
af7f89cc9d Fix path macro hygiene 2025-03-10 09:29:27 +01:00
Prajwal S N
39391b0d38
fix(hir): VariantDef is impl HasSource
A new syntax node `ast::VariantDef` has been introduced to map between the HIR node and the AST.
The files have been updated with `cargo test -p xtask`.

Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
2025-03-08 01:25:27 +05:30
Chayim Refael Friedman
62e7d2851b Warn the user when a rename will change the meaning of the program
Specifically, when a rename of a local will change some code that refers it to refer another local, or some code that refer another local to refer to it.

We do it by introducing a dummy edit with an annotation. I'm not a fond of this approach, but I don't think LSP has a better way.
2025-03-06 21:07:10 +02:00
Chayim Refael Friedman
2fc0dc0f13 Pass the target crate in HirFormatter
This is required to format evaluated consts, because we need trait env, and it needs the crate (currently it uses the last crate in topological order, which is wrong, the next commit will fix that).
2025-03-06 21:00:05 +02:00
Lukas Wirth
27dc614627
Merge pull request #19274 from Veykril/push-pouwrwwrlrlt
Highlight unsafe operations as unsafe, not definitions
2025-03-05 12:57:25 +00:00
Lukas Wirth
9fc0ffe008 Use HIR unsafety information for unsafe syntax highlightng 2025-03-05 13:18:46 +01:00
Lukas Wirth
4ad546f6a6 Support tuple struct patterns for expand_rest_pattern assist 2025-03-03 12:35:53 +01:00