Skip to content

[ICE]: end byte index 100 is not a char boundary; it is inside '☃' (bytes 98..101 of string) #6850

@jieyouxu

Description

@jieyouxu

Context

Code

fn main() {
    "☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃"
}

Configuration

rustfmt cli options used (if applicable):

$ rustfmt +nightly --check --config=error_on_line_overflow=true,error_on_unformatted=true foo.rs

Note that both error_on_line_overflow=true + error_on_unformatted=true are required.

rustfmt configuration file (e.g. rustfmt.toml, if applicable): N/A

Reproduction Steps

  1. Create reproducer foo.rs
    $ cat << 'EOF' > foo.rs
    fn main() {
        "☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃"
    }
    EOF
  2. rustfmt +nightly --check --config=error_on_line_overflow=true,error_on_unformatted=true foo.rs

Meta

rustfmt +nightly --version:

rustfmt 1.9.0-nightly (cf7da0b727 2026-03-30)

Note that nightly seems to be required, on stable internal error is instead reported:

rustfmt 1.8.0-stable (e408947bfd 2026-03-25)
error[internal]: line formatted, but exceeded maximum width (maximum: 100 (see `max_width` option), found: 126)
 --> /Users/joe.xu/Documents/repos/reproducer/foo.rs:2:2:101
  |
2 |     "☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃"
  |                                                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: set `error_on_unformatted = false` to suppress the warning against comments or string literals

warning: rustfmt has failed to format. See previous 1 errors.

Error output

thread 'main' (313655) panicked at /rust/deps/annotate-snippets-0.11.5/src/renderer/display_list.rs:1440:29:
end byte index 100 is not a char boundary; it is inside '☃' (bytes 98..101 of string)
Backtrace

thread 'main' (313655) panicked at /rust/deps/annotate-snippets-0.11.5/src/renderer/display_list.rs:1440:29:
end byte index 100 is not a char boundary; it is inside '☃' (bytes 98..101 of string)
stack backtrace:
   0:        0x11481dc64 - <<std[38c9dfd361ae7da6]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[c8f94c315d1105ca]::fmt::Display>::fmt
   1:        0x11199ad60 - core[c8f94c315d1105ca]::fmt::write
   2:        0x114835454 - <std[38c9dfd361ae7da6]::sys::stdio::unix::Stderr as std[38c9dfd361ae7da6]::io::Write>::write_fmt
   3:        0x1147f4368 - std[38c9dfd361ae7da6]::panicking::default_hook::{closure#0}
   4:        0x1148101c0 - std[38c9dfd361ae7da6]::panicking::default_hook
   5:        0x112688830 - std[38c9dfd361ae7da6]::panicking::update_hook::<alloc[9acb426b54fdd68d]::boxed::Box<rustc_driver_impl[9e63075176584248]::install_ice_hook::{closure#1}>>::{closure#0}
   6:        0x114810524 - std[38c9dfd361ae7da6]::panicking::panic_with_hook
   7:        0x1147f4410 - std[38c9dfd361ae7da6]::panicking::panic_handler::{closure#0}
   8:        0x1147e8df8 - std[38c9dfd361ae7da6]::sys::backtrace::__rust_end_short_backtrace::<std[38c9dfd361ae7da6]::panicking::panic_handler::{closure#0}, !>
   9:        0x1147f59e0 - __rustc[ddcdad3db97d047c]::rust_begin_unwind
  10:        0x1178314a4 - core[c8f94c315d1105ca]::panicking::panic_fmt
  11:        0x11199b180 - core[c8f94c315d1105ca]::str::slice_error_fail_rt
  12:        0x117830fd8 - core[c8f94c315d1105ca]::str::slice_error_fail
  13:        0x104ffd658 - <alloc[9acb426b54fdd68d]::vec::Vec<(usize, annotate_snippets[a637d5bc8f24f830]::snippet::Annotation)>>::retain::<annotate_snippets[a637d5bc8f24f830]::renderer::display_list::format_body::{closure#7}>::{closure#0}
  14:        0x1050031c0 - annotate_snippets[a637d5bc8f24f830]::renderer::display_list::format_snippet
  15:        0x1050022a0 - annotate_snippets[a637d5bc8f24f830]::renderer::display_list::format_message
  16:        0x1051c7d4c - <rustfmt_nightly[69e1b66456789714]::format_report_formatter::FormatReportFormatter as core[c8f94c315d1105ca]::fmt::Display>::fmt
  17:        0x11199ad60 - core[c8f94c315d1105ca]::fmt::write
  18:        0x11483285c - <&std[38c9dfd361ae7da6]::io::stdio::Stderr as std[38c9dfd361ae7da6]::io::Write>::write_fmt
  19:        0x114810e4c - std[38c9dfd361ae7da6]::io::stdio::_eprint
  20:        0x1050a83ac - rustfmt[cf15f111f133bd5c]::format_and_emit_report::<std[38c9dfd361ae7da6]::io::stdio::Stdout>
  21:        0x1050b958c - rustfmt[cf15f111f133bd5c]::execute
  22:        0x1050b58d8 - rustfmt[cf15f111f133bd5c]::main
  23:        0x1050b4204 - std[38c9dfd361ae7da6]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  24:        0x1050b4750 - std[38c9dfd361ae7da6]::rt::lang_start::<()>::{closure#0}
  25:        0x11480e828 - std[38c9dfd361ae7da6]::rt::lang_start_internal
  26:        0x1050c19d0 - _main

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 `/Users/joe.xu/Documents/repos/reproducer/rustc-ice-2026-04-01T05_16_27-46959.txt` to your bug report

note: rustc 1.96.0-nightly (cf7da0b72 2026-03-30) running on aarch64-apple-darwin

query stack during panic:
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-unicodeArea: Unicode handlingC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEI-ICEIssue: Internal Compiler Error (ICE) reported by rustfmt

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions