rust-lang / rust-lang/rust

[ICE]: `failed to resolve delegation to inherent impl`

Open
#162,774 2 comments 0 reactions 1 assignee View on GitHub

@paradoxicalguy is already working on this.

Since Sep 17, 2026.

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

Description

auto-reduced (treereduce-rust):

#![feature(fn_delegation)]

trait Trait {
    fn foo<'a: 'a>(&self) {}
}

struct F;
impl Trait for F {}

struct S(F);
impl S {
    reuse Trait::foo::<> { self.0 }

    reuse Self::foo::<'_> as bar { self.0 }
}

fn main() {}

original:

//@ check-pass
//@ compile-flags: -Z deduplicate-diagnostics=yes

#![feature(fn_delegation)]

trait Trait {
    fn foo<'a: 'a>(&self) {}
}

struct F;
impl Trait for F {}

struct S(F);
impl S {
    reuse Trait::foo::<> { self.0 }

    reuse Self::foo::<'_> as bar { self.0 }
}

fn main() {}

Version information

rustc 1.100.0-nightly (a8a1e6fd9 2026-09-14)
binary: rustc
commit-hash: a8a1e6fd9df2e094d6f09c0d57991508680acc1c
commit-date: 2026-09-14
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1

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

Program output

warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.FOTYhPGUBckV/rustc_testrunner_tmpdir_reporting.W5Ae5KwyzJd6/mvce.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: trait `Trait` is never used
 --> /tmp/icemaker_global_tempdir.FOTYhPGUBckV/rustc_testrunner_tmpdir_reporting.W5Ae5KwyzJd6/mvce.rs:3:7
  |
3 | trait Trait {
  |       ^^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: struct `F` is never constructed
 --> /tmp/icemaker_global_tempdir.FOTYhPGUBckV/rustc_testrunner_tmpdir_reporting.W5Ae5KwyzJd6/mvce.rs:7:8
  |
7 | struct F;
  |        ^

warning: struct `S` is never constructed
  --> /tmp/icemaker_global_tempdir.FOTYhPGUBckV/rustc_testrunner_tmpdir_reporting.W5Ae5KwyzJd6/mvce.rs:10:8
   |
10 | struct S(F);
   |        ^

warning: associated items `foo` and `bar` are never used
  --> /tmp/icemaker_global_tempdir.FOTYhPGUBckV/rustc_testrunner_tmpdir_reporting.W5Ae5KwyzJd6/mvce.rs:12:18
   |
11 | impl S {
   | ------ associated items in this implementation
12 |     reuse Trait::foo::<> { self.0 }
   |                  ^^^
13 |
14 |     reuse Self::foo::<'_> as bar { self.0 }
   |                              ^^^

warning: 5 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: failed to resolve delegation to inherent impl
  --> /tmp/icemaker_global_tempdir.FOTYhPGUBckV/rustc_testrunner_tmpdir_reporting.W5Ae5KwyzJd6/mvce.rs:14:17
   |
14 |     reuse Self::foo::<'_> as bar { self.0 }
   |                 ^^^
   |
note: delayed at /rustc-dev/a8a1e6fd9df2e094d6f09c0d57991508680acc1c/compiler/rustc_ast_lowering/src/delegation/resolution.rs:83:68
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_errors::diagnostic::Diag>::emit
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: rustc_ast_lowering::delegation::resolution::resolve_type_relative_delegations
         5: rustc_query_impl::query_vtables::resolve_type_relative_delegations::invoke_provider_fn::__rust_begin_short_backtrace
         6: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
         7: rustc_query_impl::query_vtables::resolve_type_relative_delegations::execute_query_non_incr::__rust_end_short_backtrace
         8: rustc_ast_lowering::lower_to_hir
         9: rustc_query_impl::query_vtables::lower_to_hir::invoke_provider_fn::__rust_begin_short_backtrace
        10: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 16]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
        11: rustc_query_impl::query_vtables::lower_to_hir::execute_query_non_incr::__rust_end_short_backtrace
        12: rustc_query_impl::query_vtables::hir_owner::invoke_provider_fn::__rust_begin_short_backtrace
        13: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 32]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
        14: rustc_query_impl::query_vtables::hir_owner::execute_query_non_incr::__rust_end_short_backtrace
        15: <rustc_middle::ty::context::TyCtxt>::expect_hir_owner_nodes
        16: rustc_middle::hir::map::hir_crate_items
        17: rustc_query_impl::query_vtables::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
        18: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
        19: rustc_query_impl::query_vtables::hir_crate_items::execute_query_non_incr::__rust_end_short_backtrace
        20: rustc_interface::passes::analysis
        21: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
        22: rustc_query_impl::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
        23: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}
        24: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        25: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        26: <std::sys::thread::unix::Thread>::new::thread_start
        27: <unknown>
        28: <unknown>
      
  --> /tmp/icemaker_global_tempdir.FOTYhPGUBckV/rustc_testrunner_tmpdir_reporting.W5Ae5KwyzJd6/mvce.rs:14:17
   |
14 |     reuse Self::foo::<'_> as bar { self.0 }
   |                 ^^^

error: internal compiler error: `Res::Err` but no error emitted
  --> /tmp/icemaker_global_tempdir.FOTYhPGUBckV/rustc_testrunner_tmpdir_reporting.W5Ae5KwyzJd6/mvce.rs:14:36
   |
14 |     reuse Self::foo::<'_> as bar { self.0 }
   |                                    ^^^^
   |
note: delayed at /rustc-dev/a8a1e6fd9df2e094d6f09c0d57991508680acc1c/compiler/rustc_hir_typeck/src/expr.rs:598:32
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_errors::diagnostic::Diag>::emit
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_path
         5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_field
         7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
         9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_call
        11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
        13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        14: rustc_hir_typeck::check::check_fn
        15: rustc_hir_typeck::typeck_with_inspect::{closure#0}
        16: rustc_query_impl::query_vtables::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
        17: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
        18: rustc_query_impl::query_vtables::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
        19: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}
        20: rustc_hir_analysis::check_crate
        21: rustc_interface::passes::analysis
        22: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
        23: rustc_query_impl::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
        24: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}
        25: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        26: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        27: <std::sys::thread::unix::Thread>::new::thread_start
        28: <unknown>
        29: <unknown>
      
  --> /tmp/icemaker_global_tempdir.FOTYhPGUBckV/rustc_testrunner_tmpdir_reporting.W5Ae5KwyzJd6/mvce.rs:14:36
   |
14 |     reuse Self::foo::<'_> as bar { self.0 }
   |                                    ^^^^

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 (a8a1e6fd9 2026-09-14) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

@rustbot label +F-fn_delegation

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.