]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_traits/src/normalize_erasing_regions.rs
Rollup merge of #103163 - SUPERCILEX:uninit-array-assume2, r=scottmcm
[rust.git] / compiler / rustc_traits / src / normalize_erasing_regions.rs
index 5d394ed2263ffc8141c96414eb02c4675acaed62..2da64d73d34ac8de76e97e34a6aa2acfc0c150b3 100644 (file)
@@ -18,9 +18,6 @@ pub(crate) fn provide(p: &mut Providers) {
 
             try_normalize_after_erasing_regions(tcx, goal)
         },
-        try_normalize_mir_const_after_erasing_regions: |tcx, goal| {
-            try_normalize_after_erasing_regions(tcx, goal)
-        },
         ..*p
     };
 }
@@ -30,30 +27,29 @@ fn try_normalize_after_erasing_regions<'tcx, T: TypeFoldable<'tcx> + PartialEq +
     goal: ParamEnvAnd<'tcx, T>,
 ) -> Result<T, NoSolution> {
     let ParamEnvAnd { param_env, value } = goal;
-    tcx.infer_ctxt().enter(|infcx| {
-        let cause = ObligationCause::dummy();
-        match infcx.at(&cause, param_env).normalize(value) {
-            Ok(Normalized { value: normalized_value, obligations: normalized_obligations }) => {
-                // We don't care about the `obligations`; they are
-                // always only region relations, and we are about to
-                // erase those anyway:
-                debug_assert_eq!(
-                    normalized_obligations.iter().find(|p| not_outlives_predicate(p.predicate)),
-                    None,
-                );
+    let infcx = tcx.infer_ctxt().build();
+    let cause = ObligationCause::dummy();
+    match infcx.at(&cause, param_env).normalize(value) {
+        Ok(Normalized { value: normalized_value, obligations: normalized_obligations }) => {
+            // We don't care about the `obligations`; they are
+            // always only region relations, and we are about to
+            // erase those anyway:
+            debug_assert_eq!(
+                normalized_obligations.iter().find(|p| not_outlives_predicate(p.predicate)),
+                None,
+            );
 
-                let resolved_value = infcx.resolve_vars_if_possible(normalized_value);
-                // It's unclear when `resolve_vars` would have an effect in a
-                // fresh `InferCtxt`. If this assert does trigger, it will give
-                // us a test case.
-                debug_assert_eq!(normalized_value, resolved_value);
-                let erased = infcx.tcx.erase_regions(resolved_value);
-                debug_assert!(!erased.needs_infer(), "{:?}", erased);
-                Ok(erased)
-            }
-            Err(NoSolution) => Err(NoSolution),
+            let resolved_value = infcx.resolve_vars_if_possible(normalized_value);
+            // It's unclear when `resolve_vars` would have an effect in a
+            // fresh `InferCtxt`. If this assert does trigger, it will give
+            // us a test case.
+            debug_assert_eq!(normalized_value, resolved_value);
+            let erased = infcx.tcx.erase_regions(resolved_value);
+            debug_assert!(!erased.needs_infer(), "{:?}", erased);
+            Ok(erased)
         }
-    })
+        Err(NoSolution) => Err(NoSolution),
+    }
 }
 
 fn not_outlives_predicate<'tcx>(p: ty::Predicate<'tcx>) -> bool {