]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_middle/src/ty/normalize_erasing_regions.rs
Recover when failing to normalize closure signature.
[rust.git] / compiler / rustc_middle / src / ty / normalize_erasing_regions.rs
index 66a0a192a87c179a35ed2a3162f937bb59c611bd..9d8a811659433f6b36b4b2043f714a228d24545d 100644 (file)
@@ -112,6 +112,26 @@ pub fn normalize_erasing_late_bound_regions<T>(
         self.normalize_erasing_regions(param_env, value)
     }
 
+    /// If you have a `Binder<'tcx, T>`, you can do this to strip out the
+    /// late-bound regions and then normalize the result, yielding up
+    /// a `T` (with regions erased). This is appropriate when the
+    /// binder is being instantiated at the call site.
+    ///
+    /// N.B., currently, higher-ranked type bounds inhibit
+    /// normalization. Therefore, each time we erase them in
+    /// codegen, we need to normalize the contents.
+    pub fn try_normalize_erasing_late_bound_regions<T>(
+        self,
+        param_env: ty::ParamEnv<'tcx>,
+        value: ty::Binder<'tcx, T>,
+    ) -> Result<T, NormalizationError<'tcx>>
+    where
+        T: TypeFoldable<'tcx>,
+    {
+        let value = self.erase_late_bound_regions(value);
+        self.try_normalize_erasing_regions(param_env, value)
+    }
+
     /// Monomorphizes a type from the AST by first applying the
     /// in-scope substitutions and then normalizing any associated
     /// types.