Skip to content

Error occurs after rustfmt #6392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Rjerk opened this issue Nov 13, 2024 · 3 comments
Closed

Error occurs after rustfmt #6392

Rjerk opened this issue Nov 13, 2024 · 3 comments
Labels
needs-mcve needs a Minimal Complete and Verifiable Example

Comments

@Rjerk
Copy link

Rjerk commented Nov 13, 2024

thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9:
SourceAnnotation range `(100, 102)` is bigger than source length `96`
stack backtrace:
   0:        0x10e58d174 - std::backtrace::Backtrace::create::hf4c6e0fc434c5eff
   1:        0x10c42ada8 - <alloc[8fbefe78ae127760]::boxed::Box<rustc_driver_impl[33c3c8f32b23385a]::install_ice_hook::{closure#0}> as core[cec2e0b2f6f1b021]::ops::function::Fn<(&dyn for<'a, 'b> core[cec2e0b2f6f1b021]::ops::function::Fn<(&'a std[de0be7fd51e0120c]::panic::PanicHookInfo<'b>,), Output = ()> + core[cec2e0b2f6f1b021]::marker::Sync + core[cec2e0b2f6f1b021]::marker::Send, &std[de0be7fd51e0120c]::panic::PanicHookInfo)>>::call
   2:        0x10e5a7d84 - std::panicking::rust_panic_with_hook::hdbb67fdc3f18bef3
   3:        0x10e5a79dc - std::panicking::begin_panic_handler::{{closure}}::h2eba8cd2e2569652
   4:        0x10e5a55a4 - std::sys::backtrace::__rust_end_short_backtrace::he94ac3958b004dd4
   5:        0x10e5a76a0 - _rust_begin_unwind
   6:        0x110c8aee0 - core::panicking::panic_fmt::h215910d4d4559096
   7:        0x1006c4bc0 - annotate_snippets[e9e08054810e66c0]::display_list::from_snippet::format_slice
   8:        0x1006c2960 - <annotate_snippets[e9e08054810e66c0]::display_list::structs::DisplayList as core[cec2e0b2f6f1b021]::convert::From<annotate_snippets[e9e08054810e66c0]::snippet::Snippet>>::from
   9:        0x10057c538 - <rustfmt_nightly[5edc544d64545d24]::format_report_formatter::FormatReportFormatter as core[cec2e0b2f6f1b021]::fmt::Display>::fmt
  10:        0x10b8363c4 - core::fmt::write::h8001b26d0fef496c
  11:        0x10e597470 - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::hbc6623db0693f92c
  12:        0x10e597f50 - std::io::stdio::_eprint::h0a8fd54de440d564
  13:        0x1003c97e4 - rustfmt[53412a93cf81c598]::format_and_emit_report::<std[de0be7fd51e0120c]::io::stdio::Stdout>
  14:        0x1003d0e78 - <rustfmt_nightly[5edc544d64545d24]::Session<std[de0be7fd51e0120c]::io::stdio::Stdout>>::override_config::<rustfmt[53412a93cf81c598]::format::{closure#0}, ()>
  15:        0x1003c83f4 - rustfmt[53412a93cf81c598]::execute
  16:        0x1003c6b5c - rustfmt[53412a93cf81c598]::main
  17:        0x1003d5f58 - std[de0be7fd51e0120c]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  18:        0x1003d8fd8 - std[de0be7fd51e0120c]::rt::lang_start::<()>::{closure#0}
  19:        0x10e58b658 - std::rt::lang_start_internal::h3af41b0d76141967
  20:        0x1003ca4f0 - _main


rustc version: 1.84.0-nightly (f7273e004 2024-11-12)
platform: aarch64-apple-darwin
@ytmimi
Copy link
Contributor

ytmimi commented Nov 13, 2024

@Rjerk thanks for reaching out. Unfortunately, the backtrace isn't enough to go off of. Can you please provide a code snippet that reproduces the panic.

@ytmimi ytmimi added the needs-mcve needs a Minimal Complete and Verifiable Example label Nov 13, 2024
@ytmimi
Copy link
Contributor

ytmimi commented Jan 14, 2025

No MCVE was provided. Going to close this.

@ytmimi ytmimi closed this as not planned Won't fix, can't repro, duplicate, stale Jan 14, 2025
@xiyuzhai
Copy link

I encountered a similar bug.

See https://github.com/xiyuzhai/cargo-fmt-bug-report0.

Run

cargo fmt

Then the compiler will panic like:

thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9:
SourceAnnotation range `(22, 23)` is bigger than source length `22`
stack backtrace:
   0:     0x737704adfb8a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfc616348d9ad0abc
   1:     0x737705214d26 - core::fmt::write::h7ca648217bc79799
   2:     0x737706118711 - std::io::Write::write_fmt::h7960c58bfa5ccbcb
   3:     0x737704adf9e2 - std::sys::backtrace::BacktraceLock::print::h3fb349e80cbe0423
   4:     0x737704ae1f87 - std::panicking::default_hook::{{closure}}::h3366e5842cba645d
   5:     0x737704ae1d70 - std::panicking::default_hook::hd7573a5d4879884b
   6:     0x737703c51c48 - std[26cf95b4f122e720]::panicking::update_hook::<alloc[653926f6abfe8a8a]::boxed::Box<rustc_driver_impl[bcf7efa42268b866]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x737704ae2813 - std::panicking::rust_panic_with_hook::h66e909d048c263a9
   8:     0x737704ae250a - std::panicking::begin_panic_handler::{{closure}}::h8d9aa8be7e8634cf
   9:     0x737704ae0069 - std::sys::backtrace::__rust_end_short_backtrace::h7d7e47ef99abf6aa
  10:     0x737704ae21cd - rust_begin_unwind
  11:     0x7377017a0ef0 - core::panicking::panic_fmt::hf8ffc7c15bfb58a0
  12:     0x5c45a7df2df4 - <annotate_snippets[bc1df9f5ebeb2ffa]::display_list::structs::DisplayList as core[1d264cc251a564c0]::convert::From<annotate_snippets[bc1df9f5ebeb2ffa]::snippet::Snippet>>::from
  13:     0x5c45a7c19f04 - <rustfmt_nightly[e136508bb0dd5df4]::format_report_formatter::FormatReportFormatter as core[1d264cc251a564c0]::fmt::Display>::fmt
  14:     0x737705214d26 - core::fmt::write::h7ca648217bc79799
  15:     0x737704ad3e3e - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::hc6e2c058ec27a44d
  16:     0x737704ad47d8 - std::io::stdio::_eprint::h5c350ea4f4914e82
  17:     0x5c45a7b14353 - rustfmt[f731163ddbbda32b]::format_and_emit_report::<std[26cf95b4f122e720]::io::stdio::Stdout>
  18:     0x5c45a7b11d84 - rustfmt[f731163ddbbda32b]::execute
  19:     0x5c45a7b0e35c - rustfmt[f731163ddbbda32b]::main
  20:     0x5c45a7b02a93 - std[26cf95b4f122e720]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  21:     0x5c45a7b03019 - std[26cf95b4f122e720]::rt::lang_start::<()>::{closure#0}
  22:     0x737706086208 - std::rt::lang_start_internal::heee0af441e41a6d2
  23:     0x5c45a7b153b8 - main
  24:     0x73770022a1ca - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  25:     0x73770022a28b - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:360:3
  26:     0x5c45a7af6529 - <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: rustc 1.85.1 (4eb161250 2025-03-15) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

The source code in the example isn't exactly very minimal. Because if I reduce the lines, the error will mysteriously go away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-mcve needs a Minimal Complete and Verifiable Example
Projects
None yet
Development

No branches or pull requests

3 participants