-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,18 +285,15 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> { | |
// The rhs of this `normalizes-to` must always be an unconstrained infer var as it is | ||
// the hack used by `normalizes-to` to ensure that every `normalizes-to` behaves the same | ||
// regardless of the rhs. | ||
// | ||
// 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. | ||
let term = this | ||
.term_is_fully_unconstrained(goal) | ||
.then_some(goal.predicate.term) | ||
.unwrap_or_else(|| { | ||
this.next_term_infer_of_kind(goal.predicate.term) | ||
}); | ||
|
||
// 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does this is worrying to me. I guess maybe we should change that code to replace the rhs with a new infer var, call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yeah i can do that, i have a branch that does that and coincidentally the code actually gets a bit cleaner too... |
||
// Or if this assertion ever fails, at least we have a useful test case :^) | ||
assert!(!this.term_is_fully_unconstrained(goal)); | ||
|
||
let fresh_term = this.next_term_infer_of_kind(goal.predicate.term); | ||
let projection_pred = ty::ProjectionPredicate { | ||
term, | ||
term: fresh_term, | ||
projection_ty: goal.predicate.projection_ty, | ||
}; | ||
new_goals.normalizes_to_hack_goal = | ||
|
There was a problem hiding this comment.
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.