Skip to content

New solver: assert that normalizes-to hack RHS is always constrained after eval #109583

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

Closed

Conversation

compiler-errors
Copy link
Member

See NOTE below, the then_some branch should never occur in practice.

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 Mar 25, 2023
@rustbot
Copy link
Collaborator

rustbot commented Mar 25, 2023

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

Comment on lines -289 to -291
// However it is important not to unconditionally replace the rhs with a new infer var
// as otherwise we may replace the original unconstrained infer var with a new infer var
// and never propagate any constraints on the new var back to the original var.
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if this ever matters in practice?

Or to put it in another perspective, if this indeed does matter, I don't understand why it's then valid to replace a constrained RHS with a fresh var here without later equating that constrained RHS against that var.

});

// NOTE: This term should never be considered unconstrained, not least due to the fact
// that the universe index has been bumped up at least once by `evaluate_goal` above.
Copy link
Contributor

@lcnr lcnr Mar 27, 2023

Choose a reason for hiding this comment

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

why does evaluate_goal bump the universe index/alternatively is term_is_fully_unconstrained too pessimistic?

this is worrying to me.

I guess maybe we should change that code to replace the rhs with a new infer var, call evaluate_goal for the normalizes_to hack and then emit add an eq goal for the inference vars or sth? that feels safer to me 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess maybe we should change that code to replace the rhs with a new infer var, call evaluate_goal for the normalizes_to hack and then emit add an eq goal for the inference vars or sth? that feels safer to me

yeah i can do that, i have a branch that does that and coincidentally the code actually gets a bit cleaner too...

@compiler-errors
Copy link
Member Author

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 27, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 30, 2023
…-2, r=lcnr,BoxyUwU

Freshen normalizes-to hack goal RHS in the evaluate loop

Ensure that we repeatedly equate the unconstrained RHS of the normalizes-to hack goal with the *actual* RHS of the goal, even if the normalizes-to goal loops several times and thus we replace the unconstrained RHS var repeatedly.

Alternative to rust-lang#109583.
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Mar 30, 2023
…-2, r=lcnr,BoxyUwU

Freshen normalizes-to hack goal RHS in the evaluate loop

Ensure that we repeatedly equate the unconstrained RHS of the normalizes-to hack goal with the *actual* RHS of the goal, even if the normalizes-to goal loops several times and thus we replace the unconstrained RHS var repeatedly.

Alternative to rust-lang#109583.
@compiler-errors compiler-errors deleted the normalizes-to-hack-1 branch August 11, 2023 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

4 participants