Skip to content

ICE: Annotation range 24..24 is beyond the end of buffer 0 #149304

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![doc = include_str!("/bin/id")]

original:

//@ normalize-stderr: "couldn't read.*" -> "couldn't read the file"

#![doc = include_str!("/bin/id")]
struct Documented {}
//~^^ ERROR couldn't read

#[proc_macro]
pub fn make_struct(input: TokenStream) -> TokenStream {
    match input.into_iter().next().unwrap() {
        TokenTree::Ident(ident) => {
            vec![
                TokenTree::Ident(Ident::new("struct", Span::call_site())),
                TokenTree::Ident(Ident::new_raw(&ident.to_string(), Span::call_site())),
                TokenTree::Punct(Punct::new(';', Spacing::Alone))
            ].into_iter().collect()
        }
        _ => panic!()
    }
}

Version information

rustc 1.93.0-nightly (c871d09d1 2025-11-24)
binary: rustc
commit-hash: c871d09d1cc32a649f4c5177bb819646260ed120
commit-date: 2025-11-24
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

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

Program output


thread 'rustc' (9609) panicked at /rust/deps/annotate-snippets-0.12.9/src/renderer/source_map.rs:155:13:
Annotation range `24..24` is beyond the end of buffer `0`
stack backtrace:
   0:     0x7fc68f68fff3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hf888f65f93ea839d
   1:     0x7fc68fe11a48 - core::fmt::write::h15022cb4d9b05a4a
   2:     0x7fc68f645a36 - std::io::Write::write_fmt::h5f1cd3b538c9af13
   3:     0x7fc68f65ccdc - std::panicking::default_hook::{{closure}}::hf3eb06b62bb6a85d
   4:     0x7fc68f65c833 - std::panicking::default_hook::h14941126a583391d
   5:     0x7fc68e6e12b7 - std[f4bec5e5e6e4e88f]::panicking::update_hook::<alloc[2c6f44377e58b7f6]::boxed::Box<rustc_driver_impl[e8dcddc4bc4011ea]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fc68f65d092 - std::panicking::panic_with_hook::h00d3f77a84160385
   7:     0x7fc68f65ce28 - std::panicking::panic_handler::{{closure}}::hc2781bffb256061d
   8:     0x7fc68f656e59 - std::sys::backtrace::__rust_end_short_backtrace::hb97b1e52831a52c2
   9:     0x7fc68f63805d - __rustc[c381d3d25b5a82e6]::rust_begin_unwind
  10:     0x7fc68c81e7cc - core::panicking::panic_fmt::h4c60e555f844d58f
  11:     0x7fc691029262 - <annotate_snippets[68444218d9a27b38]::renderer::source_map::SourceMap>::annotated_lines
  12:     0x7fc69102bfb6 - annotate_snippets[68444218d9a27b38]::renderer::render::render
  13:     0x7fc691270e14 - <rustc_errors[92fa76fb68106120]::annotate_snippet_emitter_writer::AnnotateSnippetEmitter>::emit_messages_default
  14:     0x7fc69127c5ee - <rustc_errors[92fa76fb68106120]::annotate_snippet_emitter_writer::AnnotateSnippetEmitter as rustc_errors[92fa76fb68106120]::emitter::Emitter>::emit_diagnostic
  15:     0x7fc691285fa6 - <rustc_errors[92fa76fb68106120]::DiagCtxtInner>::emit_diagnostic::{closure#3}
  16:     0x7fc691283a73 - rustc_interface[b866789434b6892c]::callbacks::track_diagnostic::<core[4d4135e68af60dbb]::option::Option<rustc_span[30f20a6b156fbd07]::ErrorGuaranteed>>
  17:     0x7fc691282af4 - <rustc_errors[92fa76fb68106120]::DiagCtxtInner>::emit_diagnostic
  18:     0x7fc6912829a1 - <rustc_errors[92fa76fb68106120]::DiagCtxtHandle>::emit_diagnostic
  19:     0x7fc68c89c1fc - <rustc_span[30f20a6b156fbd07]::ErrorGuaranteed as rustc_errors[92fa76fb68106120]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  20:     0x7fc691321473 - rustc_builtin_macros[7dab23d28e0c0ec]::source_util::expand_include_str
  21:     0x7fc691339e23 - <rustc_expand[9805b4ed17b62208]::expand::MacroExpander>::fully_expand_fragment
  22:     0x7fc69132552a - <rustc_expand[9805b4ed17b62208]::expand::MacroExpander>::expand_crate
  23:     0x7fc69088ad7c - rustc_interface[b866789434b6892c]::passes::configure_and_expand
  24:     0x7fc690f6cd55 - rustc_interface[b866789434b6892c]::passes::resolver_for_lowering_raw
  25:     0x7fc690f6cacd - rustc_query_impl[7e7c766fa7067a5c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7e7c766fa7067a5c]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[40d4d6b8740dcd09]::query::erase::Erased<[u8; 16usize]>>
  26:     0x7fc690f6cab3 - <rustc_query_impl[7e7c766fa7067a5c]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[4d4135e68af60dbb]::ops::function::FnOnce<(rustc_middle[40d4d6b8740dcd09]::ty::context::TyCtxt, ())>>::call_once
  27:     0x7fc690f3089f - rustc_query_system[5def49584ea6d57f]::query::plumbing::try_execute_query::<rustc_query_impl[7e7c766fa7067a5c]::DynamicConfig<rustc_query_system[5def49584ea6d57f]::query::caches::SingleCache<rustc_middle[40d4d6b8740dcd09]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[7e7c766fa7067a5c]::plumbing::QueryCtxt, false>
  28:     0x7fc690f303fc - rustc_query_impl[7e7c766fa7067a5c]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fc6910d3f77 - <rustc_interface[b866789434b6892c]::passes::create_and_enter_global_ctxt<core[4d4135e68af60dbb]::option::Option<rustc_interface[b866789434b6892c]::queries::Linker>, rustc_driver_impl[e8dcddc4bc4011ea]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[4d4135e68af60dbb]::ops::function::FnOnce<(&rustc_session[56f0e8cf066e2273]::session::Session, rustc_middle[40d4d6b8740dcd09]::ty::context::CurrentGcx, alloc[2c6f44377e58b7f6]::sync::Arc<rustc_data_structures[bc54ba309468d12e]::jobserver::Proxy>, &std[f4bec5e5e6e4e88f]::sync::once_lock::OnceLock<rustc_middle[40d4d6b8740dcd09]::ty::context::GlobalCtxt>, &rustc_data_structures[bc54ba309468d12e]::sync::worker_local::WorkerLocal<rustc_middle[40d4d6b8740dcd09]::arena::Arena>, &rustc_data_structures[bc54ba309468d12e]::sync::worker_local::WorkerLocal<rustc_hir[166a0fac99a9c6ac]::Arena>, rustc_driver_impl[e8dcddc4bc4011ea]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  30:     0x7fc690f94b85 - rustc_interface[b866789434b6892c]::interface::run_compiler::<(), rustc_driver_impl[e8dcddc4bc4011ea]::run_compiler::{closure#0}>::{closure#1}
  31:     0x7fc690f0f3d4 - std[f4bec5e5e6e4e88f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[b866789434b6892c]::util::run_in_thread_with_globals<rustc_interface[b866789434b6892c]::util::run_in_thread_pool_with_globals<rustc_interface[b866789434b6892c]::interface::run_compiler<(), rustc_driver_impl[e8dcddc4bc4011ea]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x7fc690f0f0de - <<std[f4bec5e5e6e4e88f]::thread::Builder>::spawn_unchecked_<rustc_interface[b866789434b6892c]::util::run_in_thread_with_globals<rustc_interface[b866789434b6892c]::util::run_in_thread_pool_with_globals<rustc_interface[b866789434b6892c]::interface::run_compiler<(), rustc_driver_impl[e8dcddc4bc4011ea]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[4d4135e68af60dbb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7fc690f14eef - std::sys::thread::unix::Thread::new::thread_start::hd3beb5fb1158c10c
  34:     0x7fc68a8969cb - <unknown>
  35:     0x7fc68a91aa0c - <unknown>
  36:                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 (c871d09d1 2025-11-24) 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


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