Skip to content

[ICE]: broken MIR in DropGlue #157449

@matthiaskrgr

Description

@matthiaskrgr

This is happening since #156649

snippet:

//@compile-flags: --edition=2024
#![feature(async_drop)]
fn main() {
    async {
        let mut f = None;
        f = Some(async {});
        f
    };
}

Version information

rustc 1.98.0-nightly (0cf968126 2026-06-04)
binary: rustc
commit-hash: 0cf96812614b8250543d749629867b36f2757f4d
commit-date: 2026-06-04
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6

Possibly related line of code:

};
cfg_checker.visit_body(body);
cfg_checker.check_cleanup_control_flow();
// Also run the TypeChecker.
for (location, msg) in validate_types(tcx, typing_env, body, body) {
cfg_checker.fail(location, msg);
}
// Ensure that debuginfo records are not emitted for locals that are not in debuginfo.
for (location, msg) in validate_debuginfos(body) {
cfg_checker.fail(location, msg);
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024

Program output

warning: the feature `async_drop` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.eWzJdz2LuuZU/rustc_testrunner_tmpdir_reporting.3KMPI2icPkwH/mvce.rs:1:12
  |
1 | #![feature(async_drop)]
  |            ^^^^^^^^^^
  |
  = note: see issue #126482 <https://github.com/rust-lang/rust/issues/126482> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: value assigned to `f` is never read
 --> /tmp/icemaker_global_tempdir.eWzJdz2LuuZU/rustc_testrunner_tmpdir_reporting.3KMPI2icPkwH/mvce.rs:4:21
  |
4 |         let mut f = None;
  |                     ^^^^ this value is reassigned later and never used
5 |         f = Some(async {});
  |         - `f` is overwritten here before the previous value is read
  |
  = note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default

warning: unused implementer of `Future` that must be used
 --> /tmp/icemaker_global_tempdir.eWzJdz2LuuZU/rustc_testrunner_tmpdir_reporting.3KMPI2icPkwH/mvce.rs:3:5
  |
3 | /     async {
4 | |         let mut f = None;
5 | |         f = Some(async {});
6 | |         f
7 | |     };
  | |_____^
  |
  = note: futures do nothing unless you `.await` or poll them
  = note: `#[warn(unused_must_use)]` (part of `#[warn(unused)]`) on by default

error: internal compiler error: /rustc-dev/0cf96812614b8250543d749629867b36f2757f4d/compiler/rustc_mir_transform/src/validate.rs:82:25: broken MIR in DropGlue(DefId(2:3278 ~ core[e0f7]::ptr::drop_glue), Some(Coroutine(DefId(0:4 ~ mvce[9705]::main::{closure#0}), [(), std::future::ResumeTy, (), std::option::Option<Coroutine(DefId(0:5 ~ mvce[9705]::main::{closure#0}::{closure#0}), [(), std::future::ResumeTy, (), (), ()])>, ()]))) (after phase change to runtime-optimized) at bb5[0]:
                                encountered `_0 = std::task::Poll::<std::option::Option<{async block@/tmp/icemaker_global_tempdir.eWzJdz2LuuZU/rustc_testrunner_tmpdir_reporting.3KMPI2icPkwH/mvce.rs:5:18: 5:23}>>::Ready(move _16)` with incompatible types:
                                left-hand side has type: ()
                                right-hand side has type: std::task::Poll<std::option::Option<{async block@/tmp/icemaker_global_tempdir.eWzJdz2LuuZU/rustc_testrunner_tmpdir_reporting.3KMPI2icPkwH/mvce.rs:5:18: 5:23}>>
 --> /tmp/icemaker_global_tempdir.eWzJdz2LuuZU/rustc_testrunner_tmpdir_reporting.3KMPI2icPkwH/mvce.rs:7:6
  |
7 |     };
  |      ^


thread 'rustc' (2678349) panicked at /rustc-dev/0cf96812614b8250543d749629867b36f2757f4d/compiler/rustc_mir_transform/src/validate.rs:82:25:
Box<dyn Any>
stack backtrace:
   0:     0x7f5a06688299 - <<std[e1d9dc41703d3c77]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[e0f79a309d5a3d5c]::fmt::Display>::fmt
   1:     0x7f5a06e22e88 - core[e0f79a309d5a3d5c]::fmt::write
   2:     0x7f5a0669e326 - <std[e1d9dc41703d3c77]::sys::stdio::unix::Stderr as std[e1d9dc41703d3c77]::io::Write>::write_fmt
   3:     0x7f5a0665da5e - std[e1d9dc41703d3c77]::panicking::default_hook::{closure#0}
   4:     0x7f5a0667b163 - std[e1d9dc41703d3c77]::panicking::default_hook
   5:     0x7f5a05476eb1 - std[e1d9dc41703d3c77]::panicking::update_hook::<alloc[ddaee4004cd2d224]::boxed::Box<rustc_driver_impl[a975172c0be376f0]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f5a0667b442 - std[e1d9dc41703d3c77]::panicking::panic_with_hook
   7:     0x7f5a054a4671 - std[e1d9dc41703d3c77]::panicking::begin_panic::<rustc_errors[4f43504df6b439c3]::ExplicitBug>::{closure#0}
   8:     0x7f5a0549d666 - std[e1d9dc41703d3c77]::sys::backtrace::__rust_end_short_backtrace::<std[e1d9dc41703d3c77]::panicking::begin_panic<rustc_errors[4f43504df6b439c3]::ExplicitBug>::{closure#0}, !>
   9:     0x7f5a0549d3cb - std[e1d9dc41703d3c77]::panicking::begin_panic::<rustc_errors[4f43504df6b439c3]::ExplicitBug>
  10:     0x7f5a054afb61 - <rustc_errors[4f43504df6b439c3]::diagnostic::BugAbort as rustc_errors[4f43504df6b439c3]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f5a05b1393c - <rustc_errors[4f43504df6b439c3]::DiagCtxtHandle>::span_bug::<rustc_span[48046fdc775f1ad7]::span_encoding::Span, alloc[ddaee4004cd2d224]::string::String>
  12:     0x7f5a05b3efc6 - rustc_middle[c9c104d2dfb47290]::util::bug::opt_span_bug_fmt::<rustc_span[48046fdc775f1ad7]::span_encoding::Span>::{closure#0}
  13:     0x7f5a05b3f152 - rustc_middle[c9c104d2dfb47290]::ty::context::tls::with_opt::<rustc_middle[c9c104d2dfb47290]::util::bug::opt_span_bug_fmt<rustc_span[48046fdc775f1ad7]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f5a05b2d80b - rustc_middle[c9c104d2dfb47290]::ty::context::tls::with_context_opt::<rustc_middle[c9c104d2dfb47290]::ty::context::tls::with_opt<rustc_middle[c9c104d2dfb47290]::util::bug::opt_span_bug_fmt<rustc_span[48046fdc775f1ad7]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f5a03683038 - rustc_middle[c9c104d2dfb47290]::util::bug::span_bug_fmt::<rustc_span[48046fdc775f1ad7]::span_encoding::Span>
  16:     0x7f5a041cf8b5 - <rustc_mir_transform[8d0497c8b7978976]::validate::CfgChecker>::fail::<alloc[ddaee4004cd2d224]::string::String>
  17:     0x7f5a07b77601 - <rustc_mir_transform[8d0497c8b7978976]::validate::Validator as rustc_mir_transform[8d0497c8b7978976]::pass_manager::MirPass>::run_pass
  18:     0x7f5a07b5b96e - rustc_mir_transform[8d0497c8b7978976]::pass_manager::run_passes_inner
  19:     0x7f5a07b08e59 - rustc_mir_transform[8d0497c8b7978976]::shim::make_shim
  20:     0x7f5a07b08220 - rustc_query_impl[85ac94c76a033c3c]::query_impl::mir_shims::invoke_provider_fn::__rust_begin_short_backtrace
  21:     0x7f5a07b0e66d - rustc_query_impl[85ac94c76a033c3c]::execution::try_execute_query::<rustc_middle[c9c104d2dfb47290]::query::caches::DefaultCache<rustc_middle[c9c104d2dfb47290]::ty::instance::InstanceKind, rustc_middle[c9c104d2dfb47290]::query::erase::ErasedData<[u8; 8usize]>>, false>
  22:     0x7f5a07b0e37f - rustc_query_impl[85ac94c76a033c3c]::query_impl::mir_shims::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f5a07892c3d - <rustc_middle[c9c104d2dfb47290]::ty::context::TyCtxt>::instance_mir
  24:     0x7f5a07896b4b - rustc_monomorphize[415bfb07c478fbce]::collector::items_of_instance
  25:     0x7f5a07896ad1 - rustc_query_impl[85ac94c76a033c3c]::query_impl::items_of_instance::invoke_provider_fn::__rust_begin_short_backtrace
  26:     0x7f5a0789376a - rustc_query_impl[85ac94c76a033c3c]::execution::try_execute_query::<rustc_middle[c9c104d2dfb47290]::query::caches::DefaultCache<(rustc_middle[c9c104d2dfb47290]::ty::instance::Instance, rustc_middle[c9c104d2dfb47290]::mono::CollectionMode), rustc_middle[c9c104d2dfb47290]::query::erase::ErasedData<[u8; 32usize]>>, false>
  27:     0x7f5a078933d3 - rustc_query_impl[85ac94c76a033c3c]::query_impl::items_of_instance::execute_query_non_incr::__rust_end_short_backtrace
  28:     0x7f5a07bd8bef - rustc_monomorphize[415bfb07c478fbce]::collector::collect_items_rec
  29:     0x7f5a07bda9f5 - rustc_monomorphize[415bfb07c478fbce]::collector::collect_items_rec
  30:     0x7f5a07bde379 - rustc_monomorphize[415bfb07c478fbce]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  31:     0x7f5a07bdf035 - rustc_monomorphize[415bfb07c478fbce]::partitioning::collect_and_partition_mono_items
  32:     0x7f5a07bdece4 - rustc_query_impl[85ac94c76a033c3c]::query_impl::collect_and_partition_mono_items::invoke_provider_fn::__rust_begin_short_backtrace
  33:     0x7f5a07fd07ac - rustc_query_impl[85ac94c76a033c3c]::execution::try_execute_query::<rustc_middle[c9c104d2dfb47290]::query::caches::SingleCache<rustc_middle[c9c104d2dfb47290]::query::erase::ErasedData<[u8; 24usize]>>, false>
  34:     0x7f5a07fd053c - rustc_query_impl[85ac94c76a033c3c]::query_impl::collect_and_partition_mono_items::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x7f5a080c5672 - rustc_codegen_ssa[4ddc32a98fb5b30b]::base::codegen_crate::<rustc_codegen_llvm[95658c7795df270]::LlvmCodegenBackend, rustc_codegen_llvm[95658c7795df270]::ModuleLlvm>
  36:     0x7f5a080c538d - <rustc_codegen_llvm[95658c7795df270]::LlvmCodegenBackend as rustc_codegen_ssa[4ddc32a98fb5b30b]::traits::backend::CodegenBackend>::codegen_crate
  37:     0x7f5a0801be9c - <rustc_interface[de505257a3491ef8]::queries::Linker>::codegen_and_build_linker
  38:     0x7f5a0801652b - rustc_interface[de505257a3491ef8]::interface::run_compiler::<(), rustc_driver_impl[a975172c0be376f0]::run_compiler::{closure#0}>::{closure#1}
  39:     0x7f5a07f9dd3e - std[e1d9dc41703d3c77]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[de505257a3491ef8]::util::run_in_thread_with_globals<rustc_interface[de505257a3491ef8]::util::run_in_thread_pool_with_globals<rustc_interface[de505257a3491ef8]::interface::run_compiler<(), rustc_driver_impl[a975172c0be376f0]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  40:     0x7f5a07f9e42d - <std[e1d9dc41703d3c77]::thread::lifecycle::spawn_unchecked<rustc_interface[de505257a3491ef8]::util::run_in_thread_with_globals<rustc_interface[de505257a3491ef8]::util::run_in_thread_pool_with_globals<rustc_interface[de505257a3491ef8]::interface::run_compiler<(), rustc_driver_impl[a975172c0be376f0]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e0f79a309d5a3d5c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f5a07f9f22c - <std[e1d9dc41703d3c77]::sys::thread::unix::Thread>::new::thread_start
  42:     0x7f5a014981b9 - <unknown>
  43:     0x7f5a0151d21c - <unknown>
  44:                0x0 - <unknown>

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: rustc 1.98.0-nightly (0cf968126 2026-06-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [mir_shims] generating MIR shim for `core::ptr::drop_glue`, instance=DropGlue(DefId(2:3278 ~ core[e0f7]::ptr::drop_glue), Some(Coroutine(DefId(0:4 ~ mvce[9705]::main::{closure#0}), [(), core::future::ResumeTy, (), core::option::Option<Coroutine(DefId(0:5 ~ mvce[9705]::main::{closure#0}::{closure#0}), [(), core::future::ResumeTy, (), (), ()])>, ()])))
#1 [items_of_instance] collecting items used by `core::ptr::drop_glue::<{async block@/tmp/icemaker_global_tempdir.eWzJdz2LuuZU/rustc_testrunner_tmpdir_reporting.3KMPI2icPkwH/mvce.rs:3:5: 3:10}> - shim(Some({async block@/tmp/icemaker_global_tempdir.eWzJdz2LuuZU/rustc_testrunner_tmpdir_reporting.3KMPI2icPkwH/mvce.rs:3:5: 3:10}))`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to 1 previous error; 3 warnings emitted


@rustbot label +F-async_drop

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-async_drop`#![feature(async_drop)]`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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions