diff options
| author | scalexm <alexandre@scalexm.fr> | 2019-02-08 10:46:53 +0100 |
|---|---|---|
| committer | scalexm <alexandre@scalexm.fr> | 2019-03-20 20:03:19 +0100 |
| commit | c3b33a7f3be706d35ee62847342c22406401430a (patch) | |
| tree | 7ae6415cf1ac74fc90695405b418aea477e718cc | |
| parent | 9c499ccfcded4f5be76d70f441a5c7c9d1260226 (diff) | |
| download | rust-c3b33a7f3be706d35ee62847342c22406401430a.tar.gz rust-c3b33a7f3be706d35ee62847342c22406401430a.zip | |
Fix a bug in chalk unification code
| -rw-r--r-- | src/librustc/infer/nll_relate/mod.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/librustc/infer/nll_relate/mod.rs b/src/librustc/infer/nll_relate/mod.rs index 7140af36acb..2db3208953e 100644 --- a/src/librustc/infer/nll_relate/mod.rs +++ b/src/librustc/infer/nll_relate/mod.rs @@ -239,6 +239,7 @@ where first_free_index: ty::DebruijnIndex, scopes: &[BoundRegionScope<'tcx>], ) -> ty::Region<'tcx> { + debug!("replace_bound_regions(scopes={:?})", scopes); if let ty::ReLateBound(debruijn, br) = r { Self::lookup_bound_region(*debruijn, br, first_free_index, scopes) } else { @@ -421,7 +422,13 @@ where // Forbid inference variables in the RHS. bug!("unexpected inference var {:?}", b) } else { - self.relate_ty_var(vid, a) + // We swap the order of `a` and `b` in the call to + // `relate_ty_var` below, so swap the corresponding scopes + // as well. + std::mem::swap(&mut self.a_scopes, &mut self.b_scopes); + let res = self.relate_ty_var(vid, a); + std::mem::swap(&mut self.a_scopes, &mut self.b_scopes); + res } } @@ -436,7 +443,12 @@ where (_, &ty::Projection(projection_ty)) if D::normalization() == NormalizationStrategy::Lazy => { - Ok(self.relate_projection_ty(projection_ty, a)) + // Swap the respective scopes of `a` and `b` (see comment + // above). + std::mem::swap(&mut self.a_scopes, &mut self.b_scopes); + let res = self.relate_projection_ty(projection_ty, a); + std::mem::swap(&mut self.a_scopes, &mut self.b_scopes); + Ok(res) } _ => { |
