Skip to content

ICE due to implementing auto trait on typeof(closure) #146620

@theemathas

Description

@theemathas

Code

unsafe impl Send for typeof(||{}) {}

Meta

Reproducible on the playground with version 1.92.0-nightly (2025-09-15 a454fccb02df9d361f12)

Error output

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

error: internal compiler error: compiler/rustc_hir_analysis/src/coherence/orphan.rs:238:17: weird self type for autotrait impl
 --> src/lib.rs:1:1
  |
1 | unsafe impl Send for typeof(||{}) {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Backtrace

thread 'rustc' (51) panicked at compiler/rustc_hir_analysis/src/coherence/orphan.rs:238: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_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_hir_analysis::coherence::orphan::orphan_check_impl
      [... omitted 1 frame ...]
   8: rustc_hir_analysis::coherence::coherent_trait
      [... omitted 1 frame ...]
   9: rustc_hir_analysis::check::check::check_item_type
  10: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
  11: rustc_hir_analysis::check::wfcheck::check_type_wf
      [... omitted 1 frame ...]
  12: rustc_hir_analysis::check_crate
  13: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  14: 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}
  15: 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-16T03_59_18-49.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 [orphan_check_impl] checking whether impl `<impl at src/lib.rs:1:1: 1:34>` follows the orphan rules
#1 [coherent_trait] coherence checking all impls of trait `core::marker::Send`
#2 [check_well_formed] checking that `<impl at src/lib.rs:1:1: 1:34>` is well-formed
#3 [check_type_wf] checking that types are well-formed
#4 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0516`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)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