Skip to content

ICE: assertion failed: !parent_args.is_empty() #138088

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(min_generic_const_args)]
trait Bar {
    fn x(&self) -> [i32; Bar::x];
}

original:

trait Bar {
    const X: usize;
    fn x(&self) -> [i32; Bar::x]; //~ ERROR: E0790
}

impl Foo for Baz {
    type Bar = i16;
    type Bar = u16; //~ ERROR duplicate definitions
} // This test is a regression test for #34792

fn main() {}

Version information

rustc 1.87.0-nightly (30f168ef8 2025-03-05)
binary: rustc
commit-hash: 30f168ef811aec63124eac677e14699baa9395bd
commit-date: 2025-03-05
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

debug!(?generics);
if generics.has_self {
if generics.parent.is_some() {
// The parent is a trait so it should have at least one
// generic parameter for the `Self` type.
assert!(!parent_args.is_empty())
} else {
// This item (presumably a trait) needs a self-type.
assert!(self_ty.is_some());
}
} else {
assert!(self_ty.is_none());

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(min_generic_const_args)

Program output

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:9
  |
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.vSr1Cvpnzcg2/rustc_testrunner_tmpdir_reporting.nZRwsnvVQBn4/mvce.rs:3:2
  |
3 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.vSr1Cvpnzcg2/rustc_testrunner_tmpdir_reporting.nZRwsnvVQBn4/mvce.rs`


thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:480:17:
assertion failed: !parent_args.is_empty()
stack backtrace:
   0:     0x7850d13dde24 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hf41f50ce448220db
   1:     0x7850d1c05aa2 - core::fmt::write::h2530ccbc5aed5a26
   2:     0x7850d2ed5651 - std::io::Write::write_fmt::h681bc12d66bdbd5b
   3:     0x7850d13ddc82 - std::sys::backtrace::BacktraceLock::print::h1d42fe6c4d6bf7a5
   4:     0x7850d13e0562 - std::panicking::default_hook::{{closure}}::h100cc14e5415da6d
   5:     0x7850d13e0154 - std::panicking::default_hook::hbbe023de1b3d14d2
   6:     0x7850d0532fc7 - std[2ce054583824a2db]::panicking::update_hook::<alloc[52a0444d492a86c3]::boxed::Box<rustc_driver_impl[c3b441e0b8b3ec1e]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7850d13e0dd3 - std::panicking::rust_panic_with_hook::hd76d2dd598e22f63
   8:     0x7850d13e0a96 - std::panicking::begin_panic_handler::{{closure}}::h132f3f4e3b433649
   9:     0x7850d13de2e9 - std::sys::backtrace::__rust_end_short_backtrace::h6fa5bf5a960629e7
  10:     0x7850d13e078d - rust_begin_unwind
  11:     0x7850ce05e920 - core::panicking::panic_fmt::h86998d6817cbe029
  12:     0x7850ceb6c46c - core::panicking::panic::h94bcdeb8f28a7398
  13:     0x7850d0707c87 - <dyn rustc_hir_analysis[dbcef965d73ee94d]::hir_ty_lowering::HirTyLowerer>::lower_generic_args_of_path_segment
  14:     0x7850d2386439 - <dyn rustc_hir_analysis[dbcef965d73ee94d]::hir_ty_lowering::HirTyLowerer>::lower_const_arg
  15:     0x7850d237723f - <dyn rustc_hir_analysis[dbcef965d73ee94d]::hir_ty_lowering::HirTyLowerer>::lower_ty
  16:     0x7850d238e215 - <dyn rustc_hir_analysis[dbcef965d73ee94d]::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
  17:     0x7850d238a6bd - rustc_hir_analysis[dbcef965d73ee94d]::collect::fn_sig
  18:     0x7850d1eee607 - rustc_query_impl[e00d6234639b5a1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e00d6234639b5a1a]::query_impl::fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 24usize]>>
  19:     0x7850d1eee5d5 - <rustc_query_impl[e00d6234639b5a1a]::query_impl::fn_sig::dynamic_query::{closure#2} as core[9e46b296f013918d]::ops::function::FnOnce<(rustc_middle[627fca435ebb918e]::ty::context::TyCtxt, rustc_span[eec47ca1352fb626]::def_id::DefId)>>::call_once
  20:     0x7850d1ef10ba - rustc_query_system[db5555c7757ded81]::query::plumbing::try_execute_query::<rustc_query_impl[e00d6234639b5a1a]::DynamicConfig<rustc_query_system[db5555c7757ded81]::query::caches::DefIdCache<rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[e00d6234639b5a1a]::plumbing::QueryCtxt, false>
  21:     0x7850d1ef07bd - rustc_query_impl[e00d6234639b5a1a]::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
  22:     0x7850d24a8625 - rustc_middle[627fca435ebb918e]::query::plumbing::query_get_at::<rustc_query_system[db5555c7757ded81]::query::caches::DefIdCache<rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 24usize]>>>
  23:     0x7850d23acf00 - rustc_hir_analysis[dbcef965d73ee94d]::check::check::check_item_type
  24:     0x7850d2399925 - rustc_hir_analysis[dbcef965d73ee94d]::check::wfcheck::check_well_formed
  25:     0x7850d2398011 - rustc_query_impl[e00d6234639b5a1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e00d6234639b5a1a]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 1usize]>>
  26:     0x7850d2397ac8 - rustc_query_system[db5555c7757ded81]::query::plumbing::try_execute_query::<rustc_query_impl[e00d6234639b5a1a]::DynamicConfig<rustc_data_structures[df3cf367e6d336df]::vec_cache::VecCache<rustc_span[eec47ca1352fb626]::def_id::LocalDefId, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[db5555c7757ded81]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[e00d6234639b5a1a]::plumbing::QueryCtxt, false>
  27:     0x7850d2397583 - rustc_query_impl[e00d6234639b5a1a]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7850d2394d9d - rustc_hir_analysis[dbcef965d73ee94d]::check::wfcheck::check_mod_type_wf
  29:     0x7850d2394b9f - rustc_query_impl[e00d6234639b5a1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e00d6234639b5a1a]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 1usize]>>
  30:     0x7850d2b99a56 - rustc_query_system[db5555c7757ded81]::query::plumbing::try_execute_query::<rustc_query_impl[e00d6234639b5a1a]::DynamicConfig<rustc_query_system[db5555c7757ded81]::query::caches::DefaultCache<rustc_span[eec47ca1352fb626]::def_id::LocalModDefId, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e00d6234639b5a1a]::plumbing::QueryCtxt, false>
  31:     0x7850d2b997ff - rustc_query_impl[e00d6234639b5a1a]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7850d1fa728f - rustc_hir_analysis[dbcef965d73ee94d]::check_crate
  33:     0x7850d208c2f2 - rustc_interface[f68678af3abb31c0]::passes::run_required_analyses
  34:     0x7850d2c0bffa - rustc_interface[f68678af3abb31c0]::passes::analysis
  35:     0x7850d2c0bfd9 - rustc_query_impl[e00d6234639b5a1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e00d6234639b5a1a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 0usize]>>
  36:     0x7850d2c5404b - rustc_query_system[db5555c7757ded81]::query::plumbing::try_execute_query::<rustc_query_impl[e00d6234639b5a1a]::DynamicConfig<rustc_query_system[db5555c7757ded81]::query::caches::SingleCache<rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e00d6234639b5a1a]::plumbing::QueryCtxt, false>
  37:     0x7850d2c53d39 - rustc_query_impl[e00d6234639b5a1a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7850d2c83e7d - rustc_interface[f68678af3abb31c0]::passes::create_and_enter_global_ctxt::<core[9e46b296f013918d]::option::Option<rustc_interface[f68678af3abb31c0]::queries::Linker>, rustc_driver_impl[c3b441e0b8b3ec1e]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  39:     0x7850d2cbb5cf - rustc_interface[f68678af3abb31c0]::interface::run_compiler::<(), rustc_driver_impl[c3b441e0b8b3ec1e]::run_compiler::{closure#0}>::{closure#1}
  40:     0x7850d2b5e648 - std[2ce054583824a2db]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f68678af3abb31c0]::util::run_in_thread_with_globals<rustc_interface[f68678af3abb31c0]::util::run_in_thread_pool_with_globals<rustc_interface[f68678af3abb31c0]::interface::run_compiler<(), rustc_driver_impl[c3b441e0b8b3ec1e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  41:     0x7850d2b5ef34 - <<std[2ce054583824a2db]::thread::Builder>::spawn_unchecked_<rustc_interface[f68678af3abb31c0]::util::run_in_thread_with_globals<rustc_interface[f68678af3abb31c0]::util::run_in_thread_pool_with_globals<rustc_interface[f68678af3abb31c0]::interface::run_compiler<(), rustc_driver_impl[c3b441e0b8b3ec1e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9e46b296f013918d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7850d2b60337 - std::sys::pal::unix::thread::Thread::new::thread_start::hed3936679d260bcc
  43:     0x7850ccca370a - <unknown>
  44:     0x7850ccd27aac - <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.87.0-nightly (30f168ef8 2025-03-05) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(min_generic_const_args) -Z dump-mir-dir=dir

query stack during panic:
#0 [fn_sig] computing function signature of `Bar::x`
#1 [check_well_formed] checking that `Bar` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [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