TypeVisitor: use std::ops::ControlFlow instead of bool

This commit is contained in:
LeSeulArtichaut 2020-10-21 14:22:44 +02:00
parent 8df58ae03a
commit 2c85b6fae0
10 changed files with 243 additions and 165 deletions

View file

@ -15,8 +15,12 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::
}
})
});
let body_visit = s.fold(false, |acc, bind| {
quote! { #acc || ::rustc_middle::ty::fold::TypeFoldable::visit_with(#bind, __folder) }
let body_visit = s.fold(quote!(), |acc, bind| {
quote! {
#acc
::rustc_middle::ty::fold::TypeFoldable::visit_with(#bind, __folder)?;
}
});
s.bound_impl(
@ -32,8 +36,9 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::
fn super_visit_with<__F: ::rustc_middle::ty::fold::TypeVisitor<'tcx>>(
&self,
__folder: &mut __F
) -> bool {
) -> ::std::ops::ControlFlow<(), ()> {
match *self { #body_visit }
::std::ops::ControlFlow::CONTINUE
}
},
)