Skip to content

Commit d368f0c

Browse files
Don't normalize constants unless they need normalization
1 parent 47ff6ac commit d368f0c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,10 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
638638
if tcx.lazy_normalization() {
639639
constant
640640
} else {
641+
if !constant.needs_normalization(self.param_env.reveal()) {
642+
return constant;
643+
}
644+
641645
let constant = constant.super_fold_with(self);
642646
debug!(?constant, ?self.param_env);
643647
with_replaced_escaping_bound_vars(

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
360360
&mut self,
361361
constant: ty::Const<'tcx>,
362362
) -> Result<ty::Const<'tcx>, Self::Error> {
363+
if !constant.needs_normalization(self.param_env.reveal()) {
364+
return Ok(constant);
365+
}
366+
363367
let constant = constant.try_super_fold_with(self)?;
364368
debug!(?constant, ?self.param_env);
365369
Ok(crate::traits::project::with_replaced_escaping_bound_vars(

0 commit comments

Comments
 (0)