Skip to content

[ICE]: SourceAnnotation range (21, 22) is bigger than source length 20 #6826

@jieyouxu

Description

@jieyouxu

Pulling #6083 (comment) out of the original issue, because the original issue may have been fixed but this instance is not (still ICEs on stable).

Code

repro.rs:

pub fn check(c: char) -> bool {
        c.is_ascii_alphanumeric() // 123
        || c == '。' 
        || c == '、'
}

Configuration

rustfmt cli options used (if applicable):

$ rustfmt --check

Same with rustfmt.

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

Reproduction Steps

  1. Create repro.rs
  2. rustfmt repro.rs --check

Meta

rustfmt --version:

rustfmt 1.8.0-stable (4a4ef493e3 2026-03-02)

Error output

thread 'main' (45492) panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9:
SourceAnnotation range `(21, 22)` is bigger than source length `20`
Backtrace

thread 'main' (45492) panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9:
SourceAnnotation range `(21, 22)` is bigger than source length `20`
stack backtrace:
   0:        0x10fddf634 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hcde33371d8bba08b
   1:        0x10d0301fc - core::fmt::write::h8a52dffc4df6d016
   2:        0x10fd99260 - std::io::Write::write_fmt::h2fd0abc6933d662d
   3:        0x10fdb1ea4 - std::panicking::default_hook::{{closure}}::h1af7615be47c43ab
   4:        0x10fdb1dac - std::panicking::default_hook::hdcc779fdbf67ae29
   5:        0x10dc7b378 - std[b190ad38c85ed59a]::panicking::update_hook::<alloc[cec09d4d3689febe]::boxed::Box<rustc_driver_impl[185e3967a9919f9d]::install_ice_hook::{closure#1}>>::{closure#0}
   6:        0x10fdb22d0 - std::panicking::panic_with_hook::h455d3ea9bab4bcbd
   7:        0x10fdb1f4c - std::panicking::panic_handler::{{closure}}::h2068a0d88ec25e56
   8:        0x10fdab9e4 - std::sys::backtrace::__rust_end_short_backtrace::h7bea34f9056001ee
   9:        0x10fd8f64c - __rustc[4425a7e20b4c8619]::rust_begin_unwind
  10:        0x112b17120 - core::panicking::panic_fmt::hc9b4228954207328
  11:        0x100fce234 - <annotate_snippets[99afbe11a00f89d6]::display_list::structs::DisplayList as core[a936a58af82ee723]::convert::From<annotate_snippets[99afbe11a00f89d6]::snippet::Snippet>>::from
  12:        0x10118861c - <rustfmt_nightly[133d678396802fbd]::format_report_formatter::FormatReportFormatter as core[a936a58af82ee723]::fmt::Display>::fmt
  13:        0x10d0301fc - core::fmt::write::h8a52dffc4df6d016
  14:        0x10fdd1bc4 - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h9e4c828e3b68f8a3
  15:        0x10fd9a8d0 - std::io::stdio::_eprint::he932b65433564ac5
  16:        0x10107155c - rustfmt[716b79862f341bd0]::format_and_emit_report::<std[b190ad38c85ed59a]::io::stdio::Stdout>
  17:        0x101081ff0 - rustfmt[716b79862f341bd0]::execute
  18:        0x10107eb54 - rustfmt[716b79862f341bd0]::main
  19:        0x10107d638 - std[b190ad38c85ed59a]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  20:        0x10107db84 - std[b190ad38c85ed59a]::rt::lang_start::<()>::{closure#0}
  21:        0x10fd9bfe8 - std::rt::lang_start_internal::hdd036a54cd97d929
  22:        0x10108a934 - _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: rustc 1.94.0 (4a4ef493e 2026-03-02) 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