Skip to content

mgca: index out of bounds #137084

Open
Open
@matthiaskrgr

Description

@matthiaskrgr

snippet:

#![feature(min_generic_const_args)]
fn a<const b: i32>() {}
fn d(e: &String) {
    a::<d>
}

Version information

rustc 1.86.0-nightly (69fd5e405 2025-02-15)
binary: rustc
commit-hash: 69fd5e4059f8840f09f60269bcda23dcdcb77151
commit-date: 2025-02-15
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Possibly related line of code:

}
if let Some(span_late) = def.has_late_bound_regions {
let msg = "cannot specify lifetime arguments explicitly \
if late bound lifetime parameters are present";
let note = "the late bound lifetime parameter is introduced here";
let span = args.args[0].span();
if position == GenericArgPosition::Value
&& args.num_lifetime_params() != param_counts.lifetimes
{
struct_span_code_err!(cx.dcx(), span, E0794, "{}", msg)
.with_span_note(span_late, note)

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

Program output

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.YW1oVwrZuaFw/rustc_testrunner_tmpdir_reporting.ZWaERXhXQkjK/mvce.rs:1:12
  |
1 | #![feature(min_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.YW1oVwrZuaFw/rustc_testrunner_tmpdir_reporting.ZWaERXhXQkjK/mvce.rs:5:2
  |
5 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.YW1oVwrZuaFw/rustc_testrunner_tmpdir_reporting.ZWaERXhXQkjK/mvce.rs`


thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs:643:20:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x76d7191db980 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hb724eabc0ad78635
   1:     0x76d719a28a3c - core::fmt::write::h2ba87c04d7395c9c
   2:     0x76d71acf4ed1 - std::io::Write::write_fmt::hfa6a9da60d569ca6
   3:     0x76d7191db7e2 - std::sys::backtrace::BacktraceLock::print::h4ab0db3d989d552e
   4:     0x76d7191ddc62 - std::panicking::default_hook::{{closure}}::h3f0eed1f3665de82
   5:     0x76d7191ddaea - std::panicking::default_hook::h179f8301c7da8cf4
   6:     0x76d71833d989 - std[b8741c4e06d6af8f]::panicking::update_hook::<alloc[5bb95d137f7b141e]::boxed::Box<rustc_driver_impl[bc34f49570369c15]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x76d7191de7e3 - std::panicking::rust_panic_with_hook::h86cd07aec2e613c5
   8:     0x76d7191de4da - std::panicking::begin_panic_handler::{{closure}}::he2e747a6c54051c6
   9:     0x76d7191dbe59 - std::sys::backtrace::__rust_end_short_backtrace::h0141671d10fc3772
  10:     0x76d7191de19d - rust_begin_unwind
  11:     0x76d715e3d8e0 - core::panicking::panic_fmt::h5eb235fb4ae88e73
  12:     0x76d717a04eb9 - core::panicking::panic_bounds_check::h63f9f738529401d8
  13:     0x76d71852c16d - rustc_hir_analysis[59042490e38607df]::hir_ty_lowering::generics::check_generic_arg_count
  14:     0x76d7185179c6 - <dyn rustc_hir_analysis[59042490e38607df]::hir_ty_lowering::HirTyLowerer>::lower_generic_args_of_path_segment
  15:     0x76d71b31a591 - <dyn rustc_hir_analysis[59042490e38607df]::hir_ty_lowering::HirTyLowerer>::lower_const_arg.cold
  16:     0x76d71a3623a1 - <<rustc_hir_typeck[65fba9be917441b7]::fn_ctxt::FnCtxt>::instantiate_value_path::CtorGenericArgsCtxt as rustc_hir_analysis[59042490e38607df]::hir_ty_lowering::GenericArgsLowerer>::provided_kind
  17:     0x76d719f707b3 - <rustc_hir_typeck[65fba9be917441b7]::fn_ctxt::FnCtxt>::instantiate_value_path
  18:     0x76d719f679ad - <rustc_hir_typeck[65fba9be917441b7]::fn_ctxt::FnCtxt>::check_expr_path
  19:     0x76d71a6526a6 - <rustc_hir_typeck[65fba9be917441b7]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:     0x76d71a64d557 - <rustc_hir_typeck[65fba9be917441b7]::fn_ctxt::FnCtxt>::check_expr_block
  21:     0x76d71a6550e7 - <rustc_hir_typeck[65fba9be917441b7]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:     0x76d719f34a9d - rustc_hir_typeck[65fba9be917441b7]::check::check_fn
  23:     0x76d719f3d27d - rustc_hir_typeck[65fba9be917441b7]::typeck_with_inspect::{closure#0}
  24:     0x76d719f3b28c - rustc_query_impl[e5659b33053300]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e5659b33053300]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f0d5fddc3318c322]::query::erase::Erased<[u8; 8usize]>>
  25:     0x76d719e2d057 - rustc_query_system[d0cce9770b6d6e67]::query::plumbing::try_execute_query::<rustc_query_impl[e5659b33053300]::DynamicConfig<rustc_data_structures[e5f998b15358e4fa]::vec_cache::VecCache<rustc_span[bb9bdc9d21462a2e]::def_id::LocalDefId, rustc_middle[f0d5fddc3318c322]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[d0cce9770b6d6e67]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[e5659b33053300]::plumbing::QueryCtxt, false>
  26:     0x76d719e2c09f - rustc_query_impl[e5659b33053300]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  27:     0x76d719e2bd59 - <rustc_middle[f0d5fddc3318c322]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[59042490e38607df]::check_crate::{closure#3}>::{closure#0}
  28:     0x76d719e2b3c9 - rustc_hir_analysis[59042490e38607df]::check_crate
  29:     0x76d719e25f2b - rustc_interface[1e9e5fafa3130242]::passes::run_required_analyses
  30:     0x76d71a4abf5e - rustc_interface[1e9e5fafa3130242]::passes::analysis
  31:     0x76d71a4abf2f - rustc_query_impl[e5659b33053300]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e5659b33053300]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f0d5fddc3318c322]::query::erase::Erased<[u8; 0usize]>>
  32:     0x76d71a9796d5 - rustc_query_system[d0cce9770b6d6e67]::query::plumbing::try_execute_query::<rustc_query_impl[e5659b33053300]::DynamicConfig<rustc_query_system[d0cce9770b6d6e67]::query::caches::SingleCache<rustc_middle[f0d5fddc3318c322]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e5659b33053300]::plumbing::QueryCtxt, false>
  33:     0x76d71a97940e - rustc_query_impl[e5659b33053300]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x76d71a8c26a9 - rustc_interface[1e9e5fafa3130242]::passes::create_and_enter_global_ctxt::<core[aa6201c117299edb]::option::Option<rustc_interface[1e9e5fafa3130242]::queries::Linker>, rustc_driver_impl[bc34f49570369c15]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  35:     0x76d71a939266 - rustc_interface[1e9e5fafa3130242]::interface::run_compiler::<(), rustc_driver_impl[bc34f49570369c15]::run_compiler::{closure#0}>::{closure#1}
  36:     0x76d71a879744 - std[b8741c4e06d6af8f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1e9e5fafa3130242]::util::run_in_thread_with_globals<rustc_interface[1e9e5fafa3130242]::util::run_in_thread_pool_with_globals<rustc_interface[1e9e5fafa3130242]::interface::run_compiler<(), rustc_driver_impl[bc34f49570369c15]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x76d71a879419 - <<std[b8741c4e06d6af8f]::thread::Builder>::spawn_unchecked_<rustc_interface[1e9e5fafa3130242]::util::run_in_thread_with_globals<rustc_interface[1e9e5fafa3130242]::util::run_in_thread_pool_with_globals<rustc_interface[1e9e5fafa3130242]::interface::run_compiler<(), rustc_driver_impl[bc34f49570369c15]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[aa6201c117299edb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x76d71a878bab - std::sys::pal::unix::thread::Thread::new::thread_start::h8fb7ff7d63dbc0f6
  39:     0x76d714aa339d - <unknown>
  40:     0x76d714b2849c - <unknown>
  41:                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.86.0-nightly (69fd5e405 2025-02-15) running on x86_64-unknown-linux-gnu

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

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

@rustbot label +F-min_generic_const_args

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-min_generic_const_args`#![feature(min_generic_const_args)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.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