Skip to content

ICE from explicit tail call that returns a future. #144986

@theemathas

Description

@theemathas

Code

Sorry for the number of unstable features required for this lol

#![feature(async_fn_traits, unboxed_closures, type_alias_impl_trait, explicit_tail_calls)]
#![allow(incomplete_features, dead_code)]

type MyClosure = impl AsyncFnOnce();
type MyFuture = <MyClosure as AsyncFnOnce<()>>::CallOnceFuture;

#[define_opaque(MyClosure)]
fn make_closure() -> MyClosure {
    async || {}
}

trait Trait {
    extern "rust-call" fn foo(self, _: ()) -> MyFuture;
}

impl Trait for MyClosure {
    extern "rust-call" fn foo(self, _: ()) -> MyFuture {
        become self();
    }
}

@rustbot labels +F-explicit_tail_calls +requires-incomplete-features

Meta

Reproducible on the playground with version 1.91.0-nightly (2025-08-05 ec7c02612527d185c379)

Error output

error: internal compiler error: compiler/rustc_codegen_llvm/src/builder.rs:1452:17: Encountered `PassMode::Cast { pad_i32: false, cast: CastTarget { prefix: [None, None, None, None, None, None, None, None], rest_offset: None, rest: Uniform { unit: Reg { kind: Integer, size: Size(1 bytes) }, total: Size(1 bytes), is_consecutive: false }, attrs: ArgAttributes { regular: , arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None } } }` during codegen
Backtrace

thread 'rustc' panicked at compiler/rustc_codegen_llvm/src/builder.rs:1452: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_codegen_llvm::builder::GenericBuilder<rustc_codegen_llvm::context::FullCx> as rustc_codegen_ssa::traits::builder::BuilderMethods>::tail_call
   7: <rustc_codegen_ssa::mir::block::TerminatorCodegenHelper>::do_call::<rustc_codegen_llvm::builder::GenericBuilder<rustc_codegen_llvm::context::FullCx>>
   8: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::GenericBuilder<rustc_codegen_llvm::context::FullCx>>
   9: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  10: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  11: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  12: <rustc_interface::queries::Linker>::codegen_and_build_linker
  13: 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}
  14: 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-08-06T08_39_49-25.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:
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-explicit_tail_calls`#![feature(explicit_tail_calls)]`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.requires-incomplete-featuresThis issue requires the use of incomplete features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions