Commit graph

1102 commits

Author SHA1 Message Date
Laurențiu Nicola
4599670308 Bump rustc crates once more 2025-09-20 09:38:53 +03:00
Shoyu Vanilla (Flint)
2c6f0fc0df
Merge pull request #20697 from Oblarg/fix-negative-const-generic-literals
fix negative const generic integer literals
2025-09-19 14:13:54 +00:00
Oblarg
30031b84a8 address review feedback 2025-09-19 10:03:14 -04:00
Shoyu Vanilla
3b4f5fbd73 minor: Get rid of unused deps chalk-solve and chalk-recursive 2025-09-19 22:35:46 +09:00
Laurențiu Nicola
5a643b8158 Set WithCachedTypeInfo::stable_hash when in-tree 2025-09-19 08:08:23 +03:00
Oblarg
d0bdedde0e fix negative const generic integer literals 2025-09-18 18:55:13 -04:00
Shoyu Vanilla
a04f5185b1 fix: Fix one more thing in in-rust-tree 2025-09-19 04:20:24 +09:00
Laurențiu Nicola
e6c3152214
Merge pull request #20694 from ShoyuVanilla/bump-rustc
minor: Yet another rustc crates bump
2025-09-18 18:38:03 +00:00
Shoyu Vanilla
7dfb1c463e minor: Yet another rustc crates bump 2025-09-19 03:26:03 +09:00
Shoyu Vanilla
c462f99914 fix: Fix indexmap with in-rust-tree 2025-09-19 03:04:14 +09:00
Laurențiu Nicola
f289a24d0a Bump rustc crates again 2025-09-18 19:03:35 +03:00
Shoyu Vanilla
74dda38d54 chore: Update rustc deps 2025-09-18 23:02:42 +09:00
Chayim Refael Friedman
cd31e11f94
Merge pull request #20664 from ChayimFriedman2/coerce-ns
Some checks are pending
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
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
Lukas Wirth
aecb756876
Merge pull request #20517 from Veykril/veykril/push-wrurmtqppzus
fix: Only compute unstable paths on nightly toolchains for IDE features
2025-09-16 07:28:47 +00:00
Lukas Wirth
685f156fa6 fix: Only compute unstable paths on nightly toolchains for IDE features 2025-09-16 09:17:16 +02:00
Shoyu Vanilla
33f7ffe4da fix: More precise clause filtering for explicit_*_predicates_of 2025-09-16 01:44:00 +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
Chayim Refael Friedman
b9797aa325 Add Regression Test For The One And The Only Issue #5514 2025-09-15 08:50:41 +03:00
Chayim Refael Friedman
40487c6a60 Add regression tests to some S-blocked-on-new-solver issues
That were fixed by the migration.
2025-09-15 08:25:17 +03:00
Shoyu Vanilla
26b8b794fb fix: Infinite loop while elaborting predicates 2025-09-14 20:08:40 +09:00
Shoyu Vanilla (Flint)
db0420c278
Merge pull request #20642 from ChayimFriedman2/wasm-safe
Some checks failed
metrics / build_metrics (push) Has been cancelled
rustdoc / rustdoc (push) Has been cancelled
metrics / other_metrics (diesel-1.4.8) (push) Has been cancelled
metrics / other_metrics (hyper-0.14.18) (push) Has been cancelled
metrics / other_metrics (ripgrep-13.0.0) (push) Has been cancelled
metrics / other_metrics (self) (push) Has been cancelled
metrics / other_metrics (webrender-2022) (push) Has been cancelled
metrics / generate_final_metrics (push) Has been cancelled
fix: Make `#[target_feature]` always safe on WASM
2025-09-11 05:09:26 +00:00
Shoyu Vanilla (Flint)
d048a477dc
Merge pull request #20649 from ChayimFriedman2/cast-unknown
Some checks failed
metrics / build_metrics (push) Has been cancelled
rustdoc / rustdoc (push) Has been cancelled
metrics / other_metrics (diesel-1.4.8) (push) Has been cancelled
metrics / other_metrics (hyper-0.14.18) (push) Has been cancelled
metrics / other_metrics (ripgrep-13.0.0) (push) Has been cancelled
metrics / other_metrics (self) (push) Has been cancelled
metrics / other_metrics (webrender-2022) (push) Has been cancelled
metrics / generate_final_metrics (push) Has been cancelled
fix: Always coerce in a cast, even when there are unknown types
2025-09-10 02:27:53 +00:00
Chayim Refael Friedman
577203afca Always coerce in a cast, even when there are unknown types
This cause the relationships between inference vars to get recorded.
2025-09-10 04:57:10 +03:00
Shoyu Vanilla (Flint)
cd529a48f7
Merge pull request #20645 from ChayimFriedman2/update-rustc
internal: Upgrade rustc crates
2025-09-10 01:45:46 +00:00
Chayim Refael Friedman
287a6e9482 Properly handle normalization
Previously normalization was broken, which caused a lot of fake errors.

This fix most type mismatches of the new solver, and it also reverts many test regressions.

The downside is that now `chalk_ir::TyKind::AssociatedType`/`chalk_ir::TyKind::Alias` cannot be trusted anymore with their roles, namely: `AssociatedType` is always fully normalized and `Alias` only if it can possibly be normalized further. That seems okay as the new solver does not have this distinction at all (due to it being a lazy normalizer), so this will only hold for the migration time. This does mean we have to change some APIs, notably `hir::Type::walk()` and `TyFingerprint`, to treat `Alias` the same as `AssociatedType`.

Another small thing this commit does is to isolate processing of user-written types (currently involving replacing error types and normalizing, but in the future validation will also be needed) to separate functions.
2025-09-10 03:32:06 +03:00
Chayim Refael Friedman
0f1adf43df An associated type is not a projection!
More correctly, a `TyKind::AssociatedType` is not the same as `TyKind::Projection`.

We used to map next-solver `TyKind::Alias` to Chalk's `TyKind::AssociatedType`. This is very incorrect, as `AssociatedType` is assumed to be fully normalized, and caused a lot of type mismatches.

Unfortunately fixing this causes a lot of stack overflows, because the next solver doesn't have something akin to `AssociatedType` so we normalize again and again. The reason is that is the lazy-normalization nature of the next solver, which means we need to stop normalizing everything. This will be fixed in the next commit.
2025-09-10 00:53:15 +03:00
Chayim Refael Friedman
d03fd874d0 Adopt even more custom types in the new solver
A lot of simplification and fun.
2025-09-10 00:48:33 +03:00
Chayim Refael Friedman
9621689e47 Upgrade rustc crates and handle changes to canonicalization
They have to do with diagnostics, we could probably not support them but we will also someday want good diagnostics.

The code is mostly copied from rustc.
2025-09-10 00:48:33 +03: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
6315e315ad Expand target info to include the architecture
And make it easier to expand it more in the future, if needed.
2025-09-09 13:47:26 +03:00
Shoyu Vanilla (Flint)
a53b44412d
Merge pull request #20609 from ChayimFriedman2/update-rustc
Some checks failed
metrics / build_metrics (push) Has been cancelled
rustdoc / rustdoc (push) Has been cancelled
metrics / other_metrics (diesel-1.4.8) (push) Has been cancelled
metrics / other_metrics (hyper-0.14.18) (push) Has been cancelled
metrics / other_metrics (ripgrep-13.0.0) (push) Has been cancelled
metrics / other_metrics (self) (push) Has been cancelled
metrics / other_metrics (webrender-2022) (push) Has been cancelled
metrics / generate_final_metrics (push) Has been cancelled
internal: Upgrade rustc crates
2025-09-05 03:18:14 +00:00
Chayim Refael Friedman
b78574cd62 Upgrade rustc crates
The main changes are (there are some other small changes):

 - Using a specific type for trait IDs in the new solver, allowing us to simplify a lot of code.
 - Add `BoundConst` similar to `BoundTy` and `BoundRegion` (previously consts used `BoundVar` directly), due to a new trait requirement.
2025-09-04 22:36:31 +03:00
Chayim Refael Friedman
aa2bb65417 Add a regression test for a fixed new trait solver bug
Not sure what exactly fixed it, but why not.
2025-09-04 12:18:22 +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
Shoyu Vanilla (Flint)
a271dac578
Merge pull request #20563 from ChayimFriedman2/ns-projection-dyn-auto-trait
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
fix: When mapping next-solver's `dyn` type, add `Self` (aka. bound var ^1.0) to auto traits' substitutions
2025-08-30 13:39:33 +00:00
Chayim Refael Friedman
867af5fbb6 When mapping next-solver's dyn type, add Self (aka. bound var ^1.0) to auto traits' substitutions
Chalk represents dyn types as a list of predicate, the self type should be there. The next solver represents them quite differently. The `Self` was forgotten for the auto trait case.
2025-08-28 23:53:55 +03:00
Chayim Refael Friedman
ff06610625 Don't require a full InferenceTable for CastTy
A DB is enough.
2025-08-28 19:24:46 +03:00
Laurențiu Nicola
968fc01fa6
Merge pull request #20547 from ChayimFriedman2/highlight-related-unsafe-scope
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
fix: In highlight_related, when on an unsafe block, don't highlight unsafe operations of other unsafe blocks
2025-08-27 19:09:21 +00:00
Shoyu Vanilla (Flint)
1d90205a98
Merge pull request #20527 from ChayimFriedman2/cache-next-solver
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
perf: Cache trait solving across queries in the same revision
2025-08-27 04:31:39 +00:00
Chayim Refael Friedman
1efff4677e In highlight_related, when on an unsafe block, don't highlight unsafe operations of other unsafe blocks 2025-08-26 21:46:04 +03:00
Chayim Refael Friedman
6bcfbbe8f9 Remove SolverDefId::ForeignId
Replace it with normal `SolverDefId::TypeAliasId`.

The split caused a very funny bug where code was getting `TypeAliasId` where it expected `ForeignId`, because `TypeAliasId` had a `From` impl from `hir_def::TypeAliasId` and `ForeignId` had not, plus a careless `into()`.

I could've fixed this specific bug but opted to remove the split instead; currently, it just provides more room for bugs, as we don't have typed IDs for the solver anyway, and even when we'll have (hopefully), that doesn't seem like a very useful distinction, for example in hir-def foreign types are just `TypeAliasId` with some flags.

Constructing a test for this isn't trivial; the trivial test (creating a foreign type, even proving a trait bound for it) fails to fail before the change, probably because we don't use the new solver everywhere yet so we don't trigger this specific code path.
2025-08-26 19:33:46 +03:00
Chayim Refael Friedman
fd77af3a78 Don't map Chalk's Normalize to next solver's NormalizesTo
`NormalizesTo` is a private predicate that should not be used outside the solver. For normalization, rustc uses `AliasRelate`, so replace with that.
2025-08-25 20:56:45 +03:00
Chayim Refael Friedman
1ff80eefe1 Normalize all types when finishing inference
The new solver does not eagerly normalize, but things after inference expect types to be normalized. rustc does the same.

Also, I'm afraid other things in r-a don't expect results of the solver to be unnormalized. We'll need to handle that.
2025-08-25 20:23:18 +03:00
Chayim Refael Friedman
1c8a07cfd6 Cache trait solving across queries in the same revision
Caching trait solving can do a lot to speed. Unfortunately it also consume a huge amount of memory. Therefore, as part of the migration to the new solver Jack Huey disabled caching of trait solving (he made the query transparent).

The PR proposes a middle ground: do cache trait solving, but only for the same revision. This allows us to be safe because during a revision the inputs cannot change.

The result is hopefully much better performance to features that tend to do a bulk of trait solving, and also repeat the same query (e.g. inference then IDE features).

There is another limitation: results are only cached in the same thread, to remove the need for synchronization which will be expensive. More measurements are required to check whether it's better to use a synchronized global cache, or maybe stay with a thread-local cache but batch multiple feature requests (highlighting, inlay hints etc.) of the same file to the same thread.

Alongside the actual cache we store the revision, because we need to verify it (we can't eagerly clear caches when incrementing the revision), and also the address of the db to prevent multiple dbs from interleaving (this is mostly relevant in tests, although injected highlighting also uses a new db, therefore maybe it's better to move it to a separate thread).

This "games" analysis-stats to both be way faster and use way more memory; the former is because analysis-stats doesn't increment revisions, therefore all queries share the cache and hit ratio is way too good, the latter is because analysis-stats doesn't increment revisions and therefore the cache isn't cleared. Both are not representative of a typical IDE scenario.
2025-08-25 17:17:31 +03:00
Chayim Refael Friedman
03173a7ec7 Fix opaque generics
The parent generics were incorrectly not considered for TAIT.

I'm not convinced we should follow rustc here, also there are items (opaques) with more than 1 parent (opaque -> fn/type alias -> impl/trait) and I'm not sure we properly account for that in all places, but for now I left it as-is.

Also fix a bug where lifetimes' indices were incorrect when there is a self param (they started from 0 instead of 1).
2025-08-24 08:49:40 +03:00
Shoyu Vanilla
80ce520660 fix: Infinite recursion while lowering assoc type bounds from supertraits 2025-08-22 05:24:33 +09:00
Lukas Wirth
aed0fec1a9 Auto-attach database in Analysis calls 2025-08-18 09:52:23 +02:00