Don't normalize constants unless they need normalization
This commit is contained in:
parent
7eef946fc0
commit
152646f23f
@ -647,7 +647,7 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn fold_const(&mut self, constant: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||
let tcx = self.selcx.tcx();
|
||||
if tcx.lazy_normalization() {
|
||||
if tcx.lazy_normalization() || !needs_normalization(&constant, self.param_env.reveal()) {
|
||||
constant
|
||||
} else {
|
||||
let constant = constant.super_fold_with(self);
|
||||
|
@ -353,6 +353,10 @@ fn try_fold_const(
|
||||
&mut self,
|
||||
constant: ty::Const<'tcx>,
|
||||
) -> Result<ty::Const<'tcx>, Self::Error> {
|
||||
if !needs_normalization(&constant, self.param_env.reveal()) {
|
||||
return Ok(constant);
|
||||
}
|
||||
|
||||
let constant = constant.try_super_fold_with(self)?;
|
||||
debug!(?constant, ?self.param_env);
|
||||
Ok(crate::traits::project::with_replaced_escaping_bound_vars(
|
||||
|
Loading…
Reference in New Issue
Block a user