Skip to content

Commit 54ce034

Browse files
committed
add fn visit_capture_by to MutVisitor and fix pprust-expr-roundtrip.rs
1 parent df85b28 commit 54ce034

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

compiler/rustc_ast/src/mut_visit.rs

+13
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ pub trait MutVisitor: Sized {
302302
fn visit_format_args(&mut self, fmt: &mut FormatArgs) {
303303
noop_visit_format_args(fmt, self)
304304
}
305+
306+
fn visit_capture_by(&mut self, capture_by: &mut CaptureBy) {
307+
noop_visit_capture_by(capture_by, self)
308+
}
305309
}
306310

307311
/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
@@ -1562,6 +1566,15 @@ pub fn noop_visit_vis<T: MutVisitor>(visibility: &mut Visibility, vis: &mut T) {
15621566
vis.visit_span(&mut visibility.span);
15631567
}
15641568

1569+
pub fn noop_visit_capture_by<T: MutVisitor>(capture_by: &mut CaptureBy, vis: &mut T) {
1570+
match capture_by {
1571+
CaptureBy::Ref => {}
1572+
CaptureBy::Value { move_kw } => {
1573+
vis.visit_span(move_kw);
1574+
}
1575+
}
1576+
}
1577+
15651578
/// Some value for the AST node that is valid but possibly meaningless.
15661579
pub trait DummyAstNode {
15671580
fn dummy() -> Self;

tests/ui-fulldeps/pprust-expr-roundtrip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
130130
iter_exprs(depth - 1, &mut |e| {
131131
g(ExprKind::Closure(Box::new(Closure {
132132
binder: ClosureBinder::NotPresent,
133-
capture_clause: CaptureBy::Value,
133+
capture_clause: CaptureBy::Value { move_kw: DUMMY_SP },
134134
constness: Const::No,
135135
asyncness: Async::No,
136136
movability: Movability::Movable,

0 commit comments

Comments
 (0)