compiler panic on trailing whitespace with await.
Closed this issue · 1 comments
gahooa commented
Today with cargo fmt
I got error: the compiler unexpectedly panicked. this is a bug.
I've managed to narrow the offending code down to this.
- With whitespace at the end of the long line, it panics
- WIthout whitespace at the end of the long line, it does not panic
pub async fn save() {
// update the status to read complete
pg_execute!(
(SELECT MAX(COALESCE(post_lnid, 0)) + 1 FROM intake_silo.postΔ WHERE post_uuid = $post_uuid),
$identity_uuid_principal,
)
.await
}
Steps to reproduce:
- create a new cargo project (cargo new)
- past the above code into src/main.rs
- run
cargo fmt
Observations:
- there must be trailing whitespace on the (SELECT ...) line order to trigger the panic.
- Also, if you remove the .await, there is no panic, even WITH trailing whitespace.
Here is the output on the terminal.
This happened with rust 1.82 and rust 1.83 with no discernible differences. The following is from 1.83.
jason@iron:~/code/acp7r/tmp$ cargo fmt
thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9:
SourceAnnotation range `(102, 103)` is bigger than source length `102`
stack backtrace:
0: 0x773a40ede035 - std::backtrace_rs::backtrace::libunwind::trace::h1a07e5dba0da0cd2
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
1: 0x773a40ede035 - std::backtrace_rs::backtrace::trace_unsynchronized::h61b9b8394328c0bc
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x773a40ede035 - std::sys_common::backtrace::_print_fmt::h1c5e18b460934cff
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:68:5
3: 0x773a40ede035 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1e1a1972118942ad
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:44:22
4: 0x773a40f2d29b - core::fmt::rt::Argument::fmt::h07af2b4071d536cd
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/rt.rs:165:63
5: 0x773a40f2d29b - core::fmt::write::hc090a2ffd6b28c4a
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/mod.rs:1157:21
6: 0x773a40ed2bdf - std::io::Write::write_fmt::h8898bac6ff039a23
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/mod.rs:1832:15
7: 0x773a40edde0e - std::sys_common::backtrace::_print::h4e80c5803d4ee35b
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:47:5
8: 0x773a40edde0e - std::sys_common::backtrace::print::ha96650907276675e
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:34:9
9: 0x773a40ee0779 - std::panicking::default_hook::{{closure}}::h215c2a0a8346e0e0
10: 0x773a40ee04bd - std::panicking::default_hook::h207342be97478370
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:298:9
11: 0x773a3da891b7 - std[3c8ba8ebcf555201]::panicking::update_hook::<alloc[bfbae7e348dce413]::boxed::Box<rustc_driver_impl[c88438ade88661f4]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x773a40ee0e76 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha9c3bc81d312fd83
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2036:9
13: 0x773a40ee0e76 - std::panicking::rust_panic_with_hook::hac8bdceee1e4fe2c
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:799:13
14: 0x773a40ee0c24 - std::panicking::begin_panic_handler::{{closure}}::h00d785e82757ce3c
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:664:13
15: 0x773a40ede4f9 - std::sys_common::backtrace::__rust_end_short_backtrace::h1628d957bcd06996
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:171:18
16: 0x773a40ee0957 - rust_begin_unwind
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
17: 0x773a40f29763 - core::panicking::panic_fmt::hdc63834ffaaefae5
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
18: 0x566bc7215041 - <annotate_snippets[e2773213b0964fb2]::display_list::structs::DisplayList as core[868bc93c3f2beb33]::convert::From<annotate_snippets[e2773213b0964fb2]::snippet::Snippet>>::from
19: 0x566bc71053bc - <rustfmt_nightly[ec1e3a417b7a99d0]::format_report_formatter::FormatReportFormatter as core[868bc93c3f2beb33]::fmt::Display>::fmt
20: 0x773a40f2d29b - core::fmt::rt::Argument::fmt::h07af2b4071d536cd
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/rt.rs:165:63
21: 0x773a40f2d29b - core::fmt::write::hc090a2ffd6b28c4a
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/mod.rs:1157:21
22: 0x773a40ed0c5c - std::io::Write::write_fmt::hb4c7923c70035f80
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/mod.rs:1832:15
23: 0x773a40ed0c5c - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h6886897ec26c96ae
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/stdio.rs:1019:9
24: 0x773a40ed1578 - <std::io::stdio::Stderr as std::io::Write>::write_fmt::h8648e0d9e692118a
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/stdio.rs:993:9
25: 0x773a40ed1578 - std::io::stdio::print_to::he950b71e4e858b6c
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/stdio.rs:1117:21
26: 0x773a40ed1578 - std::io::stdio::_eprint::hfc8d776e0f0e2b9a
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/stdio.rs:1205:5
27: 0x566bc70056b3 - rustfmt[ab00213afa755e1c]::format_and_emit_report::<std[3c8ba8ebcf555201]::io::stdio::Stdout>
28: 0x566bc70037fd - rustfmt[ab00213afa755e1c]::execute
29: 0x566bc6fff5ae - rustfmt[ab00213afa755e1c]::main
30: 0x566bc6feae03 - std[3c8ba8ebcf555201]::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
31: 0x566bc6fed189 - std[3c8ba8ebcf555201]::rt::lang_start::<()>::{closure#0}
32: 0x773a40ec2cb0 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h6abeee5a7794ceb5
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:284:13
33: 0x773a40ec2cb0 - std::panicking::try::do_call::hd6e966bb06877057
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40
34: 0x773a40ec2cb0 - std::panicking::try::hc9b3807f5768cb19
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19
35: 0x773a40ec2cb0 - std::panic::catch_unwind::h94a757c154076c6e
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14
36: 0x773a40ec2cb0 - std::rt::lang_start_internal::{{closure}}::hc5223fb36050c743
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:141:48
37: 0x773a40ec2cb0 - std::panicking::try::do_call::hddf7b4e1ebeb3f69
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40
38: 0x773a40ec2cb0 - std::panicking::try::h1842860a1f941a31
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19
39: 0x773a40ec2cb0 - std::panic::catch_unwind::h009016ccf811d4c3
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14
40: 0x773a40ec2cb0 - std::rt::lang_start_internal::h3ed4fe7b2f419135
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:141:20
41: 0x566bc7006685 - main
42: 0x773a3a829d90 - __libc_start_call_main
at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
43: 0x773a3a829e40 - __libc_start_main_impl
at ./csu/../csu/libc-start.c:392:3
44: 0x566bc6fd9a19 - <unknown>
45: 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: rustc 1.79.0 (129f3b996 2024-06-10) running on x86_64-unknown-linux-gnu
query stack during panic:
end of query stack