Skip to content

normalization rework: clean up projection_ty_core - #160608

Open
khyperia wants to merge 1 commit into
rust-lang:mainfrom
khyperia:cleanup-projection_ty_core
Open

normalization rework: clean up projection_ty_core#160608
khyperia wants to merge 1 commit into
rust-lang:mainfrom
khyperia:cleanup-projection_ty_core

Conversation

@khyperia

@khyperia khyperia commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

in #160443 I was overly conservative in reworking how normalization works in projection_ty_core, because the PR was about other things. However, we can assume PlaceTy::ty is normalized (... I think).

r? lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 6, 2026

@adwinwhite adwinwhite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice cleanup!

r? me

View changes since this review

Comment on lines +482 to +484
|ty, variant_index, field, ()| {
self.normalize(PlaceTy::field_ty(tcx, ty, variant_index, field), locations)
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

field -> field_index

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fair! I just brainlessly reverted to how the code looked before my PR #160443 haha :P

T: ::std::fmt::Debug + Copy,
V: Debug,
T: Debug + Copy,
{

@adwinwhite adwinwhite Aug 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe they should be normalized too. Is it a good idea that we add a debug assert to ensure the invariant holds? like debug_assert!(!tcx.next_trait_solver() || !self.ty.has_non_rigid_aliases()))
Though we seem to have no way of asserting this for the old solver.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For context for others: after discussion, this gets difficult, because we might be looking at serialized MIR from a different crate (e.g. std) that was compiled under the old solver, and hence has non-rigid aliases.

Additionally, even if we build std under the next solver, there's quite a few places that have nonrigid aliases in MIR that should theoretically be cleaned up at some point, but is a bit out of scope for this PR. For example, I think here is one:

EarlyBinder::bind(tcx, body.clone()).instantiate(tcx, args).skip_norm_wip();

@rustbot rustbot assigned adwinwhite and unassigned lcnr Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants