Open
Description
Code
pub trait Foo {
type Bar<'a>;
}
pub struct FooImpl {}
impl Foo for FooImpl {
type Bar<'a> = ();
}
pub trait FooFn {
fn bar(&self);
}
impl<T: Foo> FooFn for fn(T, T::Bar<'_>) {
fn bar(&self) {}
}
fn foo<T: Foo>(f: fn(T, T::Bar<'_>)) {
let _: &dyn FooFn = &f;
}
fn main() {
foo(|_: FooImpl, _| {});
}
Meta
rustc --version --verbose
:
rustc 1.85.1 (4eb161250 2025-03-15)
binary: rustc
commit-hash: 4eb161250e340c8f48f66e2b929ef4a5bed7c181
commit-date: 2025-03-15
host: x86_64-unknown-linux-gnu
release: 1.85.1
LLVM version: 19.1.7
Error output
error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:585:21: failed to resolve instance for <fn(FooImpl, ()) as FooFn>::bar
--> src/main.rs:12:5
|
12 | fn bar(&self);
| ^^^^^^^^^^^^^^
thread 'rustc' panicked at compiler/rustc_middle/src/ty/instance.rs:585:21:
Box<dyn Any>
Backtrace
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
2: <rustc_errors::DiagCtxtHandle>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
7: <rustc_middle::ty::instance::Instance>::expect_resolve
8: <rustc_middle::ty::instance::Instance>::expect_resolve_for_vtable
9: rustc_trait_selection::traits::vtable::vtable_entries::{closure#0}
10: rustc_trait_selection::traits::vtable::vtable_entries
[... omitted 3 frames ...]
11: rustc_monomorphize::collector::create_mono_items_for_vtable_methods
12: rustc_monomorphize::collector::items_of_instance
[... omitted 1 frame ...]
13: rustc_monomorphize::collector::collect_items_rec::{closure#0}
14: rustc_monomorphize::collector::collect_items_rec
15: rustc_monomorphize::collector::collect_items_rec
16: rustc_monomorphize::partitioning::collect_and_partition_mono_items
[... omitted 2 frames ...]
17: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
18: <rustc_interface::queries::Linker>::codegen_and_build_linker
19: 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}
20: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Relevant to the compiler team, which will review and decide on the PR/issue.Fixed by the next-generation trait solver, `-Znext-solver`.