Skip to content

[ICE]: broken MIR in Shim(FutureDropPoll(DefId #161101

Description

@matthiaskrgr

snippet:

//@compile-flags: --edition=2024 -Clink-dead-code=true -Znext-solver=globally --crate-type=lib
#![feature(async_drop)]
#![feature(gen_blocks)]
async fn html() {
    async gen {
        gen { yield };
        yield
    };
}

Version information

rustc 1.99.0-nightly (a9066b3a6 2026-08-14)
binary: rustc
commit-hash: a9066b3a6e6a0956706c77c49f24a8d258c5ed3b
commit-date: 2026-08-14
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 23.1.0

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 -Clink-dead-code=true -Znext-solver=globally --crate-type=lib

Program output

warning: the feature `async_drop` is incomplete and may not be safe to use and/or cause compiler crashes
 --> code.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: function `html` is never used
 --> code.rs:3:10
  |
3 | async fn html() {
  |          ^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: unused coroutine that must be used
 --> code.rs:4:5
  |
4 | /     async gen {
5 | |         gen { yield };
6 | |         yield
7 | |     };
  | |_____^
  |
  = note: coroutines are lazy and do nothing unless resumed
  = note: `#[warn(unused_must_use)]` (part of `#[warn(unused)]`) on by default

warning: unused coroutine that must be used
 --> code.rs:5:9
  |
5 |         gen { yield };
  |         ^^^^^^^^^^^^^
  |
  = note: coroutines are lazy and do nothing unless resumed

error: internal compiler error: /rustc-dev/a9066b3a6e6a0956706c77c49f24a8d258c5ed3b/compiler/rustc_mir_transform/src/validate.rs:82:25: broken MIR in Shim(FutureDropPoll(DefId(2:17326 ~ core[13dd]::future::async_drop::async_drop_in_place::{closure#0}), Coroutine(DefId(2:17326 ~ core[13dd]::future::async_drop::async_drop_in_place::{closure#0}), [Coroutine(DefId(0:6 ~ code[5e39]::html::{closure#0}::{closure#0}), [(), std::future::ResumeTy, std::task::Poll<std::option::Option<()>>, (), ()]), (), std::future::ResumeTy, (), (), (&'{erased} mut Coroutine(DefId(0:6 ~ code[5e39]::html::{closure#0}::{closure#0}), [(), std::future::ResumeTy, std::task::Poll<std::option::Option<()>>, (), ()]),)]), Coroutine(DefId(0:6 ~ code[5e39]::html::{closure#0}::{closure#0}), [(), std::future::ResumeTy, std::task::Poll<std::option::Option<()>>, (), ()]))) (after phase change to runtime-optimized) at bb3[0]:
                                encountered `_0 = const std::async_iter::async_iter::<impl std::task::Poll<std::option::Option<()>>>::PENDING` with incompatible types:
                                left-hand side has type: std::task::Poll<()>
                                right-hand side has type: std::task::Poll<std::option::Option<()>>
 --> code.rs:5:22
  |
5 |         gen { yield };
  |                      ^


thread 'rustc' (3034729) panicked at /rustc-dev/a9066b3a6e6a0956706c77c49f24a8d258c5ed3b/compiler/rustc_mir_transform/src/validate.rs:82:25:
Box<dyn Any>
stack backtrace:
   0:     0x7eff59c6ea46 - <<std[692e976d77b7a3f6]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[13dda5fcc088c534]::fmt::Display>::fmt
   1:     0x7eff5a20e0cf - core[13dda5fcc088c534]::fmt::write
   2:     0x7eff59c83ecc - <std[692e976d77b7a3f6]::sys::stdio::unix::Stderr as core[13dda5fcc088c534]::io::write::Write>::write_fmt
   3:     0x7eff59c41e9a - std[692e976d77b7a3f6]::panicking::default_hook::{closure#0}
   4:     0x7eff59c62cf3 - std[692e976d77b7a3f6]::panicking::default_hook
   5:     0x7eff58be543a - std[692e976d77b7a3f6]::panicking::update_hook::<alloc[dbfd58dbf254fafa]::boxed::Box<rustc_driver_impl[1370f39de7a97809]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7eff59c63192 - std[692e976d77b7a3f6]::panicking::panic_with_hook
   7:     0x7eff58c12f44 - std[692e976d77b7a3f6]::panicking::begin_panic::<rustc_errors[25ba36bf64e1aaff]::ExplicitBug>::{closure#0}
   8:     0x7eff58c0bb86 - std[692e976d77b7a3f6]::sys::backtrace::__rust_end_short_backtrace::<std[692e976d77b7a3f6]::panicking::begin_panic<rustc_errors[25ba36bf64e1aaff]::ExplicitBug>::{closure#0}, !>
   9:     0x7eff58c0b9cb - std[692e976d77b7a3f6]::panicking::begin_panic::<rustc_errors[25ba36bf64e1aaff]::ExplicitBug>
  10:     0x7eff58c1e8f1 - <rustc_errors[25ba36bf64e1aaff]::diagnostic::BugAbort as rustc_errors[25ba36bf64e1aaff]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7eff5917715c - <rustc_errors[25ba36bf64e1aaff]::DiagCtxtHandle>::span_bug::<rustc_span[6eba6fbb581c6740]::span_encoding::Span, alloc[dbfd58dbf254fafa]::string::String>
  12:     0x7eff591a7ad6 - rustc_middle[f494a7f59409fa9f]::util::bug::opt_span_bug_fmt::<rustc_span[6eba6fbb581c6740]::span_encoding::Span>::{closure#0}
  13:     0x7eff591a7ef2 - rustc_middle[f494a7f59409fa9f]::ty::context::tls::with_opt::<rustc_middle[f494a7f59409fa9f]::util::bug::opt_span_bug_fmt<rustc_span[6eba6fbb581c6740]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7eff591928a0 - rustc_middle[f494a7f59409fa9f]::ty::context::tls::with_context_opt::<rustc_middle[f494a7f59409fa9f]::ty::context::tls::with_opt<rustc_middle[f494a7f59409fa9f]::util::bug::opt_span_bug_fmt<rustc_span[6eba6fbb581c6740]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7eff571c3168 - rustc_middle[f494a7f59409fa9f]::util::bug::span_bug_fmt::<rustc_span[6eba6fbb581c6740]::span_encoding::Span>
  16:     0x7eff576a6e15 - <rustc_mir_transform[3a01492f6be5ac40]::validate::CfgChecker>::fail::<alloc[dbfd58dbf254fafa]::string::String>
  17:     0x7eff5b55235d - <rustc_mir_transform[3a01492f6be5ac40]::validate::Validator as rustc_mir_transform[3a01492f6be5ac40]::pass_manager::MirPass>::run_pass
  18:     0x7eff5a207969 - rustc_mir_transform[3a01492f6be5ac40]::pass_manager::run_passes_inner
  19:     0x7eff59377ae7 - rustc_mir_transform[3a01492f6be5ac40]::run_optimization_passes
  20:     0x7eff5b17fbf3 - rustc_mir_transform[3a01492f6be5ac40]::shim::make_shim
  21:     0x7eff5b17e683 - rustc_query_impl[a35d67d5fc9ff5f9]::query_vtables::mir_shims::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7eff5ab70751 - rustc_query_impl[a35d67d5fc9ff5f9]::execution::try_execute_query::<rustc_middle[f494a7f59409fa9f]::query::caches::DefaultCache<rustc_middle[f494a7f59409fa9f]::ty::instance::ShimKind, rustc_middle[f494a7f59409fa9f]::query::erase::ErasedData<[u8; 8usize]>>, false>
  23:     0x7eff5ab70467 - rustc_query_impl[a35d67d5fc9ff5f9]::query_vtables::mir_shims::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7eff5a41270d - <rustc_middle[f494a7f59409fa9f]::ty::context::TyCtxt>::instance_mir
  25:     0x7eff5a41850b - rustc_monomorphize[c437d136507ca264]::collector::items_of_instance
  26:     0x7eff5a418491 - rustc_query_impl[a35d67d5fc9ff5f9]::query_vtables::items_of_instance::invoke_provider_fn::__rust_begin_short_backtrace
  27:     0x7eff5af6aca0 - rustc_query_impl[a35d67d5fc9ff5f9]::execution::try_execute_query::<rustc_middle[f494a7f59409fa9f]::query::caches::DefaultCache<(rustc_middle[f494a7f59409fa9f]::ty::instance::Instance, rustc_middle[f494a7f59409fa9f]::mono::CollectionMode), rustc_middle[f494a7f59409fa9f]::query::erase::ErasedData<[u8; 32usize]>>, false>
  28:     0x7eff5af6a922 - rustc_query_impl[a35d67d5fc9ff5f9]::query_vtables::items_of_instance::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7eff5b22f667 - rustc_monomorphize[c437d136507ca264]::collector::collect_items_rec
  30:     0x7eff5b2318d7 - rustc_monomorphize[c437d136507ca264]::collector::collect_items_rec
  31:     0x7eff5b235cf6 - rustc_monomorphize[c437d136507ca264]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  32:     0x7eff5b236601 - rustc_monomorphize[c437d136507ca264]::partitioning::collect_and_partition_mono_items
  33:     0x7eff5b3caa96 - rustc_query_impl[a35d67d5fc9ff5f9]::query_vtables::collect_and_partition_mono_items::invoke_provider_fn::__rust_begin_short_backtrace
  34:     0x7eff5b3ca3c5 - rustc_query_impl[a35d67d5fc9ff5f9]::execution::try_execute_query::<rustc_middle[f494a7f59409fa9f]::query::caches::SingleCache<rustc_middle[f494a7f59409fa9f]::query::erase::ErasedData<[u8; 24usize]>>, false>
  35:     0x7eff5b3ca138 - rustc_query_impl[a35d67d5fc9ff5f9]::query_vtables::collect_and_partition_mono_items::execute_query_non_incr::__rust_end_short_backtrace
  36:     0x7eff5ab98e83 - rustc_codegen_ssa[db30eeacc56e781b]::back::symbol_export::exported_generic_symbols_provider_local
  37:     0x7eff5b3e6070 - rustc_query_impl[a35d67d5fc9ff5f9]::query_vtables::exported_generic_symbols::invoke_provider_fn::__rust_begin_short_backtrace
  38:     0x7eff5b02cd75 - rustc_query_impl[a35d67d5fc9ff5f9]::execution::try_execute_query::<rustc_data_structures[414d63a8a0047e5e]::vec_cache::VecCache<rustc_span[6eba6fbb581c6740]::def_id::CrateNum, rustc_middle[f494a7f59409fa9f]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[f494a7f59409fa9f]::dep_graph::graph::DepNodeIndex>, false>
  39:     0x7eff5b02ca27 - rustc_query_impl[a35d67d5fc9ff5f9]::query_vtables::exported_generic_symbols::execute_query_non_incr::__rust_end_short_backtrace
  40:     0x7eff5b2839ec - <rustc_metadata[8780c7c13e9daca6]::rmeta::encoder::EncodeContext>::encode_crate_root
  41:     0x7eff5b0dca6d - rustc_metadata[8780c7c13e9daca6]::rmeta::encoder::encode_metadata::{closure#3}
  42:     0x7eff5b0da1ed - rustc_metadata[8780c7c13e9daca6]::rmeta::encoder::encode_metadata
  43:     0x7eff5b0ded7a - rustc_metadata[8780c7c13e9daca6]::fs::encode_and_write_metadata
  44:     0x7eff5b48e7fe - <rustc_interface[25623703ff6c4eae]::queries::Linker>::codegen_and_build_linker
  45:     0x7eff5b486355 - rustc_interface[25623703ff6c4eae]::interface::run_compiler::<(), rustc_driver_impl[1370f39de7a97809]::run_compiler::{closure#0}>::{closure#2}
  46:     0x7eff5b4bd1e4 - std[692e976d77b7a3f6]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[25623703ff6c4eae]::util::run_in_thread_with_globals<rustc_interface[25623703ff6c4eae]::util::run_in_thread_pool_with_globals<rustc_interface[25623703ff6c4eae]::interface::run_compiler<(), rustc_driver_impl[1370f39de7a97809]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  47:     0x7eff5b4bcfad - <std[692e976d77b7a3f6]::thread::lifecycle::spawn_unchecked<rustc_interface[25623703ff6c4eae]::util::run_in_thread_with_globals<rustc_interface[25623703ff6c4eae]::util::run_in_thread_pool_with_globals<rustc_interface[25623703ff6c4eae]::interface::run_compiler<(), rustc_driver_impl[1370f39de7a97809]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[13dda5fcc088c534]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7eff5b4ba747 - <std[692e976d77b7a3f6]::sys::thread::unix::Thread>::new::thread_start
  49:     0x7eff54a97739 - <unknown>
  50:     0x7eff54b1bedc - <unknown>
  51:                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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-08-14T15_21_14-3034727.txt` to your bug report

note: rustc 1.99.0-nightly (a9066b3a6 2026-08-14) running on x86_64-unknown-linux-gnu

note: compiler flags: -C link-dead-code=true -Z next-solver=globally --crate-type lib

query stack during panic:
#0 [mir_shims] generating MIR shim for `core::future::async_drop::async_drop_in_place::{closure#0}`, kind=FutureDropPoll(DefId(2:17326 ~ core[13dd]::future::async_drop::async_drop_in_place::{closure#0}), Coroutine(DefId(2:17326 ~ core[13dd]::future::async_drop::async_drop_in_place::{closure#0}), [Coroutine(DefId(0:6 ~ code[5e39]::html::{closure#0}::{closure#0}), [(), core::future::ResumeTy, core::task::poll::Poll<core::option::Option<()>>, (), ()]), (), core::future::ResumeTy, (), (), (&'{erased} mut Coroutine(DefId(0:6 ~ code[5e39]::html::{closure#0}::{closure#0}), [(), core::future::ResumeTy, core::task::poll::Poll<core::option::Option<()>>, (), ()]),)]), Coroutine(DefId(0:6 ~ code[5e39]::html::{closure#0}::{closure#0}), [(), core::future::ResumeTy, core::task::poll::Poll<core::option::Option<()>>, (), ()]))
#1 [items_of_instance] collecting items used by `core::future::async_drop::async_drop_in_place::<{async gen block@code.rs:4:5: 4:14}>::{closure#0} - dropshim({async fn body of core::future::async_drop::async_drop_in_place<{async gen block@code.rs:4:5: 4:14}>()}-{async gen block@code.rs:4:5: 4:14})`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
#3 [exported_generic_symbols] collecting exported generic symbols for crate `0`
end of query stack
error: aborting due to 1 previous error; 4 warnings emitted


@rustbot label +F-async_drop +F-gen_blocks +WG-trait-system-refactor

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-async_drop`#![feature(async_drop)]`F-gen_blocks`gen {}` expressions that produce `Iterator`sI-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.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions