Commit Graph

507 Commits

Author SHA1 Message Date
Jana Dönszelmann 180725cff6 consistently encode failure reason (nosolution or rerun) in the error type 2026-05-08 14:35:58 +02:00
Jana Dönszelmann 687f839266 return faster from internal iterators 2026-05-08 14:10:56 +02:00
Chayim Refael Friedman ff25d8acf3 Use special DefIds for aliases
Like we do for other things for better experience in rust-analyzer.

It's possible now that the `AliasTyKind` and `AliasTermKind` contains the DefId.

It does require a few `try_into().unwrap()`s since in the solver's `consider_X_candidate()` only get an untyped `DefId`. It's possible to reduce that considerably if we'd pass them the typed def id as a parameter, but I don't know what will be the impact on perf.
2026-05-06 20:56:55 +03:00
bors 365c0e1d7a Auto merge of #155443 - jdonszelmann:canonical, r=lcnr
Improve caching by introducing `TypingMode::ErasedNotCoherence`



r? @lcnr


This introduces `TypingMode::ErasedNotCoherence`. Most typing modes contain a list of opaque types, which are quite often unused during canonicalization. With this change, any time we try canonicalization, we replace whichever typing mode we're currently in with `ErasedNotcoherence`, attempt to canonicalize, and if that fails *retry* in the original typing mode. If erased mode succeeds, this is beneficial because that way the opaque types don't end up in the cache key, allowing more cache reuse.

This seems to have a small (0.5%) slowdown on most programs, but a dramatic (>60%) speedup in specific cases like the rustc-perf `wg-grammar` benchmark. Some more improvements are expected with "eager normalization", which is work that's under way right now.
2026-05-06 13:55:09 +00:00
Jana Dönszelmann 1c34c39553 some cleanup 2026-05-06 10:18:21 +02:00
Jana Dönszelmann 52bd834020 move typing mode determination out of canonicalize_goal 2026-05-06 10:18:21 +02:00
Jana Dönszelmann f0c1798a3a prefer assert_not_erased over matching+unreachable 2026-05-06 10:18:21 +02:00
Jana Dönszelmann d543ed8344 make RerunReason an enum 2026-05-06 10:18:21 +02:00
Jana Dönszelmann 13904094c5 some attempts at improving coroutines resulting in FIXME 2026-05-06 10:18:21 +02:00
Jana Dönszelmann e8b74eec74 consistently return OpaquesAccessed from probes to signal why they error 2026-05-06 10:18:21 +02:00
Jana Dönszelmann 9fda7e0c97 Refactor fetch_eligible_assoc_item output 2026-05-06 10:18:21 +02:00
Jana Dönszelmann 7ff71be015 Try to canonicalize with erased opaques, retry when opaques are used. 2026-05-06 10:18:21 +02:00
Jana Dönszelmann a299302d5c Add logging in various places 2026-05-06 10:18:21 +02:00
Jana Dönszelmann 630f0d2bbb type safety for typing mode outside trait solver which can't be erased-not-coherence 2026-05-06 10:18:21 +02:00
Jana Dönszelmann a93f8c0579 Introduce ErasedNotCoherence typing mode 2026-05-06 10:13:29 +02:00
Jana Dönszelmann 6173314a50 Change sg apis to cache opaque accesses 2026-05-06 10:13:29 +02:00
Jana Dönszelmann 3b0a258918 Add AccessedOpaques, tracking opaque access during canonicalization 2026-05-06 10:13:29 +02:00
Jacob Pratt b2cc990df0 Rollup merge of #155341 - khyperia:non-type-const, r=BoxyUwU
generic_const_args: allow paths to non type consts

tracking issue: https://github.com/rust-lang/rust/issues/151972

Non type consts should be usable in the type system in `feature(generic_const_args)`. These are directly plugged into the constant evaluator, unlike type consts, which are attempted to be reasoned about by the type system.

Inherent associated constants are not supported at this time, due to complications around how generic arguments are represented for them (it's currently a mess). The mess is being cleaned up (e.g. https://github.com/rust-lang/rust/pull/154758), so instead of trying to hack support in before the refactoring is done, let's just wait to be able to implement it more cleanly.

r? @BoxyUwU
2026-05-05 22:50:18 -04:00
khyperia cb2c5fc540 generic_const_args: allow paths to non type consts 2026-05-05 17:35:17 +02:00
Shoyu Vanilla 4432f6bf82 Implement a new flag -Zdisable-fast-paths in trait solving 2026-05-05 19:46:30 +09:00
bors a3e96d8cb8 Auto merge of #155767 - adwinwhite:eager-norm-outside, r=lcnr
`-Znext-solver` Eager normalization outside of solver 




This PR adds a normalization routine for the next solver that behaves the same as the normalization in the old solver.
The new routine is used to normalize eagerly outside of the next solver.

This is [part 2](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/Eager.20normalization.2C.20ahoy.21/near/582996783) of modifying the next solver to support eager normalization.

Those test changes are mostly wording changes, duplicating some errors or reducing some duplicates. But I could have overlooked something.
Notably it fixes the first, third and fourth examples in https://github.com/rust-lang/trait-system-refactor-initiative/issues/191, but not the second variant.

It's probably easier to review commit by commit.

Fixes rust-lang/rust#151308
Fixes rust-lang/rust#101557
Fixes rust-lang/rust#119692
Fixes rust-lang/rust#136859
2026-05-02 20:56:41 +00:00
Nicholas Nethercote e7d28d3e9b Rename the HashStable* trait/derives as StableHash*.
Specifically:
- `HashStable` -> `StableHash` (trait)
- `HashStable` -> `StableHash` (derive)
- `HashStable_NoContext` -> `StableHash_NoContext` (derive)

Note: there are some names in `compiler/rustc_macros/src/hash_stable.rs`
that are still to be renamed, e.g. `HashStableMode`.

Part of MCP 983.
2026-05-02 10:16:40 +02:00
Adwin White e82c3c80ef add a new normalization routine that can handle ambiguity 2026-05-02 16:11:12 +08:00
Shoyu Vanilla e43a1b5b44 -Znext-solver Ignore region constraints from the nested goals in leakcheck 2026-05-02 00:11:43 +09:00
Nicholas Nethercote f01d549c29 Reduce derive(HashStable_NoContext).
Thanks to the `HashStable` trait being simplified,
`HashStable_NoContext` is only needed when a (near) perfect derive is
required. In practice, this means it's only needed for types with a
generic `<I: Interner>` parameter.

This commit replaces `derive(HashStable_NoContext)` with
`derive(HashStable)` for all types that don't have `<I: Interner>`.
2026-04-30 08:26:22 +10:00
bors c935696dd0 Auto merge of #155487 - ShoyuVanilla:canon-ph, r=lcnr
Canonicalize free regions from inputs as placeholders in root univ



Context: The box named *coroutine witness Send lifetime requirements now considered by leakcheck* [this roadmap](https://raw.githubusercontent.com/hexcatnl/roadmap/e380fef94b47c02a056b4c8f05124a9db475b990/next-solver.svg)

Fixes (only for the next-solver) rust-lang/rust#106569 
Prerequisite of https://github.com/rust-lang/rust/pull/155749
2026-04-29 13:17:37 +00:00
Shoyu Vanilla f2ae894662 Canonicalize free regions from inputs as placeholders in root univ 2026-04-29 13:13:04 +09:00
Shoyu Vanilla 25c241c1b0 Propagate stalled_on_coroutines as a field in Certainty::Maybe 2026-04-29 02:28:38 +09:00
Waffle Lapkin e8b6c9737e fix ty::UnevaluatedConst<I>>->AliasTerm<I> conversion 2026-04-21 12:28:25 +02:00
Waffle Lapkin 0ff2fe8eef add AliasTermTy::with_args to simplify a common-ish pattern 2026-04-21 12:28:24 +02:00
Waffle Lapkin d7986943e4 AliasTermTy refactor: fixup compiler 2026-04-21 12:28:22 +02:00
Adwin White 6279106e72 fix all errors 2026-04-20 00:18:28 +08:00
Shoyu Vanilla ace3aa319c Make region equality emits Eq constraints 2026-04-18 22:02:01 +09:00
Jana Dönszelmann 26a0fdcdcd fixup let-else on typing mode in the compiler 2026-04-14 11:05:19 +02:00
Jana Dönszelmann 63c212e62b make typing_mode getter 2026-04-10 11:42:02 +02:00
Jana Dönszelmann 0e0d12ccb3 introduce TypingModeEqWrapper and make TypingMode !Eq 2026-04-10 11:40:01 +02:00
Jacob Pratt 6bd1a6cd31 Rollup merge of #154991 - cijiugechu:fix/next-solver-transmutefrom-ice, r=Kivooeo
Fix ICE in next-solver TransmuteFrom candidate

Treat TransmuteFrom goals with non-region inference variables as ambiguous before running transmutability, matching the old solver.

Closes rust-lang/rust#153370 .
2026-04-08 23:03:59 -04:00
Jacob Pratt bcb5909a14 Rollup merge of #152859 - ShoyuVanilla:issue-152789, r=lcnr
`-Znext-solver` use the trait object's own bounds instead of goal when considering builtin object bounds

Fixes https://github.com/rust-lang/rust/issues/152789 and fixes https://github.com/rust-lang/rust/issues/151329

r? lcnr
2026-04-08 23:03:57 -04:00
cijiugechu ee135be041 Fix ICE in next-solver TransmuteFrom candidate
Treat TransmuteFrom goals with non-region inference variables as ambiguous before running transmutability, instead of computing layouts for unresolved types. The old solver already treated these goals as ambiguous, so only the next solver could hit this ICE.
2026-04-09 10:12:18 +08:00
Shoyu Vanilla ba3b486c3c Use the trait object's own bounds instead of goal when considering builtin object bounds 2026-04-09 02:13:55 +09:00
Waffle Lapkin 0f767084b8 ty::Alias refactor: fixup all the compiler code 2026-04-07 10:08:12 +02:00
Jonathan Brouwer d9e0301801 Rollup merge of #154709 - Jamesbarford:chore/revert-ty-type-alias, r=lcnr
Revert `Ty` type alias in `rustc_type_ir`

Reverting (rust-lang/rust#154270) the creation and use of `Ty` type alias in `rustc_type_ir` that was causing problems with Rust Analyser, see [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/.23154270.20.28Ty.20alias.29.20triggers.20many.20bogus.20RA.20errors/with/583209227) for more

r? @lcnr
2026-04-02 22:13:58 +02:00
Jonathan Brouwer fc758577be Rollup merge of #153614 - lcnr:find-param-in-clause-ambig, r=BoxyUwU
`FindParamInClause` handle edge-cases

If normalization is ambiguous, we want to treat the where-bound as non-global. The affected code should pretty much always have other errors in that case. It does make reasoning about trait solver cycles and rerunning more confusing and just feels wrong ™️ I encountered this while looking into `ml-kem` (https://github.com/rust-lang/trait-system-refactor-initiative/issues/246). I don't know whether this matters in practice and don't care to look into it too deeply.

We also want to properly handle concrete aliases which mention to something mentioning a generic parameter due to another where-bound.

r? @BoxyUwU
2026-04-02 22:13:52 +02:00
lcnr 69148fd190 add mgca fixme 2026-04-02 16:29:26 +02:00
lcnr b3b29ede80 handle concrete alias norm to generic
see the added test
2026-04-02 16:29:25 +02:00
lcnr 77a9316422 FindParamInClause non-global on overflow 2026-04-02 12:32:23 +02:00
khyperia 9465366ec4 remove the o from oGCA 2026-04-02 12:06:25 +02:00
khyperia 0e2c554e74 rename opaque_generic_const_args to generic_const_args 2026-04-02 12:04:25 +02:00
James Barford-Evans e29f4f4a79 Revert Ty type alias in rustc_type_ir 2026-04-02 10:39:56 +01:00
Jonathan Brouwer 286263335b Rollup merge of #154270 - Jamesbarford:chore/move-ty-pt1, r=lcnr
Create `Ty` type alias in `rustc_type_ir`

r? lcnr

Anywhere that required the use of the trait `Ty` I used `ty::Ty<I>` otherwise it should be `Ty<I>`
2026-03-31 13:58:42 +02:00