Skip to content

[ICE]: unreachable with double definition inside direct_const_arg! #159127

Description

@matthiaskrgr

original:

#![feature(fn_delegation)]
#![feature(min_generic_const_args)]
impl
    core::direct_const_arg!({
        fn foo() {}
        reuse foo::<>as bar;
        reuse bar;
    })
{
}

Version information

rustc 1.99.0-nightly (ad49852b6 2026-07-11)
binary: rustc
commit-hash: ad49852b6f3dd9c1c73fe909d8843bb7e464b387
commit-date: 2026-07-11
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

Possibly related line of code:

),
// For trait impl's `sig_id` is always equal to the corresponding trait method.
// For inherent methods delegation is not yet supported.
(FnKind::AssocTraitImpl, _)
| (_, FnKind::AssocTraitImpl)
| (_, FnKind::AssocInherentImpl) => unreachable!(),
}
}
/// Creates generic arguments for further delegation signature and predicates instantiation.
/// Arguments can be user-specified (in this case they are in `parent_args` and `child_args`)
/// or propagated. User can specify either both `parent_args` and `child_args`, one of them or none,

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

Program output

error[E0428]: the name `bar` is defined multiple times
 --> code.rs:7:9
  |
6 |         reuse foo::<>as bar;
  |         -------------------- previous definition of the value `bar` here
7 |         reuse bar;
  |         ^^^^^^^^^^ `bar` redefined here
  |
  = note: `bar` must be defined only once in the value namespace of this block

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

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> code.rs:2:12
  |
2 | #![feature(min_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information

error: expected type, found `direct_const_arg!()` constant
 --> code.rs:4:5
  |
4 | /     core::direct_const_arg!({
5 | |         fn foo() {}
6 | |         reuse foo::<>as bar;
7 | |         reuse bar;
8 | |     })
  | |______^


thread 'rustc' (3079820) panicked at /rustc-dev/ad49852b6f3dd9c1c73fe909d8843bb7e464b387/compiler/rustc_hir_analysis/src/delegation.rs:316:45:
internal error: entered unreachable code
stack backtrace:
   0:     0x7f9e3dffbc46 - <<std[de3b7ecb4a396195]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a5634a7968bc49f0]::fmt::Display>::fmt
   1:     0x7f9e3e610f48 - core[a5634a7968bc49f0]::fmt::write
   2:     0x7f9e3e0110bc - <std[de3b7ecb4a396195]::sys::stdio::unix::Stderr as core[a5634a7968bc49f0]::io::write::Write>::write_fmt
   3:     0x7f9e3dfcffca - std[de3b7ecb4a396195]::panicking::default_hook::{closure#0}
   4:     0x7f9e3dfee363 - std[de3b7ecb4a396195]::panicking::default_hook
   5:     0x7f9e3cfc67ab - std[de3b7ecb4a396195]::panicking::update_hook::<alloc[de1f657d51345da4]::boxed::Box<rustc_driver_impl[4ef98c1faf29e502]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f9e3dfee802 - std[de3b7ecb4a396195]::panicking::panic_with_hook
   7:     0x7f9e3dfd00b4 - std[de3b7ecb4a396195]::panicking::panic_handler::{closure#0}
   8:     0x7f9e3dfc6d49 - std[de3b7ecb4a396195]::sys::backtrace::__rust_end_short_backtrace::<std[de3b7ecb4a396195]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f9e3dfd19dd - __rustc[80c2305df47a8488]::rust_begin_unwind
  10:     0x7f9e3ae48cfc - core[a5634a7968bc49f0]::panicking::panic_fmt
  11:     0x7f9e3b4e8502 - core[a5634a7968bc49f0]::panicking::panic
  12:     0x7f9e3d16422e - rustc_hir_analysis[6392d7eaa5751367]::delegation::get_delegation_self_ty
  13:     0x7f9e3d163125 - rustc_hir_analysis[6392d7eaa5751367]::delegation::create_folder_and_args
  14:     0x7f9e3d16577f - rustc_hir_analysis[6392d7eaa5751367]::delegation::inherit_sig_for_delegation_item
  15:     0x7f9e3da78392 - rustc_query_impl[f8a48d6a867b8694]::query_impl::inherit_sig_for_delegation_item::invoke_provider_fn::__rust_begin_short_backtrace
  16:     0x7f9e3ea57a01 - rustc_query_impl[f8a48d6a867b8694]::execution::try_execute_query::<rustc_data_structures[84f0c090dd236aae]::vec_cache::VecCache<rustc_span[1cf83d6190130360]::def_id::LocalDefId, rustc_middle[f1a16747f86fcc9d]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[f1a16747f86fcc9d]::dep_graph::graph::DepNodeIndex>, false>
  17:     0x7f9e3da783fa - rustc_query_impl[f8a48d6a867b8694]::query_impl::inherit_sig_for_delegation_item::execute_query_non_incr::__rust_end_short_backtrace
  18:     0x7f9e3eb39767 - <dyn rustc_hir_analysis[6392d7eaa5751367]::hir_ty_lowering::HirTyLowerer>::lower_ty
  19:     0x7f9e3eb27330 - <dyn rustc_hir_analysis[6392d7eaa5751367]::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
  20:     0x7f9e3eb26ac3 - rustc_hir_analysis[6392d7eaa5751367]::collect::lower_fn_sig_recovering_infer_ret_ty
  21:     0x7f9e3e84dad9 - rustc_hir_analysis[6392d7eaa5751367]::collect::fn_sig
  22:     0x7f9e3e84d32b - rustc_query_impl[f8a48d6a867b8694]::query_impl::fn_sig::invoke_provider_fn::__rust_begin_short_backtrace
  23:     0x7f9e3e84fb8e - rustc_query_impl[f8a48d6a867b8694]::execution::try_execute_query::<rustc_middle[f1a16747f86fcc9d]::query::caches::DefIdCache<rustc_middle[f1a16747f86fcc9d]::query::erase::ErasedData<[u8; 24usize]>>, false>
  24:     0x7f9e3e84f2d3 - rustc_query_impl[f8a48d6a867b8694]::query_impl::fn_sig::execute_query_non_incr::__rust_end_short_backtrace
  25:     0x7f9e3cb37222 - <rustc_ast_lowering[20be3873bb80d941]::delegation::resolution::resolver::DelegationResolver>::resolve_delegation
  26:     0x7f9e3cb2febb - <rustc_ast_lowering[20be3873bb80d941]::LoweringContext>::lower_delegation
  27:     0x7f9e3ee82f72 - <rustc_ast_lowering[20be3873bb80d941]::LoweringContext>::lower_item_kind
  28:     0x7f9e3ea59db6 - rustc_ast_lowering[20be3873bb80d941]::lower_to_hir
  29:     0x7f9e3ea58a5d - rustc_query_impl[f8a48d6a867b8694]::query_impl::lower_to_hir::invoke_provider_fn::__rust_begin_short_backtrace
  30:     0x7f9e3ea576ca - rustc_query_impl[f8a48d6a867b8694]::execution::try_execute_query::<rustc_data_structures[84f0c090dd236aae]::vec_cache::VecCache<rustc_span[1cf83d6190130360]::def_id::LocalDefId, rustc_middle[f1a16747f86fcc9d]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[f1a16747f86fcc9d]::dep_graph::graph::DepNodeIndex>, false>
  31:     0x7f9e3ea57405 - rustc_query_impl[f8a48d6a867b8694]::query_impl::lower_to_hir::execute_query_non_incr::__rust_end_short_backtrace
  32:     0x7f9e3ea56f31 - rustc_query_impl[f8a48d6a867b8694]::query_impl::hir_owner::invoke_provider_fn::__rust_begin_short_backtrace
  33:     0x7f9e3ea562d2 - rustc_query_impl[f8a48d6a867b8694]::execution::try_execute_query::<rustc_data_structures[84f0c090dd236aae]::vec_cache::VecCache<rustc_span[1cf83d6190130360]::def_id::LocalDefId, rustc_middle[f1a16747f86fcc9d]::query::erase::ErasedData<[u8; 32usize]>, rustc_middle[f1a16747f86fcc9d]::dep_graph::graph::DepNodeIndex>, false>
  34:     0x7f9e3ea56008 - rustc_query_impl[f8a48d6a867b8694]::query_impl::hir_owner::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x7f9e3b21d511 - <rustc_middle[f1a16747f86fcc9d]::ty::context::TyCtxt>::hir_opt_delegation_info
  36:     0x7f9e3f7ea53d - rustc_passes[83433282f3d9f406]::delegation::check_glob_and_list_delegations_target_expr
  37:     0x7f9e3f065501 - rustc_interface[45196e524e7bee1]::passes::analysis
  38:     0x7f9e3f7ebb07 - rustc_query_impl[f8a48d6a867b8694]::execution::try_execute_query::<rustc_middle[f1a16747f86fcc9d]::query::caches::SingleCache<rustc_middle[f1a16747f86fcc9d]::query::erase::ErasedData<[u8; 0usize]>>, false>
  39:     0x7f9e3f7eb7e9 - rustc_query_impl[f8a48d6a867b8694]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  40:     0x7f9e3f783282 - rustc_interface[45196e524e7bee1]::interface::run_compiler::<(), rustc_driver_impl[4ef98c1faf29e502]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7f9e3f8744fa - std[de3b7ecb4a396195]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[45196e524e7bee1]::util::run_in_thread_with_globals<rustc_interface[45196e524e7bee1]::util::run_in_thread_pool_with_globals<rustc_interface[45196e524e7bee1]::interface::run_compiler<(), rustc_driver_impl[4ef98c1faf29e502]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7f9e3f8742ad - <std[de3b7ecb4a396195]::thread::lifecycle::spawn_unchecked<rustc_interface[45196e524e7bee1]::util::run_in_thread_with_globals<rustc_interface[45196e524e7bee1]::util::run_in_thread_pool_with_globals<rustc_interface[45196e524e7bee1]::interface::run_compiler<(), rustc_driver_impl[4ef98c1faf29e502]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a5634a7968bc49f0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f9e3f872210 - <std[de3b7ecb4a396195]::sys::thread::unix::Thread>::new::thread_start
  44:     0x7f9e390981b9 - <unknown>
  45:     0x7f9e3911d21c - <unknown>
  46:                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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-07-11T09_01_12-3079818.txt` to your bug report

note: rustc 1.99.0-nightly (ad49852b6 2026-07-11) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [inherit_sig_for_delegation_item] inheriting delegation signature
#1 [fn_sig] computing function signature of `<impl at code.rs:3:1: 8:7>::bar`
#2 [lower_to_hir] lowering HIR for `<impl at code.rs:3:1: 8:7>::bar`
#3 [hir_owner] getting owner for `<impl at code.rs:3:1: 8:7>::bar`
#4 [analysis] running analysis passes on crate `code`
end of query stack
error: aborting due to 2 previous errors; 2 warnings emitted

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

@rustbot label +F-fn_delegation +F-min_generic_const_args

Metadata

Metadata

Labels

C-bugCategory: This is a bug.F-fn_delegation`#![feature(fn_delegation)]`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