Skip to content

Commit

Permalink
fixes for rustfmt + ast visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
dnbln committed Nov 4, 2023
1 parent a6b41aa commit df85b28
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ pub trait Visitor<'ast>: Sized {
fn visit_inline_asm_sym(&mut self, sym: &'ast InlineAsmSym) {
walk_inline_asm_sym(self, sym)
}
fn visit_capture_by(&mut self, _capture_by: &'ast CaptureBy) {
// Nothing to do
}
}

#[macro_export]
Expand Down Expand Up @@ -857,7 +860,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
}
ExprKind::Closure(box Closure {
binder,
capture_clause: _,
capture_clause,
asyncness: _,
constness: _,
movability: _,
Expand All @@ -866,6 +869,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
fn_decl_span: _,
fn_arg_span: _,
}) => {
visitor.visit_capture_by(capture_clause);
visitor.visit_fn(FnKind::Closure(binder, fn_decl, body), expression.span, expression.id)
}
ExprKind::Block(block, opt_label) => {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rustfmt/src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ fn rewrite_closure_fn_decl(
""
};
let is_async = if asyncness.is_async() { "async " } else { "" };
let mover = if capture == ast::CaptureBy::Value {
let mover = if matches!(capture, ast::CaptureBy::Value { .. }) {
"move "
} else {
""
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rustfmt/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ pub(crate) fn format_expr(
}
}
ast::ExprKind::Gen(capture_by, ref block, ref kind) => {
let mover = if capture_by == ast::CaptureBy::Value {
let mover = if matches!(capture_by, ast::CaptureBy::Value { .. }) {
"move "
} else {
""
Expand Down

0 comments on commit df85b28

Please sign in to comment.