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

byte index 4 is not a char boundary; #6422

Closed
matthiaskrgr opened this issue Dec 19, 2024 · 2 comments
Closed

byte index 4 is not a char boundary; #6422

matthiaskrgr opened this issue Dec 19, 2024 · 2 comments
Labels
bug Panic, non-idempotency, invalid code, etc. e-trailing whitespace error[internal]: left behind trailing whitespace

Comments

@matthiaskrgr
Copy link
Member

//


pub fn main() {}

thread 'main' panicked at src/tools/rustfmt/src/missed_spans.rs:216:36:
byte index 4 is not a char boundary; it is inside '\u{2028}' (bytes 3..6) of `//


`
stack backtrace:
   0:     0x78b846f6d72a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h672668bd5fbc6747
   1:     0x78b847613d7c - core::fmt::write::h1c272aa884a4082c
   2:     0x78b848572b51 - std::io::Write::write_fmt::hfd1b0b8c2f046787
   3:     0x78b846f6d582 - std::sys::backtrace::BacktraceLock::print::h4274bb5562f27f33
   4:     0x78b846f6fa7a - std::panicking::default_hook::{{closure}}::h06d790cfc4765386
   5:     0x78b846f6f8c3 - std::panicking::default_hook::hbaba8e6fbddaf0bb
   6:     0x78b8460dc978 - std[1dec83a902989b10]::panicking::update_hook::<alloc[c28ee22c574c43a5]::boxed::Box<rustc_driver_impl[914e6f53ce1bc03e]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x78b846f70238 - std::panicking::rust_panic_with_hook::h1df75c095a4f3488
   8:     0x78b846f6ff2a - std::panicking::begin_panic_handler::{{closure}}::hf3afa20cd541c11f
   9:     0x78b846f6dbd9 - std::sys::backtrace::__rust_end_short_backtrace::h3ced788cfddd85e3
  10:     0x78b846f6fbed - rust_begin_unwind
  11:     0x78b843bb1990 - core::panicking::panic_fmt::ha07a50819406191f
  12:     0x78b845b13677 - core::str::slice_error_fail_rt::h94fc6469cd6e8f26
  13:     0x78b845b1333a - core::str::slice_error_fail::hf74663b5ae173cf4
  14:     0x5b05ddbe8f21 - <rustfmt_nightly[e46619801dc48d84]::visitor::FmtVisitor>::format_missing_inner::<<rustfmt_nightly[e46619801dc48d84]::visitor::FmtVisitor>::format_missing_indent::{closure#0}>
  15:     0x5b05ddc1df88 - <rustfmt_nightly[e46619801dc48d84]::visitor::FmtVisitor>::visit_fn
  16:     0x5b05ddc1f2eb - <rustfmt_nightly[e46619801dc48d84]::visitor::FmtVisitor>::visit_item
  17:     0x5b05ddbffab1 - <rustfmt_nightly[e46619801dc48d84]::visitor::FmtVisitor>::visit_items_with_reordering
  18:     0x5b05ddc2ea4b - <rustfmt_nightly[e46619801dc48d84]::visitor::FmtVisitor>::format_separate_mod
  19:     0x5b05dda8825a - <scoped_tls[e196119f2bca9f54]::ScopedKey<rustc_span[1f5f77272f7ff56d]::SessionGlobals>>::with::<<rustfmt_nightly[e46619801dc48d84]::Session<std[1dec83a902989b10]::io::stdio::Stdout>>::format_input_inner::{closure#0}, core[925518ec66bfeb2a]::result::Result<rustfmt_nightly[e46619801dc48d84]::FormatReport, rustfmt_nightly[e46619801dc48d84]::ErrorKind>>
  20:     0x5b05ddaa2e5b - rustfmt[e1dfe25e16623e65]::format_and_emit_report::<std[1dec83a902989b10]::io::stdio::Stdout>
  21:     0x5b05ddaa0a52 - rustfmt[e1dfe25e16623e65]::execute
  22:     0x5b05dda9ca53 - rustfmt[e1dfe25e16623e65]::main
  23:     0x5b05dda90fa3 - std[1dec83a902989b10]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  24:     0x5b05dda91529 - std[1dec83a902989b10]::rt::lang_start::<()>::{closure#0}
  25:     0x78b8485def58 - std::rt::lang_start_internal::h9084ca16043064bd
  26:     0x5b05ddaa40a8 - main
  27:     0x78b842745e08 - <unknown>
  28:     0x78b842745ecc - __libc_start_main
  29:     0x5b05dda847b9 - <unknown>
  30:                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 `/tmp/im/rustc-ice-2024-12-19T07_27_18-2727633.txt` to your bug report

query stack during panic:
end of query stack
@matthiaskrgr
Copy link
Member Author

a.rs.txt

@ytmimi
Copy link
Contributor

ytmimi commented Dec 19, 2024

In the example above, line 2 ends with a Line Separator, and rustfmt fails when it tries to report the trailing whitespace. Pretty sure this is a duplicate of #5876, and I think there's a good chance this will be fixed by #6391

1 | //
2 |

  | ^ line ends with (U+2028)
  |
3 | pub fn main() {}

@ytmimi ytmimi closed this as completed Dec 19, 2024
@ytmimi ytmimi added bug Panic, non-idempotency, invalid code, etc. e-trailing whitespace error[internal]: left behind trailing whitespace labels Dec 19, 2024
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. e-trailing whitespace error[internal]: left behind trailing whitespace
Projects
None yet
Development

No branches or pull requests

2 participants