Convert TypeVisitor
and DefIdVisitor
to use VisitorResult
This commit is contained in:
parent
5abfb3775d
commit
be9b125d41
53 changed files with 345 additions and 448 deletions
|
@ -34,7 +34,14 @@ pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
|
|||
s.add_bounds(synstructure::AddBounds::Generics);
|
||||
let body_visit = s.each(|bind| {
|
||||
quote! {
|
||||
::rustc_middle::ty::visit::TypeVisitable::visit_with(#bind, __visitor)?;
|
||||
match ::rustc_ast_ir::visit::VisitorResult::branch(
|
||||
::rustc_middle::ty::visit::TypeVisitable::visit_with(#bind, __visitor)
|
||||
) {
|
||||
::core::ops::ControlFlow::Continue(()) => {},
|
||||
::core::ops::ControlFlow::Break(r) => {
|
||||
return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
s.bind_with(|_| synstructure::BindStyle::Move);
|
||||
|
@ -45,9 +52,9 @@ pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
|
|||
fn visit_with<__V: ::rustc_middle::ty::visit::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(
|
||||
&self,
|
||||
__visitor: &mut __V
|
||||
) -> ::std::ops::ControlFlow<__V::BreakTy> {
|
||||
) -> __V::Result {
|
||||
match *self { #body_visit }
|
||||
::std::ops::ControlFlow::Continue(())
|
||||
<__V::Result as ::rustc_ast_ir::visit::VisitorResult>::output()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue