-
-
Notifications
You must be signed in to change notification settings - Fork 15.6k
trait_selection: Keep type-op region constraints in borrowck #161423
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
base: main
Are you sure you want to change the base?
Changes from all commits
2c20476
1b5deb1
962324c
7474e2f
16eccd1
0f14fc7
a8fcf21
e578558
7bc04c3
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 |
|---|---|---|
|
|
@@ -146,11 +146,13 @@ impl<'tcx> InferCtxt<'tcx> { | |
| let region_obligations = self.take_registered_region_obligations(); | ||
| let region_assumptions = self.take_registered_region_assumptions(); | ||
| debug!(?region_obligations); | ||
| let solver_constraints = self.clone_solver_region_constraints(); | ||
|
Member
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 not |
||
| let region_constraints = self.with_region_constraints(|region_constraints| { | ||
| make_query_region_constraints( | ||
| region_obligations, | ||
| region_constraints, | ||
| region_assumptions, | ||
| solver_constraints, | ||
| ) | ||
| }); | ||
| debug!(?region_constraints); | ||
|
|
@@ -214,6 +216,13 @@ impl<'tcx> InferCtxt<'tcx> { | |
| self.register_region_assumption(assumption); | ||
| } | ||
|
|
||
| let solver_constraints = instantiate_value( | ||
| self.tcx, | ||
| &result_args, | ||
| query_response.value.region_constraints.solver_constraints.clone(), | ||
| ); | ||
| self.register_solver_region_constraint(solver_constraints.with_spans(cause.span)); | ||
|
|
||
| let user_result: R = | ||
| query_response.instantiate_projected(self.tcx, &result_args, |q_r| q_r.value.clone()); | ||
|
|
||
|
|
@@ -347,6 +356,17 @@ impl<'tcx> InferCtxt<'tcx> { | |
| .map(|&r_c| instantiate_value(self.tcx, &result_args, r_c)), | ||
| ); | ||
|
|
||
| let solver_constraints = instantiate_value( | ||
| self.tcx, | ||
| &result_args, | ||
| query_response.value.region_constraints.solver_constraints.clone(), | ||
| ); | ||
| output_query_region_constraints.solver_constraints = | ||
| ty::region_constraint::RegionConstraint::build_and( | ||
| std::mem::take(&mut output_query_region_constraints.solver_constraints), | ||
| solver_constraints, | ||
| ); | ||
|
|
||
| let user_result: R = | ||
| query_response.instantiate_projected(self.tcx, &result_args, |q_r| q_r.value.clone()); | ||
|
|
||
|
|
@@ -619,6 +639,7 @@ pub fn make_query_region_constraints<'tcx>( | |
| outlives_obligations: Vec<TypeOutlivesConstraint<'tcx>>, | ||
| region_constraints: &RegionConstraintData<'tcx>, | ||
| assumptions: Vec<ty::ArgOutlivesClause<'tcx>>, | ||
| solver_constraints: ty::region_constraint::RegionConstraint<TyCtxt<'tcx>>, | ||
| ) -> QueryRegionConstraints<'tcx> { | ||
| let RegionConstraintData { constraints, verifys } = region_constraints; | ||
|
|
||
|
|
@@ -663,5 +684,5 @@ pub fn make_query_region_constraints<'tcx>( | |
| )) | ||
| .collect(); | ||
|
|
||
| QueryRegionConstraints { constraints, assumptions } | ||
| QueryRegionConstraints { constraints, assumptions, solver_constraints } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -374,6 +374,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate< | |
| region_obligations, | ||
| region_constraints, | ||
| region_assumptions, | ||
| Default::default(), | ||
|
Member
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. Can you add a comment about why we ignore new style constraints here |
||
| ) | ||
| }); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -60,8 +60,8 @@ impl<F> fmt::Debug for CustomTypeOp<F> { | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Executes `op` and then scrapes out all the "old style" region | ||||||||||
| /// constraints that result, creating query-region-constraints. | ||||||||||
| /// Executes `op` and then scrapes out all resulting region constraints, | ||||||||||
| /// creating query-region-constraints. | ||||||||||
|
Comment on lines
+63
to
+64
Member
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.
Suggested change
|
||||||||||
| pub fn scrape_region_constraints<'tcx, Op, R>( | ||||||||||
| infcx: &InferCtxt<'tcx>, | ||||||||||
| root_def_id: LocalDefId, | ||||||||||
|
|
@@ -88,6 +88,11 @@ where | |||||||||
| pre_assumptions.is_empty(), | ||||||||||
| "scrape_region_constraints: incoming region assumptions = {pre_assumptions:#?}", | ||||||||||
| ); | ||||||||||
| let pre_solver_constraints = infcx.take_solver_region_constraints(); | ||||||||||
| assert!( | ||||||||||
| pre_solver_constraints.is_true(), | ||||||||||
| "scrape_region_constraints: incoming solver constraints = {pre_solver_constraints:#?}", | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| let value = infcx.commit_if_ok(|_| { | ||||||||||
| let ocx = ObligationCtxt::new(infcx); | ||||||||||
|
|
@@ -144,11 +149,13 @@ where | |||||||||
|
|
||||||||||
| let region_obligations = infcx.take_registered_region_obligations(); | ||||||||||
| let region_assumptions = infcx.take_registered_region_assumptions(); | ||||||||||
| let solver_constraints = infcx.take_solver_region_constraints(); | ||||||||||
| let region_constraint_data = infcx.take_and_reset_region_constraints(); | ||||||||||
| let region_constraints = query_response::make_query_region_constraints( | ||||||||||
| region_obligations, | ||||||||||
| ®ion_constraint_data, | ||||||||||
| region_assumptions, | ||||||||||
| solver_constraints, | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| if region_constraints.is_empty() { | ||||||||||
|
|
||||||||||
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.
want to add an assert that this is empty? that way the comment cant go out of date