Make TypeFoldable implementors short-circuit on error

Co-authored-by: Alan Egerton <eggyal@gmail.com>
This commit is contained in:
LeSeulArtichaut 2021-05-19 13:34:54 +02:00 committed by Alan Egerton
parent c5f0d0ebb4
commit 6e3fa20b00
No known key found for this signature in database
GPG key ID: 07CAC3CCA7E0643F
11 changed files with 299 additions and 204 deletions

View file

@ -17,7 +17,7 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::
vi.construct(|_, index| {
let bind = &bindings[index];
quote! {
::rustc_middle::ty::fold::TypeFoldable::fold_with(#bind, __folder)
::rustc_middle::ty::fold::TypeFoldable::fold_with(#bind, __folder)?
}
})
});
@ -28,8 +28,8 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::
fn super_fold_with<__F: ::rustc_middle::ty::fold::TypeFolder<'tcx>>(
self,
__folder: &mut __F
) -> Self {
match self { #body_fold }
) -> Result<Self, __F::Error> {
Ok(match self { #body_fold })
}
fn super_visit_with<__F: ::rustc_middle::ty::fold::TypeVisitor<'tcx>>(