Commit Graph

487 Commits

Author SHA1 Message Date
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
James Barford-Evans 17e0cc3ebd Create Ty type alias in rustc_type_ir 2026-03-30 12:34:38 +01:00
Jana Dönszelmann 632ed10838 Revert "eagerly normalize during generalization"
This reverts commit 5d0863b147.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann c838deca23 Revert "normalize at the start of generalize if we can"
This reverts commit f50591fc10.
2026-03-23 12:09:34 +01:00
bors ac7f9ec7da Auto merge of #151746 - jdonszelmann:eagerly-normalize-in-generalize, r=lcnr
Eagerly normalize in generalize

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/151746)*

r? @lcnr 

cc: https://github.com/rust-lang/trait-system-refactor-initiative/issues/262
2026-03-20 18:22:43 +00:00
bendn b90abe64c1 constify const Fn*: Destruct 2026-03-17 23:47:42 +07:00
Oli Scherer 1867653c81 Allow calling const closures in const items 2026-03-13 20:29:43 +00:00
Jonathan Brouwer fad370cc4a Rollup merge of #152800 - spirali:fix-FindParamInClause, r=lcnr
Adds recursion limit into FindParamInClause

Fixes rust-lang/rust#152716

r? lcnr
2026-03-09 11:49:23 +01:00
Ada Bohm 592246e2a1 Added comments 2026-03-07 22:09:35 +01:00
Ada Bohm fcddf7fa3c Propagate certainty 2026-03-05 10:08:57 +01:00
Jonathan Brouwer baa285c6fd Rollup merge of #153172 - jdonszelmann:placeholder-comment, r=lcnr
Fix comment about placeholders

r? @lcnr

When this was introduced, briefly returned an `Option`, which is what the comment refers to.
https://github.com/rust-lang/rust/pull/86993/changes/a9f1e1c440ae20f0ea99f5e265f24094f1a613a5#diff-8d11697c196da9f44774488ae0bf353283e5c6466a6dd570d7818431b73d4a44R511

Before that this code would just panic, and in the commit right after fixing review comments it does so again:
https://github.com/rust-lang/rust/pull/86993/changes/cf001dc8894ae726de96f4db032f11c22f24c393#diff-8d11697c196da9f44774488ae0bf353283e5c6466a6dd570d7818431b73d4a44R560

That comment has been copied around for 5 years now despite not reflecting the behavior hehe

Second commit has some general typos I found
2026-02-28 12:52:56 +01:00
Benno Lossin 7b428597ff add field representing types 2026-02-27 15:54:20 +01:00
Jana Dönszelmann ea2a15fb89 and some typos 2026-02-27 10:46:37 +01:00
Jana Dönszelmann 8f25f8ca50 fix comment about placeholders 2026-02-27 10:44:43 +01:00
Jana Dönszelmann f50591fc10 normalize at the start of generalize if we can 2026-02-26 14:53:57 +01:00
Jana Dönszelmann 5d0863b147 eagerly normalize during generalization 2026-02-26 11:44:24 +01:00
Ada Bohm 8b83d4b4a6 Adds recursion limit into FindParamInClause 2026-02-18 16:44:18 +01:00
Matthias Krüger 336debab2e Rollup merge of #152383 - RalfJung:BikeshedGuaranteedNoDrop, r=TaKO8Ki
BikeshedGuaranteedNoDrop trait: add comments indicating that it can be observed on stable

Not sure if that's worth it, maybe this goes without saying for all these builtin traits?
2026-02-11 13:48:50 +01:00
Ralf Jung 8c0a493e35 BikeshedGuaranteedNoDrop trait: add comments indicating that it can be observed on stable 2026-02-09 12:03:29 +01:00
Noah Lev 9a30ec8149 Implement MVP for opaque generic const arguments
This is meant to be the interim successor to generic const expressions.
Essentially, const item RHS's will be allowed to do arbitrary const
operations using generics. The limitation is that these const items will
be treated opaquely, like ADTs in nominal typing, such that uses of them
will only be equal if the same const item is referenced. In other words,
two const items with the exact same RHS will not be considered equal.

I also added some logic to check feature gates that depend on others
being enabled (like oGCA depending on mGCA).

= Coherence =

During coherence, OGCA consts should be normalized ambiguously because
they are opaque but eventually resolved to a real value. We don't want
two OGCAs that have the same value to be treated as distinct for
coherence purposes. (Just like opaque types.)

This actually doesn't work yet because there are pre-existing
fundamental issues with equate relations involving consts that need to
be normalized. The problem is that we normalize only one layer of the
const item and don't actually process the resulting anon const. Normally
the created inference variable should be handled, which in this case
would cause us to hit the anon const, but that's not happening.
Specifically, `visit_const` on `Generalizer` should be updated to be
similar to `visit_ty`.
2026-02-08 18:15:11 +00:00
James Barford-Evans 25c1365507 Part 2 refactoring of moving placeholder types to rustc_type_ir 2026-01-29 11:11:40 +00:00