Skip to content

ICE due to impl block on typeof(closure) #147146

@theemathas

Description

@theemathas

Code

impl typeof(|| {}) {}

Similar to #146620

Meta

Reproducible on the playground with version 1.92.0-nightly (2025-09-28 c8905eaa66e0c35a3362).

Error output

error[E0516]: `typeof` is a reserved keyword but unimplemented
 --> src/lib.rs:1:6
  |
1 | impl typeof(|| {}) {}
  |      ^^^^^^^^^^^^^ reserved keyword

error: internal compiler error: compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs:203:17: unexpected impl self type of impl: DefId(0:3 ~ playground[b6f9]::{impl#0}) Closure(DefId(0:5 ~ playground[b6f9]::{impl#0}::{constant#0}::{closure#0}), [i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()])
Backtrace

thread 'rustc' (28) panicked at compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs:203:17:
Box<dyn Any>
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_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: 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}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: rustc_hir_analysis::coherence::inherent_impls::crate_inherent_impls
      [... omitted 2 frames ...]
   7: rustc_hir_analysis::coherence::inherent_impls::crate_inherent_impls_validity_check
      [... omitted 1 frame ...]
   8: rustc_hir_analysis::check_crate
   9: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  10: 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}
  11: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please attach the file at `/playground/rustc-ice-2025-09-29T05_48_37-26.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [crate_inherent_impls] finding all inherent impls defined in crate
#1 [crate_inherent_impls_validity_check] check for inherent impls that should not be defined in crate
#2 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0516`.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions