Skip to content

Commit 1077e36

Browse files
committed
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.
1 parent 426a60a commit 1077e36

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/rustc_trait_selection/src/traits/query/normalize.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,14 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
333333
return Ok(constant);
334334
}
335335

336-
let constant = constant.try_super_fold_with(self)?;
337-
debug!(?constant, ?self.param_env);
338-
Ok(crate::traits::with_replaced_escaping_bound_vars(
336+
let constant = crate::traits::with_replaced_escaping_bound_vars(
339337
self.infcx,
340338
&mut self.universes,
341339
constant,
342340
|constant| constant.normalize(self.infcx.tcx, self.param_env),
343-
))
341+
);
342+
debug!(?constant, ?self.param_env);
343+
constant.try_super_fold_with(self)
344344
}
345345

346346
#[inline]

0 commit comments

Comments
 (0)