-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
normalize in trait_ref_is_knowable
in new solver
#114457
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,44 +388,60 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> { | |
&& is_normalizes_to_hack == IsNormalizesToHack::No | ||
&& !self.search_graph.in_cycle() | ||
{ | ||
debug!("rerunning goal to check result is stable"); | ||
self.search_graph.reset_encountered_overflow(encountered_overflow); | ||
let (_orig_values, canonical_goal) = self.canonicalize_goal(goal); | ||
let Ok(new_canonical_response) = EvalCtxt::evaluate_canonical_goal( | ||
self.tcx(), | ||
self.search_graph, | ||
canonical_goal, | ||
// FIXME(-Ztrait-solver=next): we do not track what happens in `evaluate_canonical_goal` | ||
&mut ProofTreeBuilder::new_noop(), | ||
) else { | ||
bug!( | ||
"goal went from {certainty:?} to error: re-canonicalized goal={canonical_goal:#?} \ | ||
first_response={canonical_response:#?}, | ||
second response was error" | ||
); | ||
}; | ||
// We only check for modulo regions as we convert all regions in | ||
// the input to new existentials, even if they're expected to be | ||
// `'static` or a placeholder region. | ||
if !new_canonical_response.value.var_values.is_identity_modulo_regions() { | ||
bug!( | ||
"unstable result: re-canonicalized goal={canonical_goal:#?} \ | ||
first_response={canonical_response:#?} \ | ||
second_response={new_canonical_response:#?}" | ||
); | ||
} | ||
if certainty != new_canonical_response.value.certainty { | ||
bug!( | ||
"unstable certainty: {certainty:#?} re-canonicalized goal={canonical_goal:#?} \ | ||
first_response={canonical_response:#?} \ | ||
second_response={new_canonical_response:#?}" | ||
); | ||
} | ||
// The nested evaluation has to happen with the original state | ||
// of `encountered_overflow`. | ||
let from_original_evaluation = | ||
self.search_graph.reset_encountered_overflow(encountered_overflow); | ||
self.check_evaluate_goal_stable_result(goal, canonical_goal, canonical_response); | ||
// In case the evaluation was unstable, we manually make sure that this | ||
// debug check does not influence the result of the parent goal. | ||
self.search_graph.reset_encountered_overflow(from_original_evaluation); | ||
} | ||
|
||
Ok((has_changed, certainty, nested_goals)) | ||
} | ||
|
||
fn check_evaluate_goal_stable_result( | ||
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. This check should even when debug assertions are enabled -- otherwise, there's UI test instability between rustc w/ debug_assertions and not. |
||
&mut self, | ||
goal: Goal<'tcx, ty::Predicate<'tcx>>, | ||
original_input: CanonicalInput<'tcx>, | ||
original_result: CanonicalResponse<'tcx>, | ||
) { | ||
let (_orig_values, canonical_goal) = self.canonicalize_goal(goal); | ||
let result = EvalCtxt::evaluate_canonical_goal( | ||
self.tcx(), | ||
self.search_graph, | ||
canonical_goal, | ||
// FIXME(-Ztrait-solver=next): we do not track what happens in `evaluate_canonical_goal` | ||
&mut ProofTreeBuilder::new_noop(), | ||
); | ||
|
||
macro_rules! fail { | ||
($msg:expr) => {{ | ||
let msg = $msg; | ||
warn!( | ||
"unstable result: {msg}\n\ | ||
original goal: {original_input:?},\n\ | ||
original result: {original_result:?}\n\ | ||
re-canonicalized goal: {canonical_goal:?}\n\ | ||
second response: {result:?}" | ||
); | ||
return; | ||
}}; | ||
} | ||
|
||
let Ok(new_canonical_response) = result else { fail!("second response was error") }; | ||
// We only check for modulo regions as we convert all regions in | ||
// the input to new existentials, even if they're expected to be | ||
// `'static` or a placeholder region. | ||
if !new_canonical_response.value.var_values.is_identity_modulo_regions() { | ||
fail!("additional constraints from second response") | ||
} | ||
if original_result.value.certainty != new_canonical_response.value.certainty { | ||
fail!("unstable certainty") | ||
} | ||
} | ||
|
||
fn compute_goal(&mut self, goal: Goal<'tcx, ty::Predicate<'tcx>>) -> QueryResult<'tcx> { | ||
let Goal { param_env, predicate } = goal; | ||
let kind = predicate.kind(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do you think
lazy_normalize_ty
should just return thisFailureKind
?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.
hmm, I think it's valuable to guarantee that
trait_ref_is_knowable
always returns the outerOk
when used outside of the new solver