-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
Code
trait FnPtr {
type Args<'a>;
}
impl FnPtr for fn() {
type Args<'a> = ();
}
trait FnThunk<B> {}
impl<B> FnThunk<B> for () {}
trait PackedFn<'a, B>: Fn(B::Args<'a>)
where
B: FnPtr,
{
}
impl<'a, B, F> PackedFn<'a, B> for F
where
B: FnPtr,
F: Fn(B::Args<'a>),
{
}
fn make<B, F>(_: F) -> impl FnThunk<B>
where
B: FnPtr,
F: for<'x> PackedFn<'x, B>,
{
}
fn f<F, C, H>(_: C)
where
C: FnOnce(F) -> H,
F: FnPtr,
H: FnThunk<F>,
{
}
pub fn main() {
f::<fn(), _, _>(|_| make(|()| ()))
}Meta
rustc --version --verbose:
rustc 1.91.1 (ed61e7d7e 2025-11-07)
binary: rustc
commit-hash: ed61e7d7e242494fb7057f2657300d9e77bb4fcb
commit-date: 2025-11-07
host: x86_64-pc-windows-msvc
release: 1.91.1
LLVM version: 21.1.2
Also present on nightly rustc 1.93.0-nightly (29a69716f 2025-11-10).
Error output
error: internal compiler error: failure to relate an opaque to itself should result in an error later on
--> src/main.rs:42:21
|
42 | f::<fn(), _, _>(|_| make(|()| ()))
| ^^^^^^^^^^^^^^^^^
|
note: delayed at compiler/rustc_borrowck/src/type_check/relate_tys.rs:359:37 - disabled backtrace
--> src/main.rs:42:21
|
42 | f::<fn(), _, _>(|_| make(|()| ()))
| ^^^^^^^^^^^^^^^^^
error: internal compiler error: failure to relate an opaque to itself should result in an error later on
--> src/main.rs:42:24
|
42 | f::<fn(), _, _>(|_| make(|()| ()))
| ^
|
note: delayed at compiler/rustc_borrowck/src/type_check/relate_tys.rs:359:37 - disabled backtrace
--> src/main.rs:42:24
|
42 | f::<fn(), _, _>(|_| make(|()| ()))
| ^
Backtrace
error: internal compiler error: failure to relate an opaque to itself should result in an error later on
--> <source>:42:21
|
42 | f::<fn(), _, _>(|_| make(|()| ()))
| ^^^^^^^^^^^^^^^^^
|
note: delayed at compiler/rustc_borrowck/src/type_check/relate_tys.rs:359:37
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_borrowck::type_check::relate_tys::NllTypeRelating as rustc_type_ir::relate::TypeRelation<rustc_middle::ty::context::TyCtxt>>::tys
5: <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate::<rustc_borrowck::type_check::relate_tys::NllTypeRelating>
6: rustc_type_ir::relate::structurally_relate_tys::<rustc_middle::ty::context::TyCtxt, rustc_borrowck::type_check::relate_tys::NllTypeRelating>::{closure#0}
7: <rustc_middle::ty::generic_args::GenericArg as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate::<rustc_borrowck::type_check::relate_tys::NllTypeRelating>
8: <core::result::Result<rustc_middle::ty::generic_args::GenericArg, rustc_type_ir::error::TypeError<rustc_middle::ty::context::TyCtxt>> as rustc_type_ir::interner::CollectAndApply<rustc_middle::ty::generic_args::GenericArg, &rustc_middle::ty::list::RawList<(), rustc_middle::ty::generic_args::GenericArg>>>::collect_and_apply::<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::generic_args::GenericArg>>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::generic_args::GenericArg>>>, rustc_type_ir::relate::relate_args_invariantly<rustc_middle::ty::context::TyCtxt, rustc_borrowck::type_check::relate_tys::NllTypeRelating>::{closure#0}>, <rustc_middle::ty::context::TyCtxt>::mk_args_from_iter<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::generic_args::GenericArg>>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::generic_args::GenericArg>>>, rustc_type_ir::relate::relate_args_invariantly<rustc_middle::ty::context::TyCtxt, rustc_borrowck::type_check::relate_tys::NllTypeRelating>::{closure#0}>, core::result::Result<rustc_middle::ty::generic_args::GenericArg, rustc_type_ir::error::TypeError<rustc_middle::ty::context::TyCtxt>>>::{closure#0}>
9: rustc_type_ir::relate::structurally_relate_tys::<rustc_middle::ty::context::TyCtxt, rustc_borrowck::type_check::relate_tys::NllTypeRelating>::{closure#0}
10: rustc_borrowck::type_check::type_check
11: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
12: rustc_borrowck::mir_borrowck
13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
15: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
16: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
17: rustc_interface::passes::analysis
18: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
20: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
21: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
22: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
23: 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}, ()>
24: <<std::thread::Builder>::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}
25: std::sys::thread::unix::Thread::new::thread_start
26: <unknown>
27: <unknown>
--> <source>:42:21
|
42 | f::<fn(), _, _>(|_| make(|()| ()))
| ^^^^^^^^^^^^^^^^^
error: internal compiler error: failure to relate an opaque to itself should result in an error later on
--> <source>:42:24
|
42 | f::<fn(), _, _>(|_| make(|()| ()))
| ^
|
note: delayed at compiler/rustc_borrowck/src/type_check/relate_tys.rs:359:37
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_borrowck::type_check::type_check
5: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
6: rustc_borrowck::mir_borrowck
7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
9: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
10: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
11: rustc_interface::passes::analysis
12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
15: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
16: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
17: 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}, ()>
18: <<std::thread::Builder>::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}
19: std::sys::thread::unix::Thread::new::thread_start
20: <unknown>
21: <unknown>
--> <source>:42:24
|
42 | f::<fn(), _, _>(|_| make(|()| ()))
| ^
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.