Skip to content

[ICE]: mgca: fn foo() -> S<core::direct_const_arg!(_)> #159558

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(min_generic_const_args)]
struct S;
fn foo() -> S<core::direct_const_arg!(_)> {}

original:

#![feature(min_generic_const_args)]
struct S;
fn foo() -> S<core::direct_const_arg !(_)> {}

Version information

rustc 1.99.0-nightly (c904ba32e 2026-07-18)
binary: rustc
commit-hash: c904ba32e22c9d6fd31140b4283c5cc6c6b2fb5c
commit-date: 2026-07-18
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

Possibly related line of code:

{
let ct = match self.can_lower_expr_to_const_arg_direct(expr) {
Ok(()) => self.lower_expr_to_const_arg_direct(expr, None),
Err(e) => e.emit(self),
};
let ct = self.arena.alloc(ct);
return GenericArg::Const(ct.try_as_ambig_ct().unwrap());
}
_ => {}
}
GenericArg::Type(self.lower_ty_alloc(ty, itctx).try_as_ambig_ty().unwrap())
}
ast::GenericArg::Const(ct) => {

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.A0DeF7ChnTFp/rustc_testrunner_tmpdir_reporting.iV3nq3KAdZ36/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


thread 'rustc' (1238369) panicked at /rustc-dev/c904ba32e22c9d6fd31140b4283c5cc6c6b2fb5c/compiler/rustc_ast_lowering/src/lib.rs:1473:71:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7fe96782f826 - <<std[919e504754a1c63d]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[e67c28fc62871515]::fmt::Display>::fmt
   1:     0x7fe967e0ec88 - core[e67c28fc62871515]::fmt::write
   2:     0x7fe967844a8c - <std[919e504754a1c63d]::sys::stdio::unix::Stderr as core[e67c28fc62871515]::io::write::Write>::write_fmt
   3:     0x7fe9678014ba - std[919e504754a1c63d]::panicking::default_hook::{closure#0}
   4:     0x7fe967821f53 - std[919e504754a1c63d]::panicking::default_hook
   5:     0x7fe9667de86b - std[919e504754a1c63d]::panicking::update_hook::<alloc[780eb494d2eb9566]::boxed::Box<rustc_driver_impl[31e7de9ceb7c6422]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fe9678223f2 - std[919e504754a1c63d]::panicking::panic_with_hook
   7:     0x7fe9678015a4 - std[919e504754a1c63d]::panicking::panic_handler::{closure#0}
   8:     0x7fe9677f8a09 - std[919e504754a1c63d]::sys::backtrace::__rust_end_short_backtrace::<std[919e504754a1c63d]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fe967802ecd - __rustc[a0c1f58ab300e458]::rust_begin_unwind
  10:     0x7fe9645e010c - core[e67c28fc62871515]::panicking::panic_fmt
  11:     0x7fe964ba2342 - core[e67c28fc62871515]::panicking::panic
  12:     0x7fe9653d8e89 - core[e67c28fc62871515]::option::unwrap_failed
  13:     0x7fe9685941a8 - <rustc_ast_lowering[afe3dacaeb423852]::LoweringContext>::lower_qpath
  14:     0x7fe96858d8ad - <rustc_ast_lowering[afe3dacaeb423852]::LoweringContext>::lower_ty
  15:     0x7fe968982bbb - <rustc_ast_lowering[afe3dacaeb423852]::LoweringContext>::lower_fn_decl
  16:     0x7fe968581b7f - <rustc_ast_lowering[afe3dacaeb423852]::LoweringContext>::lower_item_kind
  17:     0x7fe9681b0636 - rustc_ast_lowering[afe3dacaeb423852]::lower_to_hir
  18:     0x7fe9681af2dd - rustc_query_impl[3f6b060824cc6068]::query_impl::lower_to_hir::invoke_provider_fn::__rust_begin_short_backtrace
  19:     0x7fe9681adf4a - rustc_query_impl[3f6b060824cc6068]::execution::try_execute_query::<rustc_data_structures[6943ebaa02d1f3a9]::vec_cache::VecCache<rustc_span[3197f56976480149]::def_id::LocalDefId, rustc_middle[173d04f2423416b5]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[173d04f2423416b5]::dep_graph::graph::DepNodeIndex>, false>
  20:     0x7fe9681adc85 - rustc_query_impl[3f6b060824cc6068]::query_impl::lower_to_hir::execute_query_non_incr::__rust_end_short_backtrace
  21:     0x7fe9681ad7b1 - rustc_query_impl[3f6b060824cc6068]::query_impl::hir_owner::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7fe9681acb52 - rustc_query_impl[3f6b060824cc6068]::execution::try_execute_query::<rustc_data_structures[6943ebaa02d1f3a9]::vec_cache::VecCache<rustc_span[3197f56976480149]::def_id::LocalDefId, rustc_middle[173d04f2423416b5]::query::erase::ErasedData<[u8; 32usize]>, rustc_middle[173d04f2423416b5]::dep_graph::graph::DepNodeIndex>, false>
  23:     0x7fe9681ac888 - rustc_query_impl[3f6b060824cc6068]::query_impl::hir_owner::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7fe968cb69ce - <rustc_middle[173d04f2423416b5]::hir::map::ItemCollector as rustc_hir[f2a35161d13b08d5]::intravisit::Visitor>::visit_nested_item
  25:     0x7fe968cb46e5 - rustc_middle[173d04f2423416b5]::hir::map::hir_crate_items
  26:     0x7fe968f3a261 - rustc_query_impl[3f6b060824cc6068]::query_impl::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
  27:     0x7fe968f3e41a - rustc_query_impl[3f6b060824cc6068]::execution::try_execute_query::<rustc_middle[173d04f2423416b5]::query::caches::SingleCache<rustc_middle[173d04f2423416b5]::query::erase::ErasedData<[u8; 8usize]>>, false>
  28:     0x7fe968f3ef4f - rustc_query_impl[3f6b060824cc6068]::query_impl::hir_crate_items::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7fe968437c18 - rustc_interface[204f2b53c2050133]::passes::analysis
  30:     0x7fe968f3dac7 - rustc_query_impl[3f6b060824cc6068]::execution::try_execute_query::<rustc_middle[173d04f2423416b5]::query::caches::SingleCache<rustc_middle[173d04f2423416b5]::query::erase::ErasedData<[u8; 0usize]>>, false>
  31:     0x7fe968f3d729 - rustc_query_impl[3f6b060824cc6068]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  32:     0x7fe968ef81cd - rustc_interface[204f2b53c2050133]::interface::run_compiler::<(), rustc_driver_impl[31e7de9ceb7c6422]::run_compiler::{closure#0}>::{closure#2}
  33:     0x7fe968f4b764 - std[919e504754a1c63d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[204f2b53c2050133]::util::run_in_thread_with_globals<rustc_interface[204f2b53c2050133]::util::run_in_thread_pool_with_globals<rustc_interface[204f2b53c2050133]::interface::run_compiler<(), rustc_driver_impl[31e7de9ceb7c6422]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  34:     0x7fe968f4b539 - <std[919e504754a1c63d]::thread::lifecycle::spawn_unchecked<rustc_interface[204f2b53c2050133]::util::run_in_thread_with_globals<rustc_interface[204f2b53c2050133]::util::run_in_thread_pool_with_globals<rustc_interface[204f2b53c2050133]::interface::run_compiler<(), rustc_driver_impl[31e7de9ceb7c6422]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e67c28fc62871515]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7fe968f55b3a - <std[919e504754a1c63d]::sys::thread::unix::Thread>::new::thread_start
  36:     0x7fe962897739 - <unknown>
  37:     0x7fe96291bedc - <unknown>
  38:                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.99.0-nightly (c904ba32e 2026-07-18) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [lower_to_hir] lowering HIR for `foo`
#1 [hir_owner] getting owner for `foo`
#2 [hir_crate_items] getting HIR crate items
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
warning: 1 warning emitted


@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) ❄️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

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions