Skip to content

Normalize before computing ConstArgHasType goal in new solver #142806

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 1 commit into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jun 20, 2025

This is a fix for #139905. See the description I left in the test.

I chose to fix this by normalizing the type before matching on its .kind() in compute_const_arg_has_type_goal (since it feels somewhat consistent with how we normalize types before assembling their candidates, for example); however, there are several other solutions that come to mind for fixing this ICE:

  1. (this solution)
  2. Giving ConstKind::Error a proper type, like ConstKind::Value, so that consts don't go from failing to passing ConstArgHasType goals after normalization (i.e. UNEVALUATED would normalize into a ConstKind::Error(_, bool) type rather than losing its type altogether).
  3. Just suppressing the errors and accepting the fact that goals can go from fail->pass after normalization.

Thoughts? Happy to discuss this fix further.

r? @BoxyUwU

@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 Jun 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 20, 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.

@compiler-errors compiler-errors changed the title Normalize before computing ConstArgHasType goal Normalize before computing ConstArgHasType goal in new solver Jun 20, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@@ -191,6 +191,7 @@ where
goal: Goal<I, (I::Const, I::Ty)>,
) -> QueryResult<I> {
let (ct, ty) = goal.predicate;
let ct = self.structurally_normalize_const(goal.param_env, ct)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if you want boxy to review this, but it feels very much correct to require normalizing before matching on the const kind here :> it's what we do for all other matches on kind as well.

so r=me here

@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 26, 2025

seems reasonable to me to normalize here. makes a nice property hold. definitely dont want to add a Ty to ConstKind::Error

@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 26, 2025

@bors r=lcnr,BoxyUwU

@bors
Copy link
Collaborator

bors commented Jun 26, 2025

📌 Commit 87c8aa1 has been approved by lcnr,BoxyUwU

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 Jun 26, 2025
@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 26, 2025

I guess more thought: I like to think of it kind of like if const items had ConstArgHasType item bounds, which drawing a parallel to how alias bounds work for types, shouldnt apply if its not a rigid alias so this does just generally feel more consistent to me

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.

6 participants