rustfmt
ICE with expanded code · Issue #6105 · rust-lang/rustfmt (original) (raw)
Code
Minimized from expanded code (i.e. -Zunpretty=expanded
) that we rustfmt
in the Linux kernel to make it easier to read:
const _: () = builtin # offset_of(x, x);
Which makes sense, given:
However, it would be nice to ignore (or format) these so that we can format expanded code.
Meta
It breaks in the latest stable (1.76.0) and nightly:
rustc 1.78.0-nightly (516b6162a 2024-03-03)
Error output
thread 'main' panicked at src/tools/rustfmt/src/expr.rs:405:13:
internal error: entered unreachable code
Backtrace
thread 'main' panicked at src/tools/rustfmt/src/expr.rs:405:13:
internal error: entered unreachable code
stack backtrace:
0: 0x7fbfb27e405f - std::backtrace_rs::backtrace::libunwind::trace::h4257829118b815c0
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
1: 0x7fbfb27e405f - std::backtrace_rs::backtrace::trace_unsynchronized::h8bf698b8571a7ffa
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7fbfb27e405f - std::backtrace::Backtrace::create::hf360b329ac3984cf
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/backtrace.rs:331:13
3: 0x7fbfb27e3fa0 - std::backtrace::Backtrace::force_capture::hce7c17c21d97619a
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/backtrace.rs:312:9
4: 0x7fbfaf49641f - std[f9c89fb8bbe75f53]::panicking::update_hook::<alloc[7bfe078ffefd51e6]::boxed::Box<rustc_driver_impl[5cb1284730e04d20]::install_ice_hook::{closure#0}>>::{closure#0}
5: 0x7fbfb27fef00 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>:🤙:hd5a664d4e890a68c
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/alloc/src/boxed.rs:2030:9
6: 0x7fbfb27fef00 - std::panicking::rust_panic_with_hook::h1329efa5bdc573dd
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/panicking.rs:783:13
7: 0x7fbfb27fec09 - std::panicking::begin_panic_handler::{{closure}}::h6ae91631ec1cf42d
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/panicking.rs:649:13
8: 0x7fbfb27fc186 - std::sys_common::backtrace::__rust_end_short_backtrace::hda139f8d0aadc9cd
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/sys_common/backtrace.rs:171:18
9: 0x7fbfb27fe974 - rust_begin_unwind
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/panicking.rs:645:5
10: 0x7fbfb2849085 - core::panicking::panic_fmt::h862551fb494a270a
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/core/src/panicking.rs:72:14
11: 0x7fbfb2849143 - core::panicking::panic::hddedaf52f5081cd3
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/core/src/panicking.rs:144:5
12: 0x55e95779da61 - rustfmt_nightly[ce9e407bc4d9aa35]::expr::format_expr
13: 0x55e957802286 - <rustfmt_nightly[ce9e407bc4d9aa35]::stmt::Stmt as rustfmt_nightly[ce9e407bc4d9aa35]::rewrite::Rewrite>::rewrite
14: 0x55e9578193aa - <rustfmt_nightly[ce9e407bc4d9aa35]::visitor::FmtVisitor>::walk_stmts
15: 0x55e957812870 - <rustfmt_nightly[ce9e407bc4d9aa35]::visitor::FmtVisitor>::visit_block
16: 0x55e95779ecfb - rustfmt_nightly[ce9e407bc4d9aa35]::expr::rewrite_block_with_visitor
17: 0x55e95779f0cc - rustfmt_nightly[ce9e407bc4d9aa35]::expr::rewrite_block_inner
18: 0x55e95779d5fc - rustfmt_nightly[ce9e407bc4d9aa35]::expr::format_expr
19: 0x55e9577a907f - rustfmt_nightly[ce9e407bc4d9aa35]::expr::rewrite_assign_rhs_expr::<rustc_ast[6684c6343d18f394]::ast::Expr>
20: 0x55e9577ab367 - rustfmt_nightly[ce9e407bc4d9aa35]::expr::rewrite_assign_rhs_with_comments::<&alloc[7bfe078ffefd51e6]:🧵:String, rustc_ast[6684c6343d18f394]::ast::Expr>
21: 0x55e9577b98fd - <rustfmt_nightly[ce9e407bc4d9aa35]::visitor::FmtVisitor>::visit_static
22: 0x55e95781601d - <rustfmt_nightly[ce9e407bc4d9aa35]::visitor::FmtVisitor>::visit_item
23: 0x55e9577f9f06 - <rustfmt_nightly[ce9e407bc4d9aa35]::visitor::FmtVisitor>::visit_items_with_reordering
24: 0x55e957819bdb - <rustfmt_nightly[ce9e407bc4d9aa35]::visitor::FmtVisitor>::format_separate_mod
25: 0x55e9576961ce - <rustfmt_nightly[ce9e407bc4d9aa35]::Session<std[f9c89fb8bbe75f53]::io::stdio::Stdout>>::format_input_inner::{closure#0}
26: 0x55e9576ab731 - rustfmt[22febc4b220ec6a2]::format_and_emit_report::<std[f9c89fb8bbe75f53]::io::stdio::Stdout>
27: 0x55e9576a9bcc - rustfmt[22febc4b220ec6a2]::execute
28: 0x55e9576a529b - rustfmt[22febc4b220ec6a2]::main
29: 0x55e95768fa83 - std[f9c89fb8bbe75f53]::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
30: 0x55e957691d39 - std[f9c89fb8bbe75f53]::rt::lang_start::<()>::{closure#0}
31: 0x7fbfb27e1043 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::he5f334fe0a08c913
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/core/src/ops/function.rs:284:13
32: 0x7fbfb27e1043 - std::panicking::try::do_call::h231e398ce39da676
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/panicking.rs:552:40
33: 0x7fbfb27e1043 - std::panicking::try::h46412093dcdab127
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/panicking.rs:516:19
34: 0x7fbfb27e1043 - std::panic::catch_unwind::hfbb2d28c473eb4dd
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/panic.rs:146:14
35: 0x7fbfb27e1043 - std::rt::lang_start_internal::{{closure}}::h083e0c5f8fcad290
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/rt.rs:148:48
36: 0x7fbfb27e1043 - std::panicking::try::do_call::h37fd7901d6535c55
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/panicking.rs:552:40
37: 0x7fbfb27e1043 - std::panicking::try::h7c485b04206d8759
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/panicking.rs:516:19
38: 0x7fbfb27e1043 - std::panic::catch_unwind::hfea1c5c7d30edbf3
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/panic.rs:146:14
39: 0x7fbfb27e1043 - std::rt::lang_start_internal::hc4df6736fe95cc4a
at /rustc/516b6162a2ea8e66678c09e8243ebd83e4b8eeea/library/std/src/rt.rs:148:20
40: 0x55e9576ac8f5 - main
41: 0x7fbfac319d90 - <unknown>
42: 0x7fbfac319e40 - __libc_start_main
43: 0x55e95767f269 - <unknown>
44: 0x0 - <unknown>
rustc version: 1.78.0-nightly (516b6162a 2024-03-03)
platform: x86_64-unknown-linux-gnu
Cc: @metaspace (who found it when trying to expand his rnull
driver)
From: https://rust-for-linux.zulipchat.com/#narrow/stream/291565-Help/topic/Using.20the.20.2Ersi.20target/near/423973701.