Skip to content

Commit a1725fa

Browse files
committed
Update rustfmt for ast::ExprKind::FormatArgs.
Rustfmt doesn't expand macros, so that's easy: FormatArgs nodes do not occur in the unexpanded AST.
1 parent c878caf commit a1725fa

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/tools/rustfmt/src/expr.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,10 @@ pub(crate) fn format_expr(
399399
}
400400
}
401401
ast::ExprKind::Underscore => Some("_".to_owned()),
402-
ast::ExprKind::IncludedBytes(..) => unreachable!(),
402+
ast::ExprKind::FormatArgs(..) | ast::ExprKind::IncludedBytes(..) => {
403+
// These do not occur in the AST because macros aren't expanded.
404+
unreachable!()
405+
}
403406
ast::ExprKind::Err => None,
404407
};
405408

src/tools/rustfmt/src/utils.rs

+1
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ pub(crate) fn first_line_ends_with(s: &str, c: char) -> bool {
462462
pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr: &str) -> bool {
463463
match expr.kind {
464464
ast::ExprKind::MacCall(..)
465+
| ast::ExprKind::FormatArgs(..)
465466
| ast::ExprKind::Call(..)
466467
| ast::ExprKind::MethodCall(..)
467468
| ast::ExprKind::Array(..)

0 commit comments

Comments
 (0)