Skip to content

Commit

Permalink
Replace unreachable! with None
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanjaint21 authored and ytmimi committed Mar 16, 2024
1 parent dd301b0 commit fe0d6e1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,11 @@ pub(crate) fn format_expr(
ast::ExprKind::FormatArgs(..)
| ast::ExprKind::IncludedBytes(..)
| ast::ExprKind::OffsetOf(..) => {
// These do not occur in the AST because macros aren't expanded.
unreachable!()
// These don't normally occur in the AST because macros aren't expanded. However,
// rustfmt tries to parse macro arguments when formatting macros, so it's not totally
// impossible for rustfmt to come across one of these nodes when formatting a file.
// Also, rustfmt might get passed the output from `-Zunpretty=expanded`.
None
}
ast::ExprKind::Err => None,
};
Expand Down

0 comments on commit fe0d6e1

Please sign in to comment.