rust-lang / rust-lang/rust

[ICE]: `parent of inherent function can be only struct or enum`

Open
#162,682 1 comment 0 reactions 1 assignee View on GitHub

@TaKO8Ki is already working on this.

Since Sep 12, 2026.

C-bug F-fn_delegation I-ICE needs-triage T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

trait S<'a, A, B, const C: usize> {
    xd,
}

impl<'a, 'b, 'c, A, > S<'static, A, usize, C> {
    fn foo_self<'d: 'd, 'e, T, >(self) {}
}

trait Trait<'a, AA, BB>  {
    reuse S::foo_self;
}



original:

trait S<'a, A, B, const C: usize> {
    xd: &'a [(A, B); C],
}

impl<'a, 'b, 'c, A, const C: usize> S<'static, A, usize, C> {
    fn foo_self<'d: 'd, 'e, T, const B: bool>(self) {}
}

trait Trait<'a, AA, BB> where Self: Sized {
    reuse S::foo_self;
}

fn main() {}

Version information

rustc 1.100.0-nightly (74b3f086e 2026-09-12)
binary: rustc
commit-hash: 74b3f086e27d20f04611a52addc3781576f3c749
commit-date: 2026-09-12
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1

Possibly related line of code:
https://github.com/rust-lang/rust/blob/74b3f086e27d20f04611a52addc3781576f3c749/compiler/rustc_ast_lowering/src/delegation/generics.rs#L473-L485

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

Program output

error: expected one of `!` or `::`, found `,`
 --> /tmp/icemaker_global_tempdir.Mi6OgfQ8uGBx/rustc_testrunner_tmpdir_reporting.3eUSBT4o5oI4/mvce.rs:2:7
  |
1 | trait S<'a, A, B, const C: usize> {
  |                                   - while parsing this item list starting here
2 |     xd,
  |       ^ expected one of `!` or `::`
3 | }
  | - the item list ends here

error[E0425]: cannot find type `C` in this scope
 --> /tmp/icemaker_global_tempdir.Mi6OgfQ8uGBx/rustc_testrunner_tmpdir_reporting.3eUSBT4o5oI4/mvce.rs:5:44
  |
5 | impl<'a, 'b, 'c, A, > S<'static, A, usize, C> {
  |                                            ^ not found in this scope
  |
note: similarly named type parameter `A` defined here
 --> /tmp/icemaker_global_tempdir.Mi6OgfQ8uGBx/rustc_testrunner_tmpdir_reporting.3eUSBT4o5oI4/mvce.rs:5:18
  |
5 | impl<'a, 'b, 'c, A, > S<'static, A, usize, C> {
  |                  ^
help: a type parameter with a similar name exists
  |
5 - impl<'a, 'b, 'c, A, > S<'static, A, usize, C> {
5 + impl<'a, 'b, 'c, A, > S<'static, A, usize, A> {
  |
help: you might be missing a type parameter
  |
5 | impl<'a, 'b, 'c, A, C, > S<'static, A, usize, C> {
  |                   +++

error[E0658]: functions delegation is not yet fully implemented
  --> /tmp/icemaker_global_tempdir.Mi6OgfQ8uGBx/rustc_testrunner_tmpdir_reporting.3eUSBT4o5oI4/mvce.rs:10:5
   |
10 |     reuse S::foo_self;
   |     ^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
   = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
   = note: this compiler was built on 2026-09-12; consider upgrading it if it is out of date

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.Mi6OgfQ8uGBx/rustc_testrunner_tmpdir_reporting.3eUSBT4o5oI4/mvce.rs:5:23
  |
5 | impl<'a, 'b, 'c, A, > S<'static, A, usize, C> {
  |                       ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default
help: if this is a dyn-compatible trait, use `dyn`
  |
5 | impl<'a, 'b, 'c, A, > dyn S<'static, A, usize, C> {
  |                       +++
help: you might have intended to implement this trait for a given type
  |
5 | impl<'a, 'b, 'c, A, > S<'static, A, usize, C> for /* Type */ {
  |                                               ++++++++++++++

error[E0747]: unresolved item provided when a constant was expected
 --> /tmp/icemaker_global_tempdir.Mi6OgfQ8uGBx/rustc_testrunner_tmpdir_reporting.3eUSBT4o5oI4/mvce.rs:5:44
  |
5 | impl<'a, 'b, 'c, A, > S<'static, A, usize, C> {
  |                                            ^
  |
help: if this generic argument was intended as a const parameter, surround it with braces
  |
5 | impl<'a, 'b, 'c, A, > S<'static, A, usize, { C }> {
  |                                            +   +


thread 'rustc' (828386) panicked at /rustc-dev/74b3f086e27d20f04611a52addc3781576f3c749/compiler/rustc_ast_lowering/src/delegation/generics.rs:479:13:
internal error: entered unreachable code: parent of inherent function can be only struct or enum
stack backtrace:
   0:     0x7f19cbe3d6f6 - <<std[3528600ba3f9fe66]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[9253e626ef1be868]::fmt::Display>::fmt
   1:     0x7f19cc40988f - core[9253e626ef1be868]::fmt::write
   2:     0x7f19cbe526bc - <std[3528600ba3f9fe66]::sys::stdio::unix::Stderr as core[9253e626ef1be868]::io::write::Write>::write_fmt
   3:     0x7f19cbe103da - std[3528600ba3f9fe66]::panicking::default_hook::{closure#0}
   4:     0x7f19cbe31e53 - std[3528600ba3f9fe66]::panicking::default_hook
   5:     0x7f19cab6269f - std[3528600ba3f9fe66]::panicking::update_hook::<alloc[19f73542e5485bc1]::boxed::Box<rustc_driver_impl[4014d772c3bdc445]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f19cbe322f2 - std[3528600ba3f9fe66]::panicking::panic_with_hook
   7:     0x7f19cbe104c4 - std[3528600ba3f9fe66]::panicking::panic_handler::{closure#0}
   8:     0x7f19cbe08049 - std[3528600ba3f9fe66]::sys::backtrace::__rust_end_short_backtrace::<std[3528600ba3f9fe66]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f19cbe1206d - __rustc[ba2e5ec835e7ab14]::rust_begin_unwind
  10:     0x7f19c882668c - core[9253e626ef1be868]::panicking::panic_fmt
  11:     0x7f19ca6040ce - <rustc_ast_lowering[92becfe79b4a3827]::delegation::resolution::resolver::DelegationResolver>::resolve_and_generate_generics
  12:     0x7f19ca5f6887 - <rustc_ast_lowering[92becfe79b4a3827]::LoweringContext>::lower_delegation
  13:     0x7f19ccab13bd - rustc_ast_lowering[92becfe79b4a3827]::lower_to_hir
  14:     0x7f19ccaa731d - rustc_query_impl[d5422e89ac02de23]::query_vtables::lower_to_hir::invoke_provider_fn::__rust_begin_short_backtrace
  15:     0x7f19ccaa5ce1 - rustc_query_impl[d5422e89ac02de23]::execution::try_execute_query::<rustc_data_structures[1609676847358c32]::vec_cache::VecCache<rustc_span[2d93c3ee6901fd4d]::def_id::LocalDefId, rustc_middle[5a5f5798a8f38072]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[5a5f5798a8f38072]::dep_graph::graph::DepNodeIndex>, false>
  16:     0x7f19ccaa5a22 - rustc_query_impl[d5422e89ac02de23]::query_vtables::lower_to_hir::execute_query_non_incr::__rust_end_short_backtrace
  17:     0x7f19ccaa54c2 - rustc_query_impl[d5422e89ac02de23]::query_vtables::hir_owner::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7f19ccaa4921 - rustc_query_impl[d5422e89ac02de23]::execution::try_execute_query::<rustc_data_structures[1609676847358c32]::vec_cache::VecCache<rustc_span[2d93c3ee6901fd4d]::def_id::LocalDefId, rustc_middle[5a5f5798a8f38072]::query::erase::ErasedData<[u8; 32usize]>, rustc_middle[5a5f5798a8f38072]::dep_graph::graph::DepNodeIndex>, false>
  19:     0x7f19ccaa4662 - rustc_query_impl[d5422e89ac02de23]::query_vtables::hir_owner::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7f19cce527da - <rustc_middle[5a5f5798a8f38072]::ty::context::TyCtxt>::expect_hir_owner_nodes
  21:     0x7f19cd5961d9 - <rustc_middle[5a5f5798a8f38072]::hir::map::ItemCollector as rustc_hir[139f080f3b0c281f]::intravisit::Visitor>::visit_nested_item
  22:     0x7f19cd593da4 - rustc_middle[5a5f5798a8f38072]::hir::map::hir_crate_items
  23:     0x7f19cd592d61 - rustc_query_impl[d5422e89ac02de23]::query_vtables::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7f19cd47525a - rustc_query_impl[d5422e89ac02de23]::execution::try_execute_query::<rustc_middle[5a5f5798a8f38072]::query::caches::SingleCache<rustc_middle[5a5f5798a8f38072]::query::erase::ErasedData<[u8; 8usize]>>, false>
  25:     0x7f19cd474f24 - rustc_query_impl[d5422e89ac02de23]::query_vtables::hir_crate_items::execute_query_non_incr::__rust_end_short_backtrace
  26:     0x7f19ccacf11a - rustc_interface[a9b0b26ac5f97aef]::passes::analysis
  27:     0x7f19cd475dca - rustc_query_impl[d5422e89ac02de23]::execution::try_execute_query::<rustc_middle[5a5f5798a8f38072]::query::caches::SingleCache<rustc_middle[5a5f5798a8f38072]::query::erase::ErasedData<[u8; 0usize]>>, false>
  28:     0x7f19cd475b6b - rustc_query_impl[d5422e89ac02de23]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7f19cd6e7fad - rustc_interface[a9b0b26ac5f97aef]::interface::run_compiler::<(), rustc_driver_impl[4014d772c3bdc445]::run_compiler::{closure#0}>::{closure#2}
  30:     0x7f19cd7ae664 - std[3528600ba3f9fe66]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a9b0b26ac5f97aef]::util::run_in_thread_with_globals<rustc_interface[a9b0b26ac5f97aef]::util::run_in_thread_pool_with_globals<rustc_interface[a9b0b26ac5f97aef]::interface::run_compiler<(), rustc_driver_impl[4014d772c3bdc445]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  31:     0x7f19cd7ae40b - <std[3528600ba3f9fe66]::thread::lifecycle::spawn_unchecked<rustc_interface[a9b0b26ac5f97aef]::util::run_in_thread_with_globals<rustc_interface[a9b0b26ac5f97aef]::util::run_in_thread_pool_with_globals<rustc_interface[a9b0b26ac5f97aef]::interface::run_compiler<(), rustc_driver_impl[4014d772c3bdc445]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9253e626ef1be868]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f19cd7b77db - <std[3528600ba3f9fe66]::sys::thread::unix::Thread>::new::thread_start
  33:     0x7f19c66980a2 - <unknown>
  34:     0x7f19c672080c - <unknown>
  35:                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.100.0-nightly (74b3f086e 2026-09-12) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [lower_to_hir] lowering HIR for `Trait::foo_self`
#1 [hir_owner] getting owner for `Trait::foo_self`
#2 [hir_crate_items] getting HIR crate items
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0425, E0658, E0747.
For more information about an error, try `rustc --explain E0425`.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.