-
Notifications
You must be signed in to change notification settings - Fork 936
Open
Labels
Description
minimal reproducible code I find
use tracing::info;
fn test_rust_fmt_panic() {
let _ = response.bytes_stream().eventsource().map(move |event| match event {
Ok(event) => {
todo!();
}
Err(e) => {
tracing::info!(
field1 = %field1,
"**😵😵😵😵**: Error in event source stream: {e:?}, error_class = error class, last succ chunk = latest_succ_sse_chunk generated at
{latest_succ_sse_received_at}",
);
todo!();
}
});
}
It's hard to reproduce, but I am sure that rustfmt panics when formatting tracing::info! macro with multiline string and field assignments(maybe needs some unicode characters and some specific indentation patterns, so I fill some useless words in the example)
stacktrace
thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9:
SourceAnnotation range `(149, 150)` is bigger than source length `138`
stack backtrace:
0: 0x7f7d64eb9a13 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hc465d815da68b65f
1: 0x7f7d65602bbf - core::fmt::write::h6e2eb076f9a0f58d
2: 0x7f7d64eaf543 - std::io::Write::write_fmt::h4034a2ae1c7826d5
3: 0x7f7d64eb9872 - std::sys::backtrace::BacktraceLock::print::h2babb832b0f7487c
4: 0x7f7d64ebd36a - std::panicking::default_hook::{{closure}}::hd2c14db44ce2b2ee
5: 0x7f7d64ebceef - std::panicking::default_hook::h6e7d36bb999fce51
6: 0x7f7d63f847e3 - std[47a95048f41649f2]::panicking::update_hook::<alloc[a82d94b8c3b79735]::boxed::Box<rustc_driver_impl[5ab17e6b36e59dd4]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7f7d64ebdbbb - std::panicking::rust_panic_with_hook::h25a3025a927f112d
8: 0x7f7d64ebd8ba - std::panicking::begin_panic_handler::{{closure}}::h21266e60c12bf697
9: 0x7f7d64eb9ee9 - std::sys::backtrace::__rust_end_short_backtrace::hef199fe2823162f9
10: 0x7f7d64ebd59d - __rustc[a3a962cb80ef9725]::rust_begin_unwind
11: 0x7f7d616a4570 - core::panicking::panic_fmt::hb5cc6ca3635c7279
12: 0x55a5740c3f45 - <annotate_snippets[5f53329adbb7812d]::display_list::structs::DisplayList as core[28534e9693d03804]::convert::From<annotate_snippets[5f53329adbb7812d]::snippet::Snippet>>::from
13: 0x55a574278759 - <rustfmt_nightly[cda62d06b257edc]::format_report_formatter::FormatReportFormatter as core[28534e9693d03804]::fmt::Display>::fmt
14: 0x7f7d65602bbf - core::fmt::write::h6e2eb076f9a0f58d
15: 0x7f7d64ead5ae - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h9cd6c6695e77dd75
16: 0x7f7d64eadee8 - std::io::stdio::_eprint::h40e2fc18f3f6b754
17: 0x55a5741d0551 - rustfmt[a2d7432d336d04af]::format_and_emit_report::<std[47a95048f41649f2]::io::stdio::Stdout>
18: 0x55a5741ce399 - rustfmt[a2d7432d336d04af]::execute
19: 0x55a5741c9c3b - rustfmt[a2d7432d336d04af]::main
20: 0x55a5741bb453 - std[47a95048f41649f2]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
21: 0x55a5741bba09 - std[47a95048f41649f2]::rt::lang_start::<()>::{closure#0}
22: 0x7f7d667de336 - std::rt::lang_start_internal::haa385655e1668df7
23: 0x55a5741d1668 - main
24: 0x7f7d60119d90 - __libc_start_call_main
at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
25: 0x7f7d60119e40 - __libc_start_main_impl
at ./csu/../csu/libc-start.c:392:3
26: 0x55a5740949b9 - <unknown>
27: 0x0 - <unknown>
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rustfmt/issues/new?labels=bug
note: please make sure that you have updated to the latest nightly
note: please attach the file at `rustc-ice-2025-07-21T05_34_44-3329323.txt` to your bug report
query stack during panic:
end of query stack
version:
rustfmt 1.8.0-nightly (35f6036521 2025-06-29)
platform
platform: x86_64-unknown-linux-gnu