Skip to content

[ICE]: delegation: TyKind::Error constructed but no error reported #154780

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(fn_delegation)]

mod test_8 {
    pub fn check<T: Clone, U: Clone>() {
        fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(f: impl FnOnce(T, U) -> U, _u: &'b U) {}

        reuse foo::<1, String, String> as bar;
    }
}

pub fn main() {}
original code

original:

//@ run-pass

#![feature(fn_delegation)]
#![allow(incomplete_features)]
#![allow(late_bound_lifetime_arguments)]

//! This is one of the mapping tests, which tests mapping of delegee parent and child
//! generic params, whose main goal is to create cases with
//! different number of lifetimes/types/consts in delegee child and parent; and in
//! delegation parent if applicable. At some tests predicates are
//! added. At some tests user-specified args are specified in reuse statement.

// Testing lifetimes + types + consts, reusing without
// user args, checking predicates inheritance
mod test_1 {
    fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {}

    pub fn check() {
        reuse foo as bar;
        bar::<i32, i32, 1>();
    }
}

// Testing lifetimes + types + consts, reusing without user args,
// providing delegation parent args in invocation
mod test_2 {
    fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {}

    pub fn check<T: Clone, U: Clone>() {
        reuse foo as bar;
        bar::<T, U, 1>();
    }
}

// Testing lifetimes + types + consts, reusing without user args,
// providing random types with delegation parent generics specified
mod test_3 {
    fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {}

    pub fn check<T: Clone, U: Clone>() {
        reuse foo as bar;
        bar::<u64, i32, 1>();
    }
}

// Testing late-bound lifetimes + types + consts, reusing without user args,
// providing random types with delegation parent generics specified,
// checking signature inheritance
mod test_4 {
    fn foo<'a, 'b, T: Clone, U: Clone, const N: usize>(_t: &'a T, _u: &'b U) {}

    pub fn check<T: Clone, U: Clone>() {
        reuse foo as bar;
        bar::<u64, i32, 1>(&1, &2);
    }
}

// Testing late-bound lifetimes + types + consts, reusing without user args,
// providing random types with delegation parent generics specified,
// checking signature inheritance, testing mixed order of types and consts
mod test_5 {
    fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {}

    pub fn check<T: Clone, U: Clone>() {
        reuse foo as bar;
        bar::<u64, 1, u32>(&1, &2);
    }
}

// Testing late-bound lifetimes + types + consts, reusing with user args,
// checking signature inheritance, testing mixed order of types and consts
mod test_6 {
    fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {}

    pub fn check<T: Clone, U: Clone>() {
        reuse foo::<String, 1, String> as bar;
        bar(&"".to_string(), &"".to_string());
    }
}

mod test_7 {
    fn foo<T, U>(t: T, u: U, f: impl FnOnce(T, U) -> U) -> U {
        f(t, u)
    }

    pub fn check() {
        reuse foo as bar;
        assert_eq!(bar::<i32, i32>(1, 2, |_, y| y), 2);
    }
}

// Testing reuse of local fn with delegation parent generic params specified,
// late-bound lifetimes + types + consts, reusing with user args,
// checking signature inheritance, mixed consts and types ordering
mod test_8 {
    pub fn check<T: Clone, U: Clone>() {
        fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(f: impl FnOnce(T, U) -> U, _u: &'b U) {}

        reuse foo::<1, String, String> as bar;
        bar(&"".to_string(), &"".to_string());
    }
}

// Testing reuse of local fn inside closure,
// late-bound lifetimes + types + consts, reusing with user args,
// checking signature inheritance, mixed consts and types ordering
mod test_9 {
    pub fn check<T: Clone, U: Clone>() {
        let closure = || {
            fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {}

            reuse foo::<String, 1, String> as bar;
            bar(&"".to_string(), &"".to_string());
        };

        closure();
    }
}

pub fn main() {
    test_1::check();
    test_2::check::<i32, String>();
    test_3::check::<i32, String>();
    test_4::check::<i32, String>();
    test_5::check::<i32, String>();
    test_6::check::<i32, String>();
    test_7::check();
    test_8::check::<i32, String>();
    test_9::check::<String, i32>();
}

Version information

rustc 1.96.0-nightly (2972b5e59 2026-04-03)
binary: rustc
commit-hash: 2972b5e59f1c5529b6ba770437812fd83ab4ebd4
commit-date: 2026-04-03
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2

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.CQQo8FmGBn8U/rustc_testrunner_tmpdir_reporting.fdG54mE5Bium/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: unused variable: `f`
 --> /tmp/icemaker_global_tempdir.CQQo8FmGBn8U/rustc_testrunner_tmpdir_reporting.fdG54mE5Bium/mvce.rs:5:60
  |
5 |         fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(f: impl FnOnce(T, U) -> U, _u: &'b U) {}
  |                                                            ^ help: if this is intentional, prefix it with an underscore: `_f`
  |
  = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: function `check` is never used
 --> /tmp/icemaker_global_tempdir.CQQo8FmGBn8U/rustc_testrunner_tmpdir_reporting.fdG54mE5Bium/mvce.rs:4:12
  |
4 |     pub fn check<T: Clone, U: Clone>() {
  |            ^^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: 3 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: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc-dev/2972b5e59f1c5529b6ba770437812fd83ab4ebd4/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:768:29
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
             2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
             3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
             4: <rustc_middle::ty::Ty>::new_misc_error
             5: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_generic_args_of_path::{closure#0}
             6: rustc_hir_analysis::delegation::get_delegation_user_specified_args
             7: rustc_hir_analysis::delegation::inherit_predicates_for_delegation_item
             8: rustc_hir_analysis::collect::predicates_of::gather_explicit_predicates_of
             9: rustc_query_impl::query_impl::explicit_predicates_of::invoke_provider_fn::__rust_begin_short_backtrace
            10: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefIdCache<rustc_middle::query::erase::ErasedData<[u8; 24]>>, false>
            11: rustc_query_impl::query_impl::explicit_predicates_of::execute_query_non_incr::__rust_end_short_backtrace
            12: rustc_query_impl::query_impl::predicates_of::invoke_provider_fn::__rust_begin_short_backtrace
            13: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefIdCache<rustc_middle::query::erase::ErasedData<[u8; 24]>>, false>
            14: rustc_query_impl::query_impl::predicates_of::execute_query_non_incr::__rust_end_short_backtrace
            15: rustc_hir_analysis::check::check::check_item_type
            16: rustc_hir_analysis::check::wfcheck::check_well_formed
            17: rustc_query_impl::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
            18: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 1]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
            19: rustc_query_impl::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
            20: rustc_hir_analysis::check::wfcheck::check_type_wf
            21: rustc_query_impl::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
            22: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 1]>>, false>
            23: rustc_query_impl::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
            24: rustc_hir_analysis::check_crate
            25: rustc_interface::passes::analysis
            26: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
            27: rustc_query_impl::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
            28: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            29: 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#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
            30: <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#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            31: <std::sys::thread::unix::Thread>::new::thread_start
            32: <unknown>
            33: <unknown>
          

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc-dev/2972b5e59f1c5529b6ba770437812fd83ab4ebd4/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:768:29
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
             2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
             3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
             4: <rustc_middle::ty::Ty>::new_misc_error
             5: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_generic_args_of_path::{closure#0}
             6: rustc_hir_analysis::delegation::get_delegation_user_specified_args
             7: rustc_hir_analysis::delegation::inherit_sig_for_delegation_item
             8: rustc_query_impl::query_impl::inherit_sig_for_delegation_item::invoke_provider_fn::__rust_begin_short_backtrace
             9: 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>
            10: rustc_query_impl::query_impl::inherit_sig_for_delegation_item::execute_query_non_incr::__rust_end_short_backtrace
            11: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
            12: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
            13: rustc_hir_analysis::collect::lower_fn_sig_recovering_infer_ret_ty
            14: rustc_hir_analysis::collect::fn_sig
            15: rustc_query_impl::query_impl::fn_sig::invoke_provider_fn::__rust_begin_short_backtrace
            16: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefIdCache<rustc_middle::query::erase::ErasedData<[u8; 24]>>, false>
            17: rustc_query_impl::query_impl::fn_sig::execute_query_non_incr::__rust_end_short_backtrace
            18: rustc_hir_analysis::check::check::check_item_type
            19: rustc_hir_analysis::check::wfcheck::check_well_formed
            20: rustc_query_impl::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
            21: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 1]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
            22: rustc_query_impl::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
            23: rustc_hir_analysis::check::wfcheck::check_type_wf
            24: rustc_query_impl::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
            25: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 1]>>, false>
            26: rustc_query_impl::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
            27: rustc_hir_analysis::check_crate
            28: rustc_interface::passes::analysis
            29: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
            30: rustc_query_impl::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
            31: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            32: 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#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
            33: <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#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            34: <std::sys::thread::unix::Thread>::new::thread_start
            35: <unknown>
            36: <unknown>
          

error: internal compiler error: failed to report fulfillment errors
  |
  = note: delayed at /rustc-dev/2972b5e59f1c5529b6ba770437812fd83ab4ebd4/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs:284:47
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
             2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
             3: <rustc_errors::DiagCtxtHandle>::delayed_bug::<&str>
             4: <rustc_trait_selection::error_reporting::TypeErrCtxt>::report_fulfillment_errors
             5: rustc_hir_analysis::check::wfcheck::check_item_fn
             6: rustc_hir_analysis::check::check::check_item_type
             7: rustc_hir_analysis::check::wfcheck::check_well_formed
             8: rustc_query_impl::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
             9: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 1]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
            10: rustc_query_impl::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
            11: rustc_hir_analysis::check::wfcheck::check_type_wf
            12: rustc_query_impl::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
            13: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 1]>>, false>
            14: rustc_query_impl::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
            15: rustc_hir_analysis::check_crate
            16: rustc_interface::passes::analysis
            17: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
            18: rustc_query_impl::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
            19: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            20: 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#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
            21: <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#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            22: <std::sys::thread::unix::Thread>::new::thread_start
            23: <unknown>
            24: <unknown>
          

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.96.0-nightly (2972b5e59 2026-04-03) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

@rustbot label +F-fn_delegation

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    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