about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/macros.rs
diff options
context:
space:
mode:
authorLeSeulArtichaut <leseulartichaut@gmail.com>2021-05-19 13:34:54 +0200
committerAlan Egerton <eggyal@gmail.com>2021-11-26 07:17:59 +0000
commit6e3fa20b00d5b3713848aa162969d7a460bd194a (patch)
treec6e4ce735e875dff44f4e99c710796d05a3ca5a6 /compiler/rustc_middle/src/macros.rs
parentc5f0d0ebb4eca79491d30bfb6f32a4541faeaa25 (diff)
downloadrust-6e3fa20b00d5b3713848aa162969d7a460bd194a.tar.gz
rust-6e3fa20b00d5b3713848aa162969d7a460bd194a.zip
Make `TypeFoldable` implementors short-circuit on error
Co-authored-by: Alan Egerton <eggyal@gmail.com>
Diffstat (limited to 'compiler/rustc_middle/src/macros.rs')
-rw-r--r--compiler/rustc_middle/src/macros.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/macros.rs b/compiler/rustc_middle/src/macros.rs
index c0f2a76c19d..c0cf265b228 100644
--- a/compiler/rustc_middle/src/macros.rs
+++ b/compiler/rustc_middle/src/macros.rs
@@ -55,8 +55,8 @@ macro_rules! TrivialTypeFoldableImpls {
                 fn super_fold_with<F: $crate::ty::fold::TypeFolder<$tcx>>(
                     self,
                     _: &mut F
-                ) -> $ty {
-                    self
+                ) -> ::std::result::Result<$ty, F::Error> {
+                    Ok(self)
                 }
 
                 fn super_visit_with<F: $crate::ty::fold::TypeVisitor<$tcx>>(
@@ -98,7 +98,7 @@ macro_rules! EnumTypeFoldableImpl {
             fn super_fold_with<V: $crate::ty::fold::TypeFolder<$tcx>>(
                 self,
                 folder: &mut V,
-            ) -> Self {
+            ) -> ::std::result::Result<Self, V::Error> {
                 EnumTypeFoldableImpl!(@FoldVariants(self, folder) input($($variants)*) output())
             }
 
@@ -112,9 +112,9 @@ macro_rules! EnumTypeFoldableImpl {
     };
 
     (@FoldVariants($this:expr, $folder:expr) input() output($($output:tt)*)) => {
-        match $this {
+        Ok(match $this {
             $($output)*
-        }
+        })
     };
 
     (@FoldVariants($this:expr, $folder:expr)
@@ -126,7 +126,7 @@ macro_rules! EnumTypeFoldableImpl {
                 output(
                     $variant ( $($variant_arg),* ) => {
                         $variant (
-                            $($crate::ty::fold::TypeFoldable::fold_with($variant_arg, $folder)),*
+                            $($crate::ty::fold::TypeFoldable::fold_with($variant_arg, $folder)?),*
                         )
                     }
                     $($output)*
@@ -145,7 +145,7 @@ macro_rules! EnumTypeFoldableImpl {
                         $variant {
                             $($variant_arg: $crate::ty::fold::TypeFoldable::fold_with(
                                 $variant_arg, $folder
-                            )),* }
+                            )?),* }
                     }
                     $($output)*
                 )