Fix order of normalization and recursion in const folding.
Fixes #126831. Without this patch, type normalization is not always idempotent, which leads to all sorts of bugs in places that assume that normalizing a normalized type does nothing.
This commit is contained in:
parent
426a60abc2
commit
7fd62320fe
2 changed files with 29 additions and 4 deletions
|
@ -333,14 +333,14 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
|
|||
return Ok(constant);
|
||||
}
|
||||
|
||||
let constant = constant.try_super_fold_with(self)?;
|
||||
debug!(?constant, ?self.param_env);
|
||||
Ok(crate::traits::with_replaced_escaping_bound_vars(
|
||||
let constant = crate::traits::with_replaced_escaping_bound_vars(
|
||||
self.infcx,
|
||||
&mut self.universes,
|
||||
constant,
|
||||
|constant| constant.normalize(self.infcx.tcx, self.param_env),
|
||||
))
|
||||
);
|
||||
debug!(?constant, ?self.param_env);
|
||||
constant.try_super_fold_with(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue