Skip to content

ICE assertion failed: line_index < lines.len() #148732

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

reuse a as b {
    dbg!(buf);
}

original:

fn a(&self) {
    15
}

reuse a as b {
    let mut reader = BufReader::new(MalformedRead {});
    let mut buf = [0u8; 1024];
    
    for _ in 0..8 {
        let read = reader.read(&mut buf).unwrap();
        dbg!(read);
    }

    reader.read(&mut buf).unwrap();
    dbg!(buf);
}

Version information

rustc 1.93.0-nightly (acda5e9f9 2025-11-09)
binary: rustc
commit-hash: acda5e9f9aadac705b851935b14aa3d34a67d428
commit-date: 2025-11-09
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


thread 'rustc' (3110239) panicked at compiler/rustc_span/src/lib.rs:2181:9:
assertion failed: line_index < lines.len()
stack backtrace:
   0:     0x7fc8c8a6c9c3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h0dc93c2810c40bd0
   1:     0x7fc8c9201afc - core::fmt::write::hacdaf2bbd154e9b5
   2:     0x7fc8c8a21533 - std::io::Write::write_fmt::h75e948926e9dfbe3
   3:     0x7fc8c8a32b42 - std::sys::backtrace::BacktraceLock::print::h251013828edeee18
   4:     0x7fc8c8a38b99 - std::panicking::default_hook::{{closure}}::hf6c9462acd913055
   5:     0x7fc8c8a386c3 - std::panicking::default_hook::h4c9fd5029d2f8b73
   6:     0x7fc8c7a2a721 - std[b4c06921f787550c]::panicking::update_hook::<alloc[7ed4a9fe7ec582b8]::boxed::Box<rustc_driver_impl[87c4f5c8377f9862]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7fc8c8a38fbf - std::panicking::panic_with_hook::h02a757165762df79
   8:     0x7fc8c8a38d46 - std::panicking::panic_handler::{{closure}}::h66210c1b0223aa50
   9:     0x7fc8c8a32c79 - std::sys::backtrace::__rust_end_short_backtrace::h24c6c4da1001b922
  10:     0x7fc8c8a1387d - __rustc[90cdb7b664da1e1e]::rust_begin_unwind
  11:     0x7fc8c5aba730 - core::panicking::panic_fmt::hb5559fbca70a856c
  12:     0x7fc8c54f083c - core::panicking::panic::h28246f2541e05ad3
  13:     0x7fc8ca5bdb46 - rustc_errors[373a255116eccc4c]::annotate_snippet_emitter_writer::shrink_file
  14:     0x7fc8ca5bc429 - <core[f1f7c8de62d6692e]::iter::adapters::filter_map::FilterMap<core[f1f7c8de62d6692e]::iter::adapters::take::Take<alloc[7ed4a9fe7ec582b8]::vec::into_iter::IntoIter<rustc_errors[373a255116eccc4c]::Substitution>>, <rustc_errors[373a255116eccc4c]::annotate_snippet_emitter_writer::AnnotateSnippetEmitter>::emit_messages_default::{closure#9}> as core[f1f7c8de62d6692e]::iter::traits::iterator::Iterator>::next
  15:     0x7fc8ca5b8dc5 - <rustc_errors[373a255116eccc4c]::annotate_snippet_emitter_writer::AnnotateSnippetEmitter>::emit_messages_default
  16:     0x7fc8ca682736 - <rustc_errors[373a255116eccc4c]::annotate_snippet_emitter_writer::AnnotateSnippetEmitter as rustc_errors[373a255116eccc4c]::emitter::Emitter>::emit_diagnostic
  17:     0x7fc8ca67ef26 - <rustc_errors[373a255116eccc4c]::DiagCtxtInner>::emit_diagnostic::{closure#3}
  18:     0x7fc8ca67ca3d - rustc_interface[df9ddd9c9467ef8b]::callbacks::track_diagnostic::<core[f1f7c8de62d6692e]::option::Option<rustc_span[39972e28049286de]::ErrorGuaranteed>>
  19:     0x7fc8ca67bab6 - <rustc_errors[373a255116eccc4c]::DiagCtxtInner>::emit_diagnostic
  20:     0x7fc8ca67b97f - <rustc_errors[373a255116eccc4c]::DiagCtxtHandle>::emit_diagnostic
  21:     0x7fc8c5b8a720 - <rustc_span[39972e28049286de]::ErrorGuaranteed as rustc_errors[373a255116eccc4c]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  22:     0x7fc8c85a092f - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::report_missing_lifetime_specifiers
  23:     0x7fc8c9ea674d - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_anonymous_lifetime
  24:     0x7fc8c9e9eadc - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor as rustc_ast[a5d5f87d51140ae2]::visit::Visitor>::visit_ty
  25:     0x7fc8c9e96150 - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_expr
  26:     0x7fc8c9e9520d - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_expr
  27:     0x7fc8c9e943e2 - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_block
  28:     0x7fc8c9e95835 - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_expr
  29:     0x7fc8c9e943e2 - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_block
  30:     0x7fc8c9e95835 - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_expr
  31:     0x7fc8c9e8fb3f - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::with_rib::<(), <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_arm::{closure#0}>
  32:     0x7fc8c9e95e88 - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_expr
  33:     0x7fc8c9e943e2 - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_block
  34:     0x7fc8c85ab16e - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_delegation
  35:     0x7fc8c9e8506c - <rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>::resolve_item
  36:     0x7fc8c9e79b8a - rustc_ast[a5d5f87d51140ae2]::visit::visit_items::<rustc_resolve[2785ebbc222f0803]::late::LateResolutionVisitor>
  37:     0x7fc8c97eede5 - <rustc_resolve[2785ebbc222f0803]::Resolver>::resolve_crate::{closure#0}
  38:     0x7fc8c97ecb1d - <rustc_resolve[2785ebbc222f0803]::Resolver>::resolve_crate
  39:     0x7fc8c9cee44f - rustc_interface[df9ddd9c9467ef8b]::passes::configure_and_expand
  40:     0x7fc8ca36013f - rustc_interface[df9ddd9c9467ef8b]::passes::resolver_for_lowering_raw
  41:     0x7fc8ca35fe9b - rustc_query_impl[d4db0883806fa552]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d4db0883806fa552]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1e1513fa521466b3]::query::erase::Erased<[u8; 16usize]>>
  42:     0x7fc8ca35fe89 - <rustc_query_impl[d4db0883806fa552]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[f1f7c8de62d6692e]::ops::function::FnOnce<(rustc_middle[1e1513fa521466b3]::ty::context::TyCtxt, ())>>::call_once
  43:     0x7fc8ca248adf - rustc_query_system[d03d33f2f2d15895]::query::plumbing::try_execute_query::<rustc_query_impl[d4db0883806fa552]::DynamicConfig<rustc_query_system[d03d33f2f2d15895]::query::caches::SingleCache<rustc_middle[1e1513fa521466b3]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[d4db0883806fa552]::plumbing::QueryCtxt, false>
  44:     0x7fc8ca24863c - rustc_query_impl[d4db0883806fa552]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  45:     0x7fc8ca509eaa - <rustc_interface[df9ddd9c9467ef8b]::passes::create_and_enter_global_ctxt<core[f1f7c8de62d6692e]::option::Option<rustc_interface[df9ddd9c9467ef8b]::queries::Linker>, rustc_driver_impl[87c4f5c8377f9862]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[f1f7c8de62d6692e]::ops::function::FnOnce<(&rustc_session[5dff62ba5cbc554d]::session::Session, rustc_middle[1e1513fa521466b3]::ty::context::CurrentGcx, alloc[7ed4a9fe7ec582b8]::sync::Arc<rustc_data_structures[aff1d8a073485c2a]::jobserver::Proxy>, &std[b4c06921f787550c]::sync::once_lock::OnceLock<rustc_middle[1e1513fa521466b3]::ty::context::GlobalCtxt>, &rustc_data_structures[aff1d8a073485c2a]::sync::worker_local::WorkerLocal<rustc_middle[1e1513fa521466b3]::arena::Arena>, &rustc_data_structures[aff1d8a073485c2a]::sync::worker_local::WorkerLocal<rustc_hir[2565f01ea710f611]::Arena>, rustc_driver_impl[87c4f5c8377f9862]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  46:     0x7fc8ca38ec69 - rustc_interface[df9ddd9c9467ef8b]::interface::run_compiler::<(), rustc_driver_impl[87c4f5c8377f9862]::run_compiler::{closure#0}>::{closure#1}
  47:     0x7fc8ca08c98f - std[b4c06921f787550c]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[df9ddd9c9467ef8b]::util::run_in_thread_with_globals<rustc_interface[df9ddd9c9467ef8b]::util::run_in_thread_pool_with_globals<rustc_interface[df9ddd9c9467ef8b]::interface::run_compiler<(), rustc_driver_impl[87c4f5c8377f9862]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  48:     0x7fc8ca08c670 - <<std[b4c06921f787550c]::thread::Builder>::spawn_unchecked_<rustc_interface[df9ddd9c9467ef8b]::util::run_in_thread_with_globals<rustc_interface[df9ddd9c9467ef8b]::util::run_in_thread_pool_with_globals<rustc_interface[df9ddd9c9467ef8b]::interface::run_compiler<(), rustc_driver_impl[87c4f5c8377f9862]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f1f7c8de62d6692e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7fc8ca08afef - std::sys::thread::unix::Thread::new::thread_start::h6ee5f4a2e2de181d
  50:     0x7fc8c3a969cb - <unknown>
  51:     0x7fc8c3b1aa0c - <unknown>
  52:                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 (acda5e9f9 2025-11-09) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: aborting due to 1 previous error

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

Metadata

Metadata

Assignees

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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions