Skip to content

Conversation

ChayimFriedman2
Copy link
Contributor

This fixes a lot of test regressions (@ShoyuVanilla including ones from your PR) and type mismatches.

Fixes #20555.

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.
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.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 10, 2025
Copy link
Member

@ShoyuVanilla ShoyuVanilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the regressed lifetime labels were the evidence of bugs 😅

@ShoyuVanilla ShoyuVanilla added this pull request to the merge queue Sep 10, 2025
Merged via the queue into rust-lang:master with commit 8b2671e Sep 10, 2025
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 10, 2025
@ChayimFriedman2 ChayimFriedman2 deleted the ns-projections branch September 10, 2025 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New solver type mismatch
3 participants