about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2024-08-18 23:41:49 -0500
committerGitHub <noreply@github.com>2024-08-18 23:41:49 -0500
commit8a513f1720926799f4507c0bb8fb8d1b164ed459 (patch)
tree35f38ab5390b874a6baf8282ad9d22f5f2c33cf7 /compiler
parentf956bceb6a1302fe3fcb56558e06d3dcbb5d2244 (diff)
parent7fd62320feddcb3fa85a3ab25bc4c0ac55ddac7c (diff)
downloadrust-8a513f1720926799f4507c0bb8fb8d1b164ed459.tar.gz
rust-8a513f1720926799f4507c0bb8fb8d1b164ed459.zip
Rollup merge of #129208 - veluca93:adt_const_fix, r=BoxyUwU
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.

Tracking issue: https://github.com/rust-lang/rust/issues/95174

r? BoxyUwU
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_trait_selection/src/traits/query/normalize.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
index 247b6e4823c..cb96db5f7a2 100644
--- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
@@ -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]