about summary refs log tree commit diff
path: root/compiler/rustc_infer/src/traits/structural_impls.rs
diff options
context:
space:
mode:
authorAlan Egerton <eggyal@gmail.com>2021-12-01 00:55:57 +0000
committerAlan Egerton <eggyal@gmail.com>2021-12-02 16:14:16 +0000
commitbfc434b6d0e64dab88def4c5282eeb4a294faf76 (patch)
tree82df3c0e564f6e72abdc13b32b39c8a768dbd513 /compiler/rustc_infer/src/traits/structural_impls.rs
parentdb7295fa960a729a4577e0e206f7a3a5a472addb (diff)
downloadrust-bfc434b6d0e64dab88def4c5282eeb4a294faf76.tar.gz
rust-bfc434b6d0e64dab88def4c5282eeb4a294faf76.zip
Reduce boilerplate around infallible folders
Diffstat (limited to 'compiler/rustc_infer/src/traits/structural_impls.rs')
-rw-r--r--compiler/rustc_infer/src/traits/structural_impls.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_infer/src/traits/structural_impls.rs b/compiler/rustc_infer/src/traits/structural_impls.rs
index 544b8939779..821901dad2b 100644
--- a/compiler/rustc_infer/src/traits/structural_impls.rs
+++ b/compiler/rustc_infer/src/traits/structural_impls.rs
@@ -1,7 +1,7 @@
 use crate::traits;
 use crate::traits::project::Normalized;
 use rustc_middle::ty;
-use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
+use rustc_middle::ty::fold::{TypeFoldable, TypeFolderFallible, TypeVisitor};
 
 use std::fmt;
 use std::ops::ControlFlow;
@@ -60,12 +60,15 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
 // TypeFoldable implementations.
 
 impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx, O> {
-    fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
+    fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
+        self,
+        folder: &mut F,
+    ) -> Result<Self, F::Error> {
         Ok(traits::Obligation {
             cause: self.cause,
             recursion_depth: self.recursion_depth,
-            predicate: self.predicate.fold_with(folder)?,
-            param_env: self.param_env.fold_with(folder)?,
+            predicate: self.predicate.try_fold_with(folder)?,
+            param_env: self.param_env.try_fold_with(folder)?,
         })
     }