Skip to content

Commit bb76851

Browse files
authored
Merge branch 'master' into paren_comment_bug
2 parents 486daff + 202fa22 commit bb76851

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
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
};

tests/rustfmt/main.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,14 @@ fn rustfmt_emits_error_on_line_overflow_true() {
176176
#[test]
177177
#[allow(non_snake_case)]
178178
fn dont_emit_ICE() {
179-
let files = ["tests/target/issue_5728.rs", "tests/target/issue_5729.rs", "tests/target/issue_6069.rs"];
180-
179+
let files = [
180+
"tests/target/issue_5728.rs",
181+
"tests/target/issue_5729.rs",
182+
"tests/target/issue-5885.rs",
183+
"tests/target/issue_6069.rs",
184+
"tests/target/issue-6105.rs",
185+
];
186+
181187
for file in files {
182188
let args = [file];
183189
let (_stdout, stderr) = rustfmt(&args);

tests/target/issue-5885.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("{}", builtin # offset_of(A, 0. 1.1.1));
3+
}

tests/target/issue-6105.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const _: () = builtin # offset_of(x, x);

0 commit comments

Comments
 (0)