Skip to content

Commit

Permalink
Unify {visit,walk}_capture_by
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcabrajac committed Oct 13, 2024
1 parent 7e5f977 commit f6751be
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions compiler/rustc_ast/src/visitors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ macro_rules! make_ast_visitor {
// field access version will continue working and it would be easy to
// forget to add handling for it.

make_visit!{CaptureBy; visit_capture_by, walk_capture_by}
make_visit!{CoroutineKind; visit_coroutine_kind, walk_coroutine_kind}
make_visit!{FnHeader; visit_fn_header, walk_fn_header}
make_visit!{ForeignMod; visit_foreign_mod, walk_foreign_mod}
Expand Down Expand Up @@ -314,15 +313,13 @@ macro_rules! make_ast_visitor {
fn visit_fn_header(&mut self, _header: &'ast FnHeader) -> Self::Result {
Self::Result::output()
}
fn visit_capture_by(&mut self, _capture_by: &'ast CaptureBy) -> Self::Result {
Self::Result::output()
}
}}

make_visit!{AngleBracketedArgs; visit_angle_bracketed_parameter_data, walk_angle_bracketed_parameter_data}
make_visit!{AnonConst; visit_anon_const, walk_anon_const}
make_visit!{AssocItemConstraint; visit_assoc_item_constraint, walk_assoc_item_constraint}
make_visit!{Attribute; visit_attribute, walk_attribute}
make_visit!{CaptureBy; visit_capture_by, walk_capture_by}
make_visit!{ClosureBinder; visit_closure_binder, walk_closure_binder}
make_visit!{Crate; visit_crate, walk_crate}
make_visit!{FnDecl; visit_fn_decl, walk_fn_decl}
Expand Down Expand Up @@ -380,6 +377,19 @@ macro_rules! make_ast_visitor {
return_result!(V)
}

pub fn walk_capture_by<$($lt,)? V: $trait$(<$lt>)?>(
vis: &mut V,
capture_by: ref_t!(CaptureBy)
) -> result!(V) {
match capture_by {
CaptureBy::Ref => {}
CaptureBy::Value { move_kw } => {
try_v!(visit_span!(vis, move_kw))
}
}
return_result!(V)
}

pub fn walk_closure_binder<$($lt,)? V: $trait$(<$lt>)?>(
vis: &mut V,
binder: ref_t!(ClosureBinder)
Expand Down Expand Up @@ -2850,15 +2860,6 @@ pub mod mut_visit {
vis.visit_span(span);
}

fn walk_capture_by<T: MutVisitor>(vis: &mut T, capture_by: &mut CaptureBy) {
match capture_by {
CaptureBy::Ref => {}
CaptureBy::Value { move_kw } => {
vis.visit_span(move_kw);
}
}
}

/// Some value for the AST node that is valid but possibly meaningless. Similar
/// to `Default` but not intended for wide use. The value will never be used
/// meaningfully, it exists just to support unwinding in `visit_clobber` in the
Expand Down

0 comments on commit f6751be

Please sign in to comment.