Skip to content

ICE line_index < lines.len() #148684

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

struct cat<U> {
    info: Vec<U>,
    meows: usize,

    how_hungry: isize,
}

pub fn main() {
    let mut nyan: cat<isize> = cat::<usize>(52, 99, vec![9]);
}

original:

//@ run-pass
#![allow(dead_code)]
#![allow(non_camel_case_types)]


struct cat<U> {
    info : Vec<U> ,
    meows : usize,

    how_hungry : isize,
}

impl<U> cat<U> {
    pub fn speak<T>(&mut self, stuff: Vec<T> ) {
        self.meows += stuff.len();
    }
    pub fn meow_count(&mut self) -> usize { self.meows }
}

fn speak<U>(in_x : usize, in_y : isize, in_info: T<U> ) -> cat<U> {
    cat {
        meows: in_x,
        how_hungry: in_y,
        info: in_info
    }
}

pub fn main() {
  let mut nyan : cat<isize> = cat::<usize>(52, 99, vec![9]);
  let mut kitty = cat(1000, 2, vec!["tabby".to_string()]);
  assert_eq!(nyan.how_hungry, 99);
  assert_eq!(kitty.how_hungry, 2);
  nyan.speak(vec![1,2,3]);
  assert_eq!(nyan.meow_count(), 55);
  kitty.speak(vec!["meow"to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()]);
  assert_eq!(kitty.meow_count(), 1004);
}

Version information

rustc 1.93.0-nightly (843f8ce2e 2025-11-07)
binary: rustc
commit-hash: 843f8ce2ebc01d35a30484eadc8a84cdc6130844
commit-date: 2025-11-07
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.3

Possibly related line of code:

pub fn line_bounds(&self, line_index: usize) -> Range<BytePos> {
if self.is_empty() {
return self.start_pos..self.start_pos;
}
let lines = self.lines();
assert!(line_index < lines.len());
if line_index == (lines.len() - 1) {
self.absolute_position(lines[line_index])..self.end_position()
} else {
self.absolute_position(lines[line_index])..self.absolute_position(lines[line_index + 1])
}
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: type `cat` should have an upper camel case name
 --> /tmp/icemaker_global_tempdir.F1g5tlKFlisA/rustc_testrunner_tmpdir_reporting.JKto2pcPmdzW/mvce.rs:1:8
  |
1 | struct cat<U> {
  |        ^^^ help: convert the identifier to upper camel case (notice the capitalization): `Cat`
  |
  = note: `#[warn(non_camel_case_types)]` (part of `#[warn(nonstandard_style)]`) on by default


thread 'rustc' (711452) panicked at compiler/rustc_span/src/lib.rs:2181:9:
assertion failed: line_index < lines.len()
stack backtrace:
   0:     0x7ff2362619f3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h34ffdfe5b35d09bd
   1:     0x7ff236a01afc - core::fmt::write::h44fabcc2c45f5b01
   2:     0x7ff236216473 - std::io::Write::write_fmt::h033bfcde7b068b45
   3:     0x7ff236227b72 - std::sys::backtrace::BacktraceLock::print::h21726ec41a769a6e
   4:     0x7ff23622dbc9 - std::panicking::default_hook::{{closure}}::h3fcc4b417ccd3280
   5:     0x7ff23622d6f3 - std::panicking::default_hook::ha9aeb39b300b35c8
   6:     0x7ff2352221a1 - std[70918e54a4c01c2f]::panicking::update_hook::<alloc[bd51d97ef4855f08]::boxed::Box<rustc_driver_impl[7b62307e987fdf9b]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7ff23622dfef - std::panicking::panic_with_hook::h4253fc3c0f99d3b2
   8:     0x7ff23622dd76 - std::panicking::panic_handler::{{closure}}::h279f7b42e8f430f3
   9:     0x7ff236227cb9 - std::sys::backtrace::__rust_end_short_backtrace::haadc81f22413cc4f
  10:     0x7ff2362087bd - __rustc[6a4d7f6399f48b20]::rust_begin_unwind
  11:     0x7ff233289560 - core::panicking::panic_fmt::ha9b7d4a596fc9998
  12:     0x7ff232c49dec - core::panicking::panic::h9218a293172c2784
  13:     0x7ff237e30806 - rustc_errors[eb190226f309982d]::annotate_snippet_emitter_writer::shrink_file
  14:     0x7ff237e2f0e9 - <core[6e2b95161510a05c]::iter::adapters::filter_map::FilterMap<core[6e2b95161510a05c]::iter::adapters::take::Take<alloc[bd51d97ef4855f08]::vec::into_iter::IntoIter<rustc_errors[eb190226f309982d]::Substitution>>, <rustc_errors[eb190226f309982d]::annotate_snippet_emitter_writer::AnnotateSnippetEmitter>::emit_messages_default::{closure#9}> as core[6e2b95161510a05c]::iter::traits::iterator::Iterator>::next
  15:     0x7ff237e2ba85 - <rustc_errors[eb190226f309982d]::annotate_snippet_emitter_writer::AnnotateSnippetEmitter>::emit_messages_default
  16:     0x7ff237effd36 - <rustc_errors[eb190226f309982d]::annotate_snippet_emitter_writer::AnnotateSnippetEmitter as rustc_errors[eb190226f309982d]::emitter::Emitter>::emit_diagnostic
  17:     0x7ff237efc526 - <rustc_errors[eb190226f309982d]::DiagCtxtInner>::emit_diagnostic::{closure#3}
  18:     0x7ff237efa03d - rustc_interface[ee8ca9de4d50d0ec]::callbacks::track_diagnostic::<core[6e2b95161510a05c]::option::Option<rustc_span[94b94e6084f0e502]::ErrorGuaranteed>>
  19:     0x7ff237ef90b6 - <rustc_errors[eb190226f309982d]::DiagCtxtInner>::emit_diagnostic
  20:     0x7ff237ef8f7f - <rustc_errors[eb190226f309982d]::DiagCtxtHandle>::emit_diagnostic
  21:     0x7ff2333416e0 - <rustc_span[94b94e6084f0e502]::ErrorGuaranteed as rustc_errors[eb190226f309982d]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  22:     0x7ff236cf8480 - <rustc_hir_typeck[a64a265d251a4b4b]::fn_ctxt::FnCtxt>::check_expr_call
  23:     0x7ff236ccb9b8 - <rustc_hir_typeck[a64a265d251a4b4b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:     0x7ff236cad9c4 - <rustc_hir_typeck[a64a265d251a4b4b]::fn_ctxt::FnCtxt>::check_decl
  25:     0x7ff236cc2983 - <rustc_hir_typeck[a64a265d251a4b4b]::fn_ctxt::FnCtxt>::check_expr_block
  26:     0x7ff236ccb993 - <rustc_hir_typeck[a64a265d251a4b4b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27:     0x7ff236c74f71 - rustc_hir_typeck[a64a265d251a4b4b]::check::check_fn
  28:     0x7ff237bbeae2 - rustc_hir_typeck[a64a265d251a4b4b]::typeck_with_inspect::{closure#0}
  29:     0x7ff237bbd4ce - rustc_query_impl[6926355345ea658b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6926355345ea658b]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[32956c401cc86bea]::query::erase::Erased<[u8; 8usize]>>
  30:     0x7ff236d2a337 - rustc_query_system[3737e2f56d9982ce]::query::plumbing::try_execute_query::<rustc_query_impl[6926355345ea658b]::DynamicConfig<rustc_data_structures[72a506bfd180f26d]::vec_cache::VecCache<rustc_span[94b94e6084f0e502]::def_id::LocalDefId, rustc_middle[32956c401cc86bea]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[3737e2f56d9982ce]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[6926355345ea658b]::plumbing::QueryCtxt, false>
  31:     0x7ff236d29cc9 - rustc_query_impl[6926355345ea658b]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7ff236d3ac2d - <rustc_middle[32956c401cc86bea]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[85a88705f15666d0]::check_crate::{closure#2}>::{closure#0}
  33:     0x7ff236d39e99 - rustc_hir_analysis[85a88705f15666d0]::check_crate
  34:     0x7ff236d20470 - rustc_interface[ee8ca9de4d50d0ec]::passes::analysis
  35:     0x7ff236d20133 - rustc_query_impl[6926355345ea658b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6926355345ea658b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[32956c401cc86bea]::query::erase::Erased<[u8; 0usize]>>
  36:     0x7ff237a5c3e6 - rustc_query_system[3737e2f56d9982ce]::query::plumbing::try_execute_query::<rustc_query_impl[6926355345ea658b]::DynamicConfig<rustc_query_system[3737e2f56d9982ce]::query::caches::SingleCache<rustc_middle[32956c401cc86bea]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[6926355345ea658b]::plumbing::QueryCtxt, false>
  37:     0x7ff237a5c03c - rustc_query_impl[6926355345ea658b]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7ff237cdb743 - <rustc_interface[ee8ca9de4d50d0ec]::passes::create_and_enter_global_ctxt<core[6e2b95161510a05c]::option::Option<rustc_interface[ee8ca9de4d50d0ec]::queries::Linker>, rustc_driver_impl[7b62307e987fdf9b]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[6e2b95161510a05c]::ops::function::FnOnce<(&rustc_session[57a374ecf4153235]::session::Session, rustc_middle[32956c401cc86bea]::ty::context::CurrentGcx, alloc[bd51d97ef4855f08]::sync::Arc<rustc_data_structures[72a506bfd180f26d]::jobserver::Proxy>, &std[70918e54a4c01c2f]::sync::once_lock::OnceLock<rustc_middle[32956c401cc86bea]::ty::context::GlobalCtxt>, &rustc_data_structures[72a506bfd180f26d]::sync::worker_local::WorkerLocal<rustc_middle[32956c401cc86bea]::arena::Arena>, &rustc_data_structures[72a506bfd180f26d]::sync::worker_local::WorkerLocal<rustc_hir[ae1e2e3a16b9b894]::Arena>, rustc_driver_impl[7b62307e987fdf9b]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  39:     0x7ff237b3da29 - rustc_interface[ee8ca9de4d50d0ec]::interface::run_compiler::<(), rustc_driver_impl[7b62307e987fdf9b]::run_compiler::{closure#0}>::{closure#1}
  40:     0x7ff237839440 - std[70918e54a4c01c2f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[ee8ca9de4d50d0ec]::util::run_in_thread_with_globals<rustc_interface[ee8ca9de4d50d0ec]::util::run_in_thread_pool_with_globals<rustc_interface[ee8ca9de4d50d0ec]::interface::run_compiler<(), rustc_driver_impl[7b62307e987fdf9b]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  41:     0x7ff237839124 - <<std[70918e54a4c01c2f]::thread::Builder>::spawn_unchecked_<rustc_interface[ee8ca9de4d50d0ec]::util::run_in_thread_with_globals<rustc_interface[ee8ca9de4d50d0ec]::util::run_in_thread_pool_with_globals<rustc_interface[ee8ca9de4d50d0ec]::interface::run_compiler<(), rustc_driver_impl[7b62307e987fdf9b]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[6e2b95161510a05c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7ff237837aaf - std::sys::thread::unix::Thread::new::thread_start::hd76d5080be86b58b
  43:     0x7ff2312969cb - <unknown>
  44:     0x7ff23131aa0c - <unknown>
  45:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.93.0-nightly (843f8ce2e 2025-11-07) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0423`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions