Skip to content

Set groundwork for proper const normalization #140549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

BoxyUwU
Copy link
Member

@BoxyUwU BoxyUwU commented May 1, 2025

r? lcnr

Updates a lot of our normalization/alias infrastructure to be setup to handle mgca aliases and normalization once const items are represented more like aliases than bodies. Inherent associated consts are still super busted, I didn't update the assertions that IACs the right arg setup because that winds up being somewhat involved to do before proper support for normalizing const aliases is implemented.

I dont intend for this to have any effect on stable. We continue normalizing via ctfe on stable and the codepaths in project for consts should only be reachable with mgca or ace.

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels May 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 1, 2025

changes to the core type system

cc @compiler-errors, @lcnr

Some changes occurred in match checking

cc @Nadrieril

// system consts that we can retrieve with some `query const_arg_of_alias` query. Evaluating the
// constant is "close enough" to getting the actual rhs of the const item for now even if it might
// lead to some cycles
super::evaluate_const(selcx.infcx, alias_ct, param_env)
Copy link
Member Author

Choose a reason for hiding this comment

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

feature(associated_const_equality) might be a bit more cycle prone now due to evaluating here instead of normalizing to the impl definition and then evaluating? All the tests still pass though so I guess its fine- and both this and the previous way it worked can't stick around long term anyway.

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

need to rebase

also, pls move the normalize.rs move AliasKind branches into subfn into a separate commit if possible. Are there any other changes to that code while moving them?

@BoxyUwU
Copy link
Member Author

BoxyUwU commented May 1, 2025

merge conflicts :despair:

@BoxyUwU
Copy link
Member Author

BoxyUwU commented May 1, 2025

also, pls move the normalize.rs move AliasKind branches into subfn into a separate commit if possible. Are there any other changes to that code while moving them?

Kinda, I had to change stuff from being working on AliasTy to AliasTerm so there's some minor changes for getting the types to line up, but behaviourally speaking it should be the same. I originally had it as its own commit but honestly it didn't really seem to matter much when I was looking over the changes because I had to switch from AliasTy to AliasKind at the same time 🤔 though i guess i could have just not done that... okay lemme split this up

@BoxyUwU BoxyUwU force-pushed the proper_const_norm branch from 6c4b953 to ed128eb Compare May 1, 2025 13:22
@BoxyUwU BoxyUwU force-pushed the proper_const_norm branch from ed128eb to 25821fd Compare May 1, 2025 13:39
@BoxyUwU
Copy link
Member Author

BoxyUwU commented May 1, 2025

Okay first commit should contain no changes to the norm logic other than replacing the two match arms with an if/else. Second commit should be able to be reviewed to see the actual changes to the logic

@BoxyUwU BoxyUwU force-pushed the proper_const_norm branch from 25821fd to 9c29713 Compare May 1, 2025 13:43
@rust-log-analyzer

This comment has been minimized.

@BoxyUwU
Copy link
Member Author

BoxyUwU commented May 1, 2025

Oh

@rustbot
Copy link
Collaborator

rustbot commented May 1, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@BoxyUwU
Copy link
Member Author

BoxyUwU commented May 1, 2025

One of the crashes tests is also fixed by #140553 and in an actually principled way so I've just removed it and will let that PR add the test (which ive verified still ICEs under this PR). The other test I've updated to still reproduce since this PR doesn't really fix it afaik

self.obligations.extend(
infcx.tcx.predicates_of(free.def_id).instantiate_own(infcx.tcx, free.args).map(
|(mut predicate, span)| {
if free.has_escaping_bound_vars() {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do that if free has escaping bound vars instead of checking the predicate?

Copy link
Member Author

Choose a reason for hiding this comment

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

seems generally wrong to be instantiating early binders with bound vars, going to open an issue about this

@BoxyUwU BoxyUwU force-pushed the proper_const_norm branch 3 times, most recently from 5ea4762 to 5fb578e Compare May 1, 2025 19:01
@BoxyUwU BoxyUwU force-pushed the proper_const_norm branch from 5fb578e to 9ec8373 Compare May 1, 2025 19:05
@lcnr
Copy link
Contributor

lcnr commented May 2, 2025

@bors r+ rollup=iffy

@bors
Copy link
Collaborator

bors commented May 2, 2025

📌 Commit 9ec8373 has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 2, 2025
VlaDexa added a commit to VlaDexa/rust that referenced this pull request May 2, 2025
Set groundwork for proper const normalization

r? lcnr

Updates a lot of our normalization/alias infrastructure to be setup to handle mgca aliases and normalization once const items are represented more like aliases than bodies. Inherent associated consts are still super busted, I didn't update the assertions that IACs the right arg setup because that winds up being somewhat involved to do *before* proper support for normalizing const aliases is implemented.

I dont *intend* for this to have any effect on stable. We continue normalizing via ctfe on stable and the codepaths in `project` for consts should only be reachable with mgca or ace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants