[ICE]: `Can't write value with incompatible type &'{erased} mut std::task::Context<'{erased}> to place with type u8`
Open
Nobody has claimed this yet.
C-bug
F-async_drop
F-coroutines
I-ICE
needs-triage
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
rustc --edition=2024 -Clink-dead-code=true -Zcodegen-backend=cranelift
This triggers an assert inside cranelift, when I remove async_drop feature its fine, so I assume an async_drop bug.
Code
#![feature(coroutines)]
#![feature(async_drop)]
fn main() {
async {
#[coroutine]
static |x: u8| match x {
y if yield == y => (),
_ => (),
};
};
}
Meta
rustc --version --verbose:
rustc 1.98.0-nightly (6bdf43094 2026-06-01)
binary: rustc
commit-hash: 6bdf43094fae65d298bc430362f116176cd25a3c
commit-date: 2026-06-01
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Error output
<output>
Backtrace
warning: the feature `async_drop` is incomplete and may not be safe to use and/or cause compiler crashes
--> code.rs:2:12
|
2 | #![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: unused implementer of `Future` that must be used
--> code.rs:4:5
|
4 | / async {
5 | | #[coroutine]
6 | | static |x: u8| match x {
7 | | y if yield == y => (),
8 | | _ => (),
9 | | };
10 | | };
| |_____^
|
= note: futures do nothing unless you `.await` or poll them
= note: `#[warn(unused_must_use)]` (part of `#[warn(unused)]`) on by default
warning: unused coroutine that must be used
--> code.rs:6:9
|
6 | / static |x: u8| match x {
7 | | y if yield == y => (),
8 | | _ => (),
9 | | };
| |_________^
|
= note: coroutines are lazy and do nothing unless resumed
thread 'rustc' (231802) panicked at /rustc-dev/6bdf43094fae65d298bc430362f116176cd25a3c/compiler/rustc_codegen_cranelift/src/value_and_place.rs:512:9:
assertion `left == right` failed: Can't write value with incompatible type &'{erased} mut std::task::Context<'{erased}> to place with type u8
[Coroutine(DefId(0:5 ~ code[6157]::main::{closure#0}::{closure#0}), [(), u8, (), (), ()]), (), std::future::ResumeTy, (), (), (&'{erased} mut Coroutine(DefId(0:5 ~ code[6157]::main::{closure#0}::{closure#0}), [(), u8, (), (), ()]),)]
[CPlace { inner: Addr(Pointer { base: Stack(ss0), offset: Offset32(0) }, None), layout: TyAndLayout { ty: Poll<()>, layout: Layout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Scalar(Initialized { value: Int(I8, false), valid_range: 0..=1 }), fields: Arbitrary { offsets: [Size(0 bytes)], in_memory_order: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Int(I8, false), valid_range: 0..=1 }), uninhabited: false, variants: Multiple { tag: Initialized { value: Int(I8, false), valid_range: 0..=1 }, tag_encoding: Direct, tag_field: 0, variants: [VariantLayout { size: Size(1 bytes), backend_repr: Scalar(Initialized { value: Int(I8, false), valid_range: 0..=1 }), field_offsets: [Size(1 bytes)], fields_in_memory_order: [0], largest_niche: None, uninhabited: false }, VariantLayout { size: Size(1 bytes), backend_repr: Memory { sized: true }, field_offsets: [], fields_in_memory_order: [], largest_niche: None, uninhabited: false }] }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 11768639066024928700 } } }, CPlace { inner: Addr(Pointer { base: Stack(ss1), offset: Offset32(0) }, None), layout: TyAndLayout { ty: Pin<&mut {async fn body of async_drop_in_place<{static coroutine@code.rs:6:9: 6:23}>()}>, layout: Layout { size: Size(8 bytes), align: AbiAlign { abi: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Arbitrary { offsets: [Size(0 bytes)], in_memory_order: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 7806131535709625041 } } }, CPlace { inner: Var(_2, var1), layout: TyAndLayout { ty: u8, layout: Layout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Scalar(Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Primitive, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } } }]
function u0:6(i64, i64) -> i8 uext system_v {
ss0 = explicit_slot 1
ss1 = explicit_slot 8, align = 8
block0(v0: i64, v1: i64):
nop
stack_store v0, ss1
}
left: &'{erased} mut std::task::Context<'{erased}>
right: u8
stack backtrace:
0: 0x7fe3f3eb7e69 - <<std[f3c9ac17ed98d4bf]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[38febd7418bd713c]::fmt::Display>::fmt
1: 0x7fe3f462a4c8 - core[38febd7418bd713c]::fmt::write
2: 0x7fe3f3ece966 - <std[f3c9ac17ed98d4bf]::sys::stdio::unix::Stderr as std[f3c9ac17ed98d4bf]::io::Write>::write_fmt
3: 0x7fe3f3e8e09e - std[f3c9ac17ed98d4bf]::panicking::default_hook::{closure#0}
4: 0x7fe3f3eab7a3 - std[f3c9ac17ed98d4bf]::panicking::default_hook
5: 0x7fe3f2c97ca1 - std[f3c9ac17ed98d4bf]::panicking::update_hook::<alloc[e58d9d17a66c7a99]::boxed::Box<rustc_driver_impl[8b54d5bb9fab87c3]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7fe3f3eaba82 - std[f3c9ac17ed98d4bf]::panicking::panic_with_hook
7: 0x7fe3f3e8e162 - std[f3c9ac17ed98d4bf]::panicking::panic_handler::{closure#0}
8: 0x7fe3f3e82689 - std[f3c9ac17ed98d4bf]::sys::backtrace::__rust_end_short_backtrace::<std[f3c9ac17ed98d4bf]::panicking::panic_handler::{closure#0}, !>
9: 0x7fe3f3e8fbcd - __rustc[d889b9b15be890d2]::rust_begin_unwind
10: 0x7fe3f09a1e3c - core[38febd7418bd713c]::panicking::panic_fmt
11: 0x7fe3f25c0973 - core[38febd7418bd713c]::panicking::assert_failed_inner
12: 0x7fe3f334b251 - core[38febd7418bd713c]::panicking::assert_failed::<rustc_middle[941705664756e64a]::ty::Ty, rustc_middle[941705664756e64a]::ty::Ty>
13: 0x7fe3e16a85b1 - rustc_codegen_cranelift[ee78beaea24cf31c]::value_and_place::assert_assignable
14: 0x7fe3e16b6508 - rustc_codegen_cranelift[ee78beaea24cf31c]::base::codegen_fn_body
15: 0x7fe3e16e0a29 - rustc_codegen_cranelift[ee78beaea24cf31c]::driver::aot::codegen_cgu_content
16: 0x7fe3e167c069 - rustc_codegen_cranelift[ee78beaea24cf31c]::driver::aot::run_aot::{closure#3}::{closure#0}::{closure#0}
17: 0x7fe3e167d8eb - rustc_codegen_cranelift[ee78beaea24cf31c]::driver::aot::run_aot::{closure#3}::{closure#0}
18: 0x7fe3e16eced9 - <core[38febd7418bd713c]::iter::adapters::filter_map::FilterMap<alloc[e58d9d17a66c7a99]::vec::into_iter::IntoIter<(usize, &rustc_middle[941705664756e64a]::mono::CodegenUnit)>, rustc_data_structures[91b7b8f6cee58889]::sync::parallel::par_map<(usize, &rustc_middle[941705664756e64a]::mono::CodegenUnit), alloc[e58d9d17a66c7a99]::vec::Vec<(usize, &rustc_middle[941705664756e64a]::mono::CodegenUnit)>, rustc_data_structures[91b7b8f6cee58889]::marker::IntoDynSyncSend<rustc_codegen_cranelift[ee78beaea24cf31c]::driver::aot::OngoingModuleCodegen>, alloc[e58d9d17a66c7a99]::vec::Vec<rustc_data_structures[91b7b8f6cee58889]::marker::IntoDynSyncSend<rustc_codegen_cranelift[ee78beaea24cf31c]::driver::aot::OngoingModuleCodegen>>, rustc_codegen_cranelift[ee78beaea24cf31c]::driver::aot::run_aot::{closure#3}::{closure#0}>::{closure#0}::{closure#3}> as core[38febd7418bd713c]::iter::traits::iterator::Iterator>::next
19: 0x7fe3e16e4f44 - rustc_codegen_cranelift[ee78beaea24cf31c]::driver::aot::run_aot
20: 0x7fe3e16f6344 - <rustc_codegen_cranelift[ee78beaea24cf31c]::CraneliftCodegenBackend as rustc_codegen_ssa[2461904fbf16def0]::traits::backend::CodegenBackend>::codegen_crate
21: 0x7fe3f57ba65c - <rustc_interface[e4073cecbcc8453d]::queries::Linker>::codegen_and_build_linker
22: 0x7fe3f57b4ce9 - rustc_interface[e4073cecbcc8453d]::interface::run_compiler::<(), rustc_driver_impl[8b54d5bb9fab87c3]::run_compiler::{closure#0}>::{closure#1}
23: 0x7fe3f5761bba - std[f3c9ac17ed98d4bf]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e4073cecbcc8453d]::util::run_in_thread_with_globals<rustc_interface[e4073cecbcc8453d]::util::run_in_thread_pool_with_globals<rustc_interface[e4073cecbcc8453d]::interface::run_compiler<(), rustc_driver_impl[8b54d5bb9fab87c3]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
24: 0x7fe3f57622ad - <std[f3c9ac17ed98d4bf]::thread::lifecycle::spawn_unchecked<rustc_interface[e4073cecbcc8453d]::util::run_in_thread_with_globals<rustc_interface[e4073cecbcc8453d]::util::run_in_thread_pool_with_globals<rustc_interface[e4073cecbcc8453d]::interface::run_compiler<(), rustc_driver_impl[8b54d5bb9fab87c3]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[38febd7418bd713c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
25: 0x7fe3f57630ac - <std[f3c9ac17ed98d4bf]::sys::thread::unix::Thread>::new::thread_start
26: 0x7fe3eec981b9 - <unknown>
27: 0x7fe3eed1d21c - <unknown>
28: 0x0 - <unknown>
error: the compiler unexpectedly panicked. This is a bug
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-06-03T05_41_54-231792.txt` to your bug report
note: rustc 1.98.0-nightly (6bdf43094 2026-06-01) running on x86_64-unknown-linux-gnu
note: compiler flags: -C link-dead-code=true -Z codegen-backend=cranelift
query stack during panic:
end of query stack
fn std::future::async_drop_in_place::{closure#0}(_1: std::pin::Pin<&mut {async fn body of std::future::async_drop_in_place<{static coroutine@code.rs:6:9: 6:23}>()}>, _2: u8) -> std::task::Poll<()> {
let mut _0: std::task::Poll<()>;
scope 1 {
}
bb0: {
_0 = std::task::Poll::<()>::Ready(const ());
return;
}
}
warning: 3 warnings emitted
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided Rust program and compiler flags, then inspect compiler/rustc_codegen_cranelift/src/value_and_place.rs around the assert_assignable failure at line 512. Trace the Cranelift handling of the async_drop coroutine and its incompatible assignment. Done means this reproducer no longer causes the compiler to panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100