Skip to content

Commit f6751be

Browse files
committed
Unify {visit,walk}_capture_by
1 parent 7e5f977 commit f6751be

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ macro_rules! make_ast_visitor {
188188
// field access version will continue working and it would be easy to
189189
// forget to add handling for it.
190190

191-
make_visit!{CaptureBy; visit_capture_by, walk_capture_by}
192191
make_visit!{CoroutineKind; visit_coroutine_kind, walk_coroutine_kind}
193192
make_visit!{FnHeader; visit_fn_header, walk_fn_header}
194193
make_visit!{ForeignMod; visit_foreign_mod, walk_foreign_mod}
@@ -314,15 +313,13 @@ macro_rules! make_ast_visitor {
314313
fn visit_fn_header(&mut self, _header: &'ast FnHeader) -> Self::Result {
315314
Self::Result::output()
316315
}
317-
fn visit_capture_by(&mut self, _capture_by: &'ast CaptureBy) -> Self::Result {
318-
Self::Result::output()
319-
}
320316
}}
321317

322318
make_visit!{AngleBracketedArgs; visit_angle_bracketed_parameter_data, walk_angle_bracketed_parameter_data}
323319
make_visit!{AnonConst; visit_anon_const, walk_anon_const}
324320
make_visit!{AssocItemConstraint; visit_assoc_item_constraint, walk_assoc_item_constraint}
325321
make_visit!{Attribute; visit_attribute, walk_attribute}
322+
make_visit!{CaptureBy; visit_capture_by, walk_capture_by}
326323
make_visit!{ClosureBinder; visit_closure_binder, walk_closure_binder}
327324
make_visit!{Crate; visit_crate, walk_crate}
328325
make_visit!{FnDecl; visit_fn_decl, walk_fn_decl}
@@ -380,6 +377,19 @@ macro_rules! make_ast_visitor {
380377
return_result!(V)
381378
}
382379

380+
pub fn walk_capture_by<$($lt,)? V: $trait$(<$lt>)?>(
381+
vis: &mut V,
382+
capture_by: ref_t!(CaptureBy)
383+
) -> result!(V) {
384+
match capture_by {
385+
CaptureBy::Ref => {}
386+
CaptureBy::Value { move_kw } => {
387+
try_v!(visit_span!(vis, move_kw))
388+
}
389+
}
390+
return_result!(V)
391+
}
392+
383393
pub fn walk_closure_binder<$($lt,)? V: $trait$(<$lt>)?>(
384394
vis: &mut V,
385395
binder: ref_t!(ClosureBinder)
@@ -2850,15 +2860,6 @@ pub mod mut_visit {
28502860
vis.visit_span(span);
28512861
}
28522862

2853-
fn walk_capture_by<T: MutVisitor>(vis: &mut T, capture_by: &mut CaptureBy) {
2854-
match capture_by {
2855-
CaptureBy::Ref => {}
2856-
CaptureBy::Value { move_kw } => {
2857-
vis.visit_span(move_kw);
2858-
}
2859-
}
2860-
}
2861-
28622863
/// Some value for the AST node that is valid but possibly meaningless. Similar
28632864
/// to `Default` but not intended for wide use. The value will never be used
28642865
/// meaningfully, it exists just to support unwinding in `visit_clobber` in the

0 commit comments

Comments
 (0)