Skip to content
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

panic in annotated_snippet dep #4968

Open
matthiaskrgr opened this issue Aug 29, 2021 · 5 comments
Open

panic in annotated_snippet dep #4968

matthiaskrgr opened this issue Aug 29, 2021 · 5 comments
Labels
bug Panic, non-idempotency, invalid code, etc. help wanted p-low

Comments

@matthiaskrgr
Copy link
Member

When I run rustfmt ./src/tools/rustfmt/tests/source/cfg_if/mod.rs inside the rustc repo, I get a panic inside the annotated-snipped dependency. Note: it seems that the version that rustfmt uses is outdated (0.8.0 vs 0.9.0) but I don't know if a dependency update will fix the crash.

code:

//! `std_detect`

#[doc(hidden)] // unstable implementation detail
#[unstable(feature = "stdsimd", issue = "27731")]
pub mod detect;

stacktrace:

error[internal]: line formatted, but exceeded maximum width (maximum: 100 (see `max_width` option), found: 272)
   --> /home/matthias/vcs/github/rust_icemaker_rustdoc/src/tools/rustfmt/tests/source/cfg_if/detect/os/linux/cpuinfo.rs:125:125:101
    |
125 | flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm
    |                                                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: set `error_on_unformatted = false` to suppress the warning against comments or string literals

error[internal]: line formatted, but exceeded maximum width (maximum: 100 (see `max_width` option), found: 268)
   --> /home/matthias/vcs/github/rust_icemaker_rustdoc/src/tools/rustfmt/tests/source/cfg_if/detect/os/linux/cpuinfo.rs:145:145:101
    |
145 |             "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm"
    |                                                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: set `error_on_unformatted = false` to suppress the warning against comments or string literals

thread 'main' panicked at 'SourceAnnotation range `(100, 114)` is bigger than source length `111`', /cargo/registry/src/github.com-1ecc6299db9ec823/annotate-snippets-0.8.0/src/display_list/from_snippet.rs:273:9
stack backtrace:
   0:     0x564977f29ebc - std::backtrace_rs::backtrace::libunwind::trace::hf16bab017f241aa7
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x564977f29ebc - std::backtrace_rs::backtrace::trace_unsynchronized::hfc27e8424e499412
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x564977f29ebc - std::sys_common::backtrace::_print_fmt::h5be1efcd85b410a6
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x564977f29ebc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h73cf7b443adc9274
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x564977f4ca5c - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/core/src/fmt/mod.rs:1150:17
   5:     0x564977f26ca5 - std::io::Write::write_fmt::hb955fdedb1f691a8
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/io/mod.rs:1667:15
   6:     0x564977f2b820 - std::sys_common::backtrace::_print::hd5ba2c14c2d68f09
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x564977f2b820 - std::sys_common::backtrace::print::h3b3d8e691bd3d5e8
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x564977f2b820 - std::panicking::default_hook::{{closure}}::h703c292cd78e95a9
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panicking.rs:210:50
   9:     0x564977f2b3db - std::panicking::default_hook::h23aea4a9b2140559
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panicking.rs:227:9
  10:     0x564977f2bed4 - std::panicking::rust_panic_with_hook::hde97eb7782db5504
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panicking.rs:624:17
  11:     0x564977f2b9b0 - std::panicking::begin_panic_handler::{{closure}}::h531b374cb1cba3c4
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panicking.rs:521:13
  12:     0x564977f2a364 - std::sys_common::backtrace::__rust_end_short_backtrace::h170e7849f1857b98
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/sys_common/backtrace.rs:141:18
  13:     0x564977f2b919 - rust_begin_unwind
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panicking.rs:517:5
  14:     0x564977b5838b - std::panicking::begin_panic_fmt::h5a33c3bbb692c362
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panicking.rs:460:5
  15:     0x564977e094b6 - annotate_snippets::display_list::from_snippet::format_slice::h24bf7eb1bf1178b3
  16:     0x564977e066f2 - annotate_snippets::display_list::from_snippet::<impl core::convert::From<annotate_snippets::snippet::Snippet> for annotate_snippets::display_list::structs::DisplayList>::from::h664ae91e8dd31293
  17:     0x564977d0a325 - <rustfmt_nightly::format_report_formatter::FormatReportFormatter as core::fmt::Display>::fmt::hb9ce9897fba5017f
  18:     0x564977f4ca5c - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/core/src/fmt/mod.rs:1150:17
  19:     0x564977f258fe - std::io::Write::write_fmt::h53a022fee3f9ba4e
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/io/mod.rs:1667:15
  20:     0x564977f258fe - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h8a7567a28964690a
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/io/stdio.rs:1112:9
  21:     0x564977f2610c - <std::io::stdio::Stderr as std::io::Write>::write_fmt::h9846093f0899bb34
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/io/stdio.rs:1086:9
  22:     0x564977f2610c - std::io::stdio::print_to::h19f37ed4e2631fbe
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/io/stdio.rs:1192:21
  23:     0x564977f2610c - std::io::stdio::_eprint::hd5fe958f4b15fa3b
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/io/stdio.rs:1216:5
  24:     0x564977c05253 - rustfmt::format_and_emit_report::hf40926c488489c7b
  25:     0x564977bfb56e - rustfmt_nightly::Session<T>::override_config::hfdf1cc8b1ac2d5b8
  26:     0x564977c02b43 - rustfmt::execute::h3162d3eefd716678
  27:     0x564977c00155 - rustfmt::main::h08b90425a39c76c0
  28:     0x564977bfbec3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5fd028dd99929bcd
  29:     0x564977c162b9 - std::rt::lang_start::{{closure}}::h8fe9c6fdb5c6f511
  30:     0x564977f2c4da - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hf530eb2c396d070c
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/core/src/ops/function.rs:259:13
  31:     0x564977f2c4da - std::panicking::try::do_call::hbab0ca478e991868
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panicking.rs:403:40
  32:     0x564977f2c4da - std::panicking::try::hab10c61d9a934c4c
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panicking.rs:367:19
  33:     0x564977f2c4da - std::panic::catch_unwind::hda9242be086d4435
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panic.rs:129:14
  34:     0x564977f2c4da - std::rt::lang_start_internal::{{closure}}::h64b87dee3d403238
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/rt.rs:45:48
  35:     0x564977f2c4da - std::panicking::try::do_call::h281babfb4ef781cc
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panicking.rs:403:40
  36:     0x564977f2c4da - std::panicking::try::hc0b72d1eea0a1037
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panicking.rs:367:19
  37:     0x564977f2c4da - std::panic::catch_unwind::h6076a2dab44912c2
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/panic.rs:129:14
  38:     0x564977f2c4da - std::rt::lang_start_internal::h5ab5a505f676e733
                               at /rustc/5eacec9ec7e112a0de1011519a57c45586d58414/library/std/src/rt.rs:45:20
  39:     0x564977c05dd2 - main
  40:     0x7fd322382b25 - __libc_start_main
  41:     0x564977bf4691 - <unknown>
@calebcartwright
Copy link
Member

calebcartwright commented Sep 2, 2021

When I run rustfmt ./src/tools/rustfmt/tests/source/cfg_if/mod.rs inside the rustc repo, I get a panic inside the annotated-snipped dependency.

Could you elaborate on what you're trying to do?

Not going to pretend like the panic is desirable because to the best of my knowledge we don't have any test cases set up to intentionally trigger any. However, folks should never run any version of rustfmt directly against anything under tests/{source,target}/. These files are only meant to be used by running the rustfmt test suite.

@matthiaskrgr
Copy link
Member Author

Ah well, I was running rustfmt on all the .rs files of the rust repo to see if any of them made rustfmt crash. 😅

@calebcartwright calebcartwright added bug Panic, non-idempotency, invalid code, etc. p-low help wanted labels Sep 3, 2021
karyon added a commit to karyon/rustfmt that referenced this issue Oct 22, 2021
Ref rust-lang#4968. Tabs were always counted to have a width of config.tab_spaces.
Since they actually can have less than that depending on the line's
previous contents, rustfmt would sometimes complain about the line
length even if the line did actually fit.
karyon added a commit to karyon/rustfmt that referenced this issue Oct 22, 2021
Ref rust-lang#4968. Tabs were always counted to have a width of config.tab_spaces.
Since they actually can have less than that depending on the line's
previous contents, rustfmt would sometimes complain about the line
length even if the line did actually fit.
@karyon
Copy link
Contributor

karyon commented Oct 22, 2021

I reduced the panic to this:

// rustfmt-error_on_line_overflow: true
// rustfmt-error_on_unformatted: true
// (these are the options the rustfmt repo uses)

fn panic_with_tabs_2() {
    let a = "tab here:	Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy consectetur adipiscing";
}

The problem is that rustfmt treats counts tabs as multiple characters (code), but annotate_snippets counts tabs as one character. So if rustfmt produces an error at the end of a line that contains tabs, annotate_snippets thinks that error is out of range. There's a somewhat related bug there: rust-lang/annotate-snippets-rs#25. Something similar would probably happen when using tabs for indentation. I don't know how to fix this.

In addition, rustfmt always gave tabs a fixed width, even though they might be narrower depending on the line's previous contents. This made rustfmt complain about lines that actually fit into the line limit. I fixed this in #5039.

@georglauterbach
Copy link

I'm currently running into this problem. This seems to have stalled. When is #5039 going to be merged?

Raekye added a commit to Raekye/rustfmt that referenced this issue Dec 7, 2022
* Internally, rustfmt preserves tabs and counts them as multiple
  characters (based on configuration).
* The annoted_snippet dependency counts tabs as 1 character.
* If rustfmt produces an error on a line containing tabs,
  annotated_snippet may think that the error is out of range and panic.
* Have rustfmt internally replace tabs with the corresponding number of
  spaces, so that columns can be counted unambiguously.
* This change is based on PR rust-lang#5039 by karyon, but with the code review
  suggestions by camsteffen.
@sosthene-nitrokey
Copy link

I also stumbled across a similar panic, it's probably a similar bug, since it involves a wide unicode character

In the rustfmt_crash.rs file:

/// ↑  
pub fn rustfmt_panic() {}

Note that there are 2 spaces after , I attached the file for reproduction.

rustfmt +nightly --config error_on_unformatted=true rustfmt_crash.rs gives:

thread 'main' panicked at 'SourceAnnotation range `(5, 9)` is bigger than source length `7`', /cargo/registry/src/index.crates.io-6f17d22bba15001f/annotate-snippets-0.9.1/src/display_list/from_snippet.rs:286:9
stack backtrace:
   0:     0x7fee19968c41 - trace
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fee19968c41 - trace_unsynchronized<std::sys_common::backtrace::_print_fmt::{closure_env#1}>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fee19968c41 - _print_fmt
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fee19968c41 - fmt
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fee199c95ff - fmt
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/core/src/fmt/rt.rs:138:9
   5:     0x7fee199c95ff - write
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fee1995bee1 - write_fmt<std::sys::unix::stdio::Stderr>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/io/mod.rs:1713:15
   7:     0x7fee19968a55 - _print
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fee19968a55 - print
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fee1996b737 - {closure#1}
  10:     0x7fee1996b524 - default_hook
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/panicking.rs:288:9
  11:     0x7fee1cbca21b - rustc_driver_impl[8ae47c5ef82a055a]::install_ice_hook::{closure#0}
  12:     0x7fee1996be7d - call<(&core::panic::panic_info::PanicInfo), (dyn core::ops::function::Fn<(&core::panic::panic_info::PanicInfo), Output=()> + core::marker::Send + core::marker::Sync), alloc::alloc::Global>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/alloc/src/boxed.rs:1999:9
  13:     0x7fee1996be7d - rust_panic_with_hook
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/panicking.rs:709:13
  14:     0x7fee1996bc17 - {closure#0}
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/panicking.rs:597:13
  15:     0x7fee19969076 - __rust_end_short_backtrace<std::panicking::begin_panic_handler::{closure_env#0}, !>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/sys_common/backtrace.rs:151:18
  16:     0x7fee1996b962 - begin_panic_handler
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/panicking.rs:593:5
  17:     0x7fee199c5883 - panic_fmt
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/core/src/panicking.rs:67:14
  18:     0x55a764e2cb64 - annotate_snippets[111d9bcc3a2e250f]::display_list::from_snippet::format_slice
  19:     0x55a764e29263 - <annotate_snippets[111d9bcc3a2e250f]::display_list::structs::DisplayList as core[a1b3bc6790436041]::convert::From<annotate_snippets[111d9bcc3a2e250f]::snippet::Snippet>>::from
  20:     0x55a764d7feb5 - <rustfmt_nightly[30be6f95dc693ab7]::format_report_formatter::FormatReportFormatter as core[a1b3bc6790436041]::fmt::Display>::fmt
  21:     0x7fee199c95ff - fmt
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/core/src/fmt/rt.rs:138:9
  22:     0x7fee199c95ff - write
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/core/src/fmt/mod.rs:1094:21
  23:     0x7fee19959ff5 - write_fmt<std::io::stdio::StderrLock>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/io/mod.rs:1713:15
  24:     0x7fee19959ff5 - write_fmt
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/io/stdio.rs:945:9
  25:     0x7fee1995aa5b - write_fmt
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/io/stdio.rs:919:9
  26:     0x7fee1995aa5b - print_to<std::io::stdio::Stderr>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/io/stdio.rs:1018:21
  27:     0x7fee1995aa5b - _eprint
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/io/stdio.rs:1106:5
  28:     0x55a764c284b2 - rustfmt[fb4e429fc1627179]::format_and_emit_report::<std[26e0ce58da05cd1d]::io::stdio::Stdout>
  29:     0x55a764c15239 - <rustfmt_nightly[30be6f95dc693ab7]::Session<std[26e0ce58da05cd1d]::io::stdio::Stdout>>::override_config::<rustfmt[fb4e429fc1627179]::format::{closure#0}, ()>
  30:     0x55a764c270d0 - rustfmt[fb4e429fc1627179]::execute
  31:     0x55a764c24fb6 - rustfmt[fb4e429fc1627179]::main
  32:     0x55a764c12df3 - std[26e0ce58da05cd1d]::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  33:     0x55a764c12e09 - std[26e0ce58da05cd1d]::rt::lang_start::<()>::{closure#0}
  34:     0x7fee1994cb35 - call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/core/src/ops/function.rs:284:13
  35:     0x7fee1994cb35 - do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/panicking.rs:500:40
  36:     0x7fee1994cb35 - try<i32, &(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/panicking.rs:464:19
  37:     0x7fee1994cb35 - catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/panic.rs:142:14
  38:     0x7fee1994cb35 - {closure#2}
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/rt.rs:148:48
  39:     0x7fee1994cb35 - do_call<std::rt::lang_start_internal::{closure_env#2}, isize>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/panicking.rs:500:40
  40:     0x7fee1994cb35 - try<isize, std::rt::lang_start_internal::{closure_env#2}>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/panicking.rs:464:19
  41:     0x7fee1994cb35 - catch_unwind<std::rt::lang_start_internal::{closure_env#2}, isize>
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/panic.rs:142:14
  42:     0x7fee1994cb35 - lang_start_internal
                               at /rustc/8b35c0bb0f833c0077dc57006eb317edde2a2d1e/library/std/src/rt.rs:148:20
  43:     0x55a764c29075 - main
  44:     0x7fee195be850 - <unknown>
  45:     0x7fee195be90a - __libc_start_main
  46:     0x55a764c0d9f9 - <unknown>
  47:                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.72.0-nightly (8b35c0bb0 2023-06-08) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

Raekye added a commit to Raekye/rustfmt that referenced this issue Aug 27, 2023
* Internally, rustfmt preserves tabs and counts them as multiple
  characters (based on configuration).
* The annotated_snippet dependency always counts tabs as 1 character.
* If rustfmt tries to display an error on a line containing tabs,
  the indicies are mismatched.
* In the extreme case, annotated_snippet may try to access out-of-range
  indices, and panic.
* This change is based on the code review by camsteffen on PR rust-lang#5039 by
  karyon: have rustfmt internally replace tabs with the corresponding
  number of spaces, so that columns/indices in the buffer passed to
  annotated_snippet are counted (unambiguously and) the same.
Raekye added a commit to Raekye/rustfmt that referenced this issue Dec 3, 2023
* Internally, rustfmt preserves tabs and counts them as multiple
  characters (based on configuration).
* The annotated_snippet dependency always counts tabs as 1 character.
* If rustfmt tries to display an error on a line containing tabs,
  the indicies are mismatched.
* In the extreme case, annotated_snippet may try to access out-of-range
  indices, and panic.
* This change is based on the code review by camsteffen on PR rust-lang#5039 by
  karyon: have rustfmt internally replace tabs with the corresponding
  number of spaces, so that columns/indices in the buffer passed to
  annotated_snippet are counted (unambiguously and) the same.
Raekye added a commit to Raekye/rustfmt that referenced this issue Dec 30, 2023
* With hard_tabs, rustfmt preserves tabs and counts them as multiple
  characters/columns (based on configuration).
* The annotated_snippet dependency, used to display errors, always
  counts tabs as 1 character.
* If rustfmt tries to report an error on a line containing tabs,
  the indices are mismatched.
* annotated_snippet will display the wrong range of the source code
  slice; in the extreme case, it can panic with out-of-bounds access.
* The test case added in this commit is expected to currently fail,
  since this commit doesn't include the fix.
Raekye added a commit to Raekye/rustfmt that referenced this issue Dec 30, 2023
* This change is based on the code review by camsteffen on PR
  rust-lang#5039 by karyon: have rustfmt internally replace tabs with
  the corresponding number of spaces, so that columns/indices in the
  buffer passed to annotated_snippet are counted unambiguously.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. help wanted p-low
Projects
None yet
Development

No branches or pull requests

5 participants