Skip to content

Commit 2991ec7

Browse files
authored
Replace unreachable! with None
1 parent 73c8149 commit 2991ec7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/expr.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,11 @@ pub(crate) fn format_expr(
404404
ast::ExprKind::FormatArgs(..)
405405
| ast::ExprKind::IncludedBytes(..)
406406
| ast::ExprKind::OffsetOf(..) => {
407-
// These do not occur in the AST because macros aren't expanded.
408-
unreachable!()
407+
// These don't normally occur in the AST because macros aren't expanded. However,
408+
// rustfmt tries to parse macro arguments when formatting macros, so it's not totally
409+
// impossible for rustfmt to come across one of these nodes when formatting a file.
410+
// Also, rustfmt might get passed the output from `-Zunpretty=expanded`.
411+
None
409412
}
410413
ast::ExprKind::Err => None,
411414
};

0 commit comments

Comments
 (0)