163 Commits

Author SHA1 Message Date
Jack Huey
cc7c061e34 Use lower_nextsolver::callable_item_signature instead of lower::callable_item_signature 2025-09-23 16:26:46 -04:00
Jack Huey
c2513538cd Add 'db to TraitEnvironment 2025-09-23 00:04:57 +00:00
Shoyu Vanilla
0a5457a392 internal: Migrate more predicate things to next-solver 2025-09-22 23:44:50 +09:00
Chayim Refael Friedman
cd31e11f94
Merge pull request #20664 from ChayimFriedman2/coerce-ns
fix: Port a bunch of stuff from rustc and fix a bunch of type mismatches/diagnostics
2025-09-18 00:19:30 +00:00
Shoyu Vanilla
0b76080c36 Fix "sync-from-ra" for rust-lang/rust 2025-09-17 03:22:52 +09:00
Chayim Refael Friedman
7d1860807e Port a bunch of stuff from rustc and fix a bunch of type mismatches/diagnostics
This started from porting coercion, but ended with porting much more.
2025-09-15 18:56:17 +03:00
Shoyu Vanilla (Flint)
db0420c278
Merge pull request #20642 from ChayimFriedman2/wasm-safe
fix: Make `#[target_feature]` always safe on WASM
2025-09-11 05:09:26 +00:00
Shoyu Vanilla
4a8bc8db38 Fix failing tests and fill-in missing details 2025-09-10 01:43:22 +09:00
jackh726
d24e8c1d38 WIP switch inference table to next-solver 2025-09-09 22:45:14 +09:00
Chayim Refael Friedman
fcab4fbabb Make #[target_feature] safe always on WASM
Even when the feature isn't enabled, as it's not UB to invoke an undefined feature in WASM (just a trap).
2025-09-09 13:49:11 +03:00
Chayim Refael Friedman
41611b19e5 Make sense of the mess that were (are) different kind of generics in the solver
To the extent possible.

Previously they were confused. Sometimes generic params were treated as `Param` and sometimes as `Placeholder`. A completely redundant (in the new solver) mapping of salsa::Id to ints to intern some info where we could just store it uninterned (not in Chalk though, for some weird reason).

Plus fix a cute bug in closure substitution that was caught by the assertions of Chalk but the next solver did not have such assertions. Do we need more assertions?
2025-09-02 06:39:32 +03:00
jackh726
ec26d9f48a Update fixme 2025-08-17 16:04:50 +00:00
jackh726
f9d2d2dd87 Switch associated_type_shorthand_candidates to lower_nextsolver 2025-08-17 16:04:50 +00:00
jackh726
17b94c41b1 Convert some of mir/eval to next-solver types 2025-08-17 16:04:50 +00:00
jackh726
eeaefa4b9d impl HirDisplay for next_solver::Ty 2025-08-17 16:04:49 +00:00
jackh726
9418a3f2df Implement next trait solver 2025-08-09 16:08:58 +00:00
Lukas Wirth
f25912c6f9 De-arc trait items query 2025-06-25 10:09:21 +02:00
Lukas Wirth
133418e3cc Remove InternedCallableDefId
It's unnecessary
2025-06-13 17:30:50 +02:00
Chayim Refael Friedman
adcf699ea3 Properly handle lifetimes when checking generic arguments len
And also, prepare for correct lowering of lifetime. We still don't handle most lifetimes correctly, but a bit more of the foundation to lifetime elision is now implemented.
2025-04-24 08:35:20 +03:00
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
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
8a9a1e3345 Remove all upcasts!
It turns out there were a lot redundant too.
2025-04-10 11:08:38 +03: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
1e1571e1c8 fix: Fix new nightly lints 2025-03-31 13:27:54 +02:00
BenjaminBrienen
7535bb4661 cargo fmt 2025-03-15 21:32:01 +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
74620e64ec internal: port rust-analyzer to new Salsa 2025-03-10 13:30:51 -04:00
Laurențiu Nicola
be48993351
Merge pull request #19331 from lnicola/sync-from-rust
minor: Sync from downstream
2025-03-10 09:52:17 +00:00
Laurențiu Nicola
bc178ff75e Bump rustc crates 2025-03-10 11:20:56 +02:00
Moulins
18772836d4 Use rustc_abi code for SIMD layout in rust-analyzer 2025-03-08 12:36:42 +01: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
Chayim Refael Friedman
87ed04bac0 Support target features implications in target_feature 1.1
We vendor the list of implications, which isn't nice, but t-compiler doesn't want to make rustc_target available to us.
2025-02-25 04:50:26 +02:00
Lukas Wirth
93bd36dfb9
Merge pull request #18987 from ChayimFriedman2/drop-glue
feat: Calculate drop glue and show it on hover
2025-02-24 13:52:17 +00:00
Chayim Refael Friedman
100e166bb1 Calculate drop glue and show it on hover
Also fix the `needs_drop()` intrinsic.

Unions also need this information (to err if they have a drop-needing field), but this will come in a follow-up PR.
2025-02-17 06:29:37 +02:00
Ben Kimock
b4b1e778c9 Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer 2025-02-16 16:18:30 -05:00
Ali Bektas
135fca9efe Revert tests::patterns::infer_pattern
And apply requested changes
2025-02-03 12:23:13 +01:00
Ali Bektas
7befcb32e4 Equip infer_pat_* with declaration origin 2025-01-29 00:54:18 +01:00
Chayim Refael Friedman
55c63abc59 Fix #[rustc_deprecated_safe_2024]
It should be considered by the edition of the caller, not the callee.

Technically we still don't do it correctly - we need the span of the method name (if it comes from a macro), but we don't keep it and this is good enough for now.
2025-01-27 14:35:20 +02:00
Chayim Refael Friedman
791b1ebfd4 Support RFC 2396
AKA. target_feature 1.1, or non unsafe target_feature.
2025-01-26 23:31:58 +02:00
Lukas Wirth
bb921fbe94 Show variance of parameters on hover 2024-12-28 20:31:20 +01:00
Lukas Wirth
eee2761140 Implement parameter variance inference 2024-12-28 19:54:22 +01:00
Chayim Refael Friedman
82896b2cc4 Move ty lowering diagnostic definitions into a separate module
To keep them organized.
2024-12-20 15:34:23 +02:00
Chayim Refael Friedman
21ad3b5b87 Complete diagnostics in ty lowering groundwork
Implement diagnostics in all places left: generics (predicates, defaults, const params' types), fields, and type aliases.

Unfortunately this results in a 20mb addition in `analysis-stats .` due to many type methods returning an addition diagnostics result now (even if it's `None` in most cases). I'm not sure if this can be improved.

An alternative strategy that can prevent the memory usage growth is to never produce diagnostics in hir-ty methods. Instead, lower all types in the hir crate when computing diagnostics from scratch (with diagnostics this time). But this has two serious disadvantages:
 1. This can cause code duplication (although it can probably be not that bad, it will still mean a lot more code).
 2. I believe we eventually want to compute diagnostics for the *entire* workspace (either on-type or on-save or something alike), so users can know when they have diagnostics even in inactive files. Choosing this approach will mean we lose all precomputed salsa queries. For one file this is fine, for the whole workspace this will be very slow.
2024-12-04 14:22:56 +02:00
Chayim Refael Friedman
5f25ae3d1b Lay the foundation for diagnostics in ty lowering, and implement a first diagnostic
The diagnostic implemented is a simple one (E0109). It serves as a test for the new foundation.

This commit only implements diagnostics for type in bodies and body-carrying signatures; the next commit will include diagnostics in the rest of the things.

Also fix one weird bug that was detected when implementing this that caused `Fn::(A, B) -> C` (which is a valid, if bizarre, alternative syntax to `Fn(A, B) -> C` to lower incorrectly.

And also fix a maybe-bug where parentheses were sneaked into a code string needlessly; this was not detected until now because the parentheses were removed (by the make-AST family API), but with a change in this commit they are now inserted. So fix that too.
2024-12-04 14:22:56 +02:00
Mark Murphy
1dbe681757 Remove references to platform-intrinsic ABI 2024-12-03 17:30:17 -05:00
Michael Goulet
29d59c58d8 Remove redundant associated type bounds from dyn 2024-11-30 03:33:33 +00:00
Vincent Esche
c1155213f3 Add pub fn direct_super_traits(db, trait_id) to hir_ty crate 2024-11-06 10:02:13 +01:00
Lukas Wirth
1cdc34fa4a Fix recursive_adt fixture 2024-10-21 11:28:18 +02:00
Noratrieb
6a2b8270c9 Update rustc-hash to version 2
This brings in the new optimized algorithm that was shown to have small performance benefits for
rustc.
2024-10-21 11:28:18 +02:00
David Barsky
ccee36e8dd chore: rename salsa to ra_salsa 2024-10-14 10:09:22 -04:00