|
18 | 18 | //! [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html |
19 | 19 |
|
20 | 20 | use infer::canonical::substitute::substitute_value; |
21 | | -use infer::canonical::{Canonical, CanonicalVarKind, CanonicalVarValues, CanonicalizedQueryResult, |
22 | | - Certainty, QueryRegionConstraint, QueryResult, SmallCanonicalVarValues}; |
| 21 | +use infer::canonical::{ |
| 22 | + Canonical, CanonicalVarKind, CanonicalVarValues, CanonicalizedQueryResult, Certainty, |
| 23 | + QueryRegionConstraint, QueryResult, SmallCanonicalVarValues, |
| 24 | +}; |
23 | 25 | use infer::region_constraints::{Constraint, RegionConstraintData}; |
24 | 26 | use infer::InferCtxtBuilder; |
25 | 27 | use infer::{InferCtxt, InferOk, InferResult, RegionObligation}; |
@@ -276,9 +278,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { |
276 | 278 |
|
277 | 279 | for (index, original_value) in original_values.iter().enumerate() { |
278 | 280 | // ...with the value `v_r` of that variable from the query. |
279 | | - let result_value = query_result |
280 | | - .substitute_projected(self.tcx, &result_subst, |
281 | | - |v| &v.var_values[CanonicalVar::new(index)]); |
| 281 | + let result_value = query_result.substitute_projected(self.tcx, &result_subst, |v| { |
| 282 | + &v.var_values[CanonicalVar::new(index)] |
| 283 | + }); |
282 | 284 | match (original_value.unpack(), result_value.unpack()) { |
283 | 285 | (UnpackedKind::Lifetime(ty::ReErased), UnpackedKind::Lifetime(ty::ReErased)) => { |
284 | 286 | // no action needed |
@@ -312,11 +314,13 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { |
312 | 314 | // ...also include the other query region constraints from the query. |
313 | 315 | output_query_region_constraints.reserve(query_result.value.region_constraints.len()); |
314 | 316 | for r_c in query_result.value.region_constraints.iter() { |
315 | | - output_query_region_constraints.push(r_c.map_bound(|ty::OutlivesPredicate(k1, r2)| { |
316 | | - let k1 = substitute_value(self.tcx, &result_subst, &k1); |
317 | | - let r2 = substitute_value(self.tcx, &result_subst, &r2); |
318 | | - ty::OutlivesPredicate(k1, r2) |
319 | | - })); |
| 317 | + let &ty::OutlivesPredicate(k1, r2) = r_c.skip_binder(); // reconstructed below |
| 318 | + let k1 = substitute_value(self.tcx, &result_subst, &k1); |
| 319 | + let r2 = substitute_value(self.tcx, &result_subst, &r2); |
| 320 | + if k1 != r2.into() { |
| 321 | + output_query_region_constraints |
| 322 | + .push(ty::Binder::bind(ty::OutlivesPredicate(k1, r2))); |
| 323 | + } |
320 | 324 | } |
321 | 325 |
|
322 | 326 | let user_result: R = |
|
0 commit comments