Make TypeFoldable
implementors short-circuit on error
Co-authored-by: Alan Egerton <eggyal@gmail.com>
This commit is contained in:
parent
c5f0d0ebb4
commit
6e3fa20b00
11 changed files with 299 additions and 204 deletions
|
@ -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)*
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue