Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: Can't write value with incompatible type #1429

Closed
matthiaskrgr opened this issue Nov 22, 2023 · 2 comments
Closed

ICE: Can't write value with incompatible type #1429

matthiaskrgr opened this issue Nov 22, 2023 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@matthiaskrgr
Copy link
Member

snippet:

#![feature(adt_const_params, coroutines, coroutine_trait)]

use std::ops::Coroutine;
use std::pin::Pin;

fn main() {
    GenericStruct::<i32, i32>::impl_function();

    // Closure
    let closure = || TestStruct1;
    closure();
}

struct TestStruct1;

struct GenericStruct<T1, T2>(std::marker::PhantomData<(T1, T2)>);

impl<T1, T2> GenericStruct<T1, T2> {
    pub fn impl_function() {
        // Closure
        let closure = || TestStruct1;
        closure();

        let mut coroutine = || {
            yield;
            return;
        };
        Pin::new(&mut coroutine).resume(());
    }
}

Version information

rustc 1.76.0-nightly (739d55682 2023-11-22)
binary: rustc
commit-hash: 739d55682659e4a81db6fd83f52b2491505030ea
commit-date: 2023-11-22
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zpolymorphize=on -Zcodegen-backend=cranelift

Program output

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

thread 'rustc' panicked at src/abi/pass_mode.rs:221:5:
assertion `left == right` failed: Can't write value with incompatible type Coroutine(DefId(0:19 ~ mvce[cafd]::{impl#0}::impl_function::{closure#1}), [i32, i32, (), (), (), CoroutineWitness(DefId(0:19 ~ mvce[cafd]::{impl#0}::impl_function::{closure#1}), [i32, i32]), ()], Movable) to place with type Coroutine(DefId(0:19 ~ mvce[cafd]::{impl#0}::impl_function::{closure#1}), [T1/#0, T2/#1, (), (), (), CoroutineWitness(DefId(0:19 ~ mvce[cafd]::{impl#0}::impl_function::{closure#1}), [T1/#0, T2/#1]), ()], Movable)

[i32, i32]
[CPlace { inner: Addr(Pointer { base: Dangling(Align(8 bytes)), offset: Offset32(0) }, None), layout: TyAndLayout { ty: (), layout: Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) } } }, CPlace { inner: Addr(Pointer { base: Dangling(Align(8 bytes)), offset: Offset32(0) }, None), layout: TyAndLayout { ty: {closure@/tmp/icemaker_global_tempdir.P7Hp73Jhct5x/rustc_testrunner_tmpdir_reporting.djVsk4t1fURb/mvce.rs:21:23: 21:25}, layout: Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) } } }, CPlace { inner: Addr(Pointer { base: Dangling(Align(8 bytes)), offset: Offset32(0) }, None), layout: TyAndLayout { ty: TestStruct1, layout: Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) } } }, CPlace { inner: Var(_3, var0), layout: TyAndLayout { ty: &{closure@/tmp/icemaker_global_tempdir.P7Hp73Jhct5x/rustc_testrunner_tmpdir_reporting.djVsk4t1fURb/mvce.rs:21:23: 21:25}, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes) } } }, CPlace { inner: Addr(Pointer { base: Stack(ss0), offset: Offset32(0) }, None), layout: TyAndLayout { ty: {coroutine@/tmp/icemaker_global_tempdir.P7Hp73Jhct5x/rustc_testrunner_tmpdir_reporting.djVsk4t1fURb/mvce.rs:24:29: 24:31}, layout: Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [Size(0 bytes)], memory_index: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Int(I8, false), valid_range: 0..=3 }), variants: Multiple { tag: Initialized { value: Int(I8, false), valid_range: 0..=3 }, tag_encoding: Direct, tag_field: 0, variants: [Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) }, Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, variants: Single { index: 1 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) }, Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, variants: Single { index: 2 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) }, Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, variants: Single { index: 3 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) }] }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) } } }, CPlace { inner: Addr(Pointer { base: Stack(ss1), offset: Offset32(0) }, None), layout: TyAndLayout { ty: CoroutineState<(), ()>, layout: Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Int(I8, false), valid_range: 0..=1 }), fields: Arbitrary { offsets: [Size(0 bytes)], memory_index: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Int(I8, false), valid_range: 0..=1 }), variants: Multiple { tag: Initialized { value: Int(I8, false), valid_range: 0..=1 }, tag_encoding: Direct, tag_field: 0, variants: [Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Int(I8, false), valid_range: 0..=1 }), fields: Arbitrary { offsets: [Size(1 bytes)], memory_index: [0] }, largest_niche: None, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) }, Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Int(I8, false), valid_range: 0..=1 }), fields: Arbitrary { offsets: [Size(1 bytes)], memory_index: [0] }, largest_niche: None, variants: Single { index: 1 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) }] }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) } } }, CPlace { inner: Addr(Pointer { base: Stack(ss2), offset: Offset32(0) }, None), layout: TyAndLayout { ty: Pin<&mut {coroutine@/tmp/icemaker_global_tempdir.P7Hp73Jhct5x/rustc_testrunner_tmpdir_reporting.djVsk4t1fURb/mvce.rs:24:29: 24:31}>, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Arbitrary { offsets: [Size(0 bytes)], memory_index: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes) } } }, CPlace { inner: Var(_7, var1), layout: TyAndLayout { ty: &mut {coroutine@/tmp/icemaker_global_tempdir.P7Hp73Jhct5x/rustc_testrunner_tmpdir_reporting.djVsk4t1fURb/mvce.rs:24:29: 24:31}, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes) } } }]

function u0:12() system_v {
    ss0 = explicit_slot 16
    ss1 = explicit_slot 16
    ss2 = explicit_slot 16
    sig0 = (i64) system_v
    sig1 = (i64) -> i64 system_v
    sig2 = (i64) -> i8 system_v
    fn0 = colocated u0:13 sig0
    fn1 = colocated u0:6 sig1
    fn2 = colocated u0:14 sig2

block0:
    nop 
    jump block1

block1:
    nop 
    v0 = iconst.i64 8
    call fn0(v0)  ; v0 = 8
    jump block2

block2:
    nop 
    v1 = iconst.i8 0
    stack_store v1, ss0  ; v1 = 0
    v2 = stack_addr.i64 ss0
    v3 = call fn1(v2)
    stack_store v3, ss2
    jump block3

block3:
    nop 
}


  left: Coroutine(DefId(0:19 ~ mvce[cafd]::{impl#0}::impl_function::{closure#1}), [i32, i32, (), (), (), CoroutineWitness(DefId(0:19 ~ mvce[cafd]::{impl#0}::impl_function::{closure#1}), [i32, i32]), ()], Movable)
 right: Coroutine(DefId(0:19 ~ mvce[cafd]::{impl#0}::impl_function::{closure#1}), [T1/#0, T2/#1, (), (), (), CoroutineWitness(DefId(0:19 ~ mvce[cafd]::{impl#0}::impl_function::{closure#1}), [T1/#0, T2/#1]), ()], Movable)
stack backtrace:
   0:     0x7f1bc038aafc - std::backtrace_rs::backtrace::libunwind::trace::hdd99412eaf13ca97
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f1bc038aafc - std::backtrace_rs::backtrace::trace_unsynchronized::h1f1df4c313dbe1c3
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1bc038aafc - std::sys_common::backtrace::_print_fmt::h1ad713b770c28acc
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f1bc038aafc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0dda65360afed24d
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f1bc03ddc80 - core::fmt::rt::Argument::fmt::h566cd6272da8873e
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/core/src/fmt/rt.rs:142:9
   5:     0x7f1bc03ddc80 - core::fmt::write::h2788119addd26744
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f1bc037e9af - std::io::Write::write_fmt::h8d10386af4d8151e
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/io/mod.rs:1762:15
   7:     0x7f1bc038a8e4 - std::sys_common::backtrace::_print::h1feaac9889d696b8
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f1bc038a8e4 - std::sys_common::backtrace::print::h7dc96e4a48e84da8
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f1bc038d577 - std::panicking::default_hook::{{closure}}::h1d54e187062bebc3
  10:     0x7f1bc038d2df - std::panicking::default_hook::h05d19a5a0b9d9910
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/panicking.rs:292:9
  11:     0x7f1bc30f37e0 - std[6f3898e8c87bd7ff]::panicking::update_hook::<alloc[78dbdfc40e6e7b27]::boxed::Box<rustc_driver_impl[83f0b3fb8e850017]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f1bc038dcb8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8185fc714826c3ad
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/alloc/src/boxed.rs:2021:9
  13:     0x7f1bc038dcb8 - std::panicking::rust_panic_with_hook::h6acfd9a9aa64c3be
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/panicking.rs:783:13
  14:     0x7f1bc038da0e - std::panicking::begin_panic_handler::{{closure}}::ha6f952772803f55f
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/panicking.rs:657:13
  15:     0x7f1bc038afc6 - std::sys_common::backtrace::__rust_end_short_backtrace::hc30e18b3c4279ee2
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f1bc038d772 - rust_begin_unwind
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/panicking.rs:645:5
  17:     0x7f1bc03da365 - core::panicking::panic_fmt::h4196180d8f686081
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/core/src/panicking.rs:72:14
  18:     0x7f1bc03da9c1 - core::panicking::assert_failed_inner::h4cbe769fe7511016
  19:     0x7f1bb69b647f - core[2feb293b23a7df61]::panicking::assert_failed::<rustc_middle[7992438648c2e2f8]::ty::Ty, rustc_middle[7992438648c2e2f8]::ty::Ty>
  20:     0x7f1bb6a4cac2 - rustc_codegen_cranelift[7be5e50b9264a0ba]::value_and_place::assert_assignable
  21:     0x7f1bb6a4bf38 - rustc_codegen_cranelift[7be5e50b9264a0ba]::value_and_place::assert_assignable
  22:     0x7f1bb69f202b - rustc_codegen_cranelift[7be5e50b9264a0ba]::abi::pass_mode::adjust_arg_for_abi
  23:     0x7f1bb69e7453 - <core[2feb293b23a7df61]::iter::adapters::chain::Chain<core[2feb293b23a7df61]::iter::adapters::chain::Chain<core[2feb293b23a7df61]::option::IntoIter<cranelift_codegen[10832528869623d1]::ir::entities::Value>, core[2feb293b23a7df61]::option::IntoIter<cranelift_codegen[10832528869623d1]::ir::entities::Value>>, core[2feb293b23a7df61]::iter::adapters::flatten::FlatMap<core[2feb293b23a7df61]::iter::adapters::skip::Skip<core[2feb293b23a7df61]::iter::adapters::enumerate::Enumerate<alloc[78dbdfc40e6e7b27]::vec::into_iter::IntoIter<rustc_codegen_cranelift[7be5e50b9264a0ba]::abi::CallArgument>>>, smallvec[de4025a24e926840]::IntoIter<[cranelift_codegen[10832528869623d1]::ir::entities::Value; 2usize]>, rustc_codegen_cranelift[7be5e50b9264a0ba]::abi::codegen_terminator_call::{closure#4}::{closure#0}>> as core[2feb293b23a7df61]::iter::traits::iterator::Iterator>::next
  24:     0x7f1bb69f95cf - rustc_codegen_cranelift[7be5e50b9264a0ba]::abi::codegen_terminator_call
  25:     0x7f1bb6a01f4d - rustc_codegen_cranelift[7be5e50b9264a0ba]::base::codegen_fn_body
  26:     0x7f1bb6a17774 - rustc_codegen_cranelift[7be5e50b9264a0ba]::driver::aot::module_codegen::{closure#0}
  27:     0x7f1bb6a14a85 - rustc_codegen_cranelift[7be5e50b9264a0ba]::driver::aot::module_codegen
  28:     0x7f1bb6a2108c - rustc_codegen_cranelift[7be5e50b9264a0ba]::driver::aot::run_aot
  29:     0x7f1bb6a4d3da - <rustc_codegen_cranelift[7be5e50b9264a0ba]::CraneliftCodegenBackend as rustc_codegen_ssa[e34bdd8235ee801f]::traits::backend::CodegenBackend>::codegen_crate
  30:     0x7f1bc4d4ed57 - rustc_interface[3b5e8f3f619d352f]::passes::start_codegen
  31:     0x7f1bc4d4e729 - <rustc_interface[3b5e8f3f619d352f]::queries::Queries>::ongoing_codegen
  32:     0x7f1bc5415947 - rustc_interface[3b5e8f3f619d352f]::interface::run_compiler::<core[2feb293b23a7df61]::result::Result<(), rustc_span[4c1ba234228835d]::ErrorGuaranteed>, rustc_driver_impl[83f0b3fb8e850017]::run_compiler::{closure#0}>::{closure#0}
  33:     0x7f1bc53a6114 - std[6f3898e8c87bd7ff]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3b5e8f3f619d352f]::util::run_in_thread_with_globals<rustc_interface[3b5e8f3f619d352f]::util::run_in_thread_pool_with_globals<rustc_interface[3b5e8f3f619d352f]::interface::run_compiler<core[2feb293b23a7df61]::result::Result<(), rustc_span[4c1ba234228835d]::ErrorGuaranteed>, rustc_driver_impl[83f0b3fb8e850017]::run_compiler::{closure#0}>::{closure#0}, core[2feb293b23a7df61]::result::Result<(), rustc_span[4c1ba234228835d]::ErrorGuaranteed>>::{closure#0}, core[2feb293b23a7df61]::result::Result<(), rustc_span[4c1ba234228835d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2feb293b23a7df61]::result::Result<(), rustc_span[4c1ba234228835d]::ErrorGuaranteed>>
  34:     0x7f1bc53a5f3d - <<std[6f3898e8c87bd7ff]::thread::Builder>::spawn_unchecked_<rustc_interface[3b5e8f3f619d352f]::util::run_in_thread_with_globals<rustc_interface[3b5e8f3f619d352f]::util::run_in_thread_pool_with_globals<rustc_interface[3b5e8f3f619d352f]::interface::run_compiler<core[2feb293b23a7df61]::result::Result<(), rustc_span[4c1ba234228835d]::ErrorGuaranteed>, rustc_driver_impl[83f0b3fb8e850017]::run_compiler::{closure#0}>::{closure#0}, core[2feb293b23a7df61]::result::Result<(), rustc_span[4c1ba234228835d]::ErrorGuaranteed>>::{closure#0}, core[2feb293b23a7df61]::result::Result<(), rustc_span[4c1ba234228835d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2feb293b23a7df61]::result::Result<(), rustc_span[4c1ba234228835d]::ErrorGuaranteed>>::{closure#1} as core[2feb293b23a7df61]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7f1bc0397b75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb2144691085ad32b
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/alloc/src/boxed.rs:2007:9
  36:     0x7f1bc0397b75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf94bff3cb4476bdb
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/alloc/src/boxed.rs:2007:9
  37:     0x7f1bc0397b75 - std::sys::unix::thread::Thread::new::thread_start::hde682e6c21a35c03
                               at /rustc/739d55682659e4a81db6fd83f52b2491505030ea/library/std/src/sys/unix/thread.rs:108:17
  38:     0x7f1bc01539eb - <unknown>
  39:     0x7f1bc01d77cc - <unknown>
  40:                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: rustc 1.76.0-nightly (739d55682 2023-11-22) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z polymorphize=on -Z codegen-backend=cranelift -Z dump-mir-dir=dir

query stack during panic:
end of query stack
warning: 1 warning emitted


@matthiaskrgr matthiaskrgr changed the title ICE: `Can't write value with incompatible type ICE: Can't write value with incompatible type Nov 22, 2023
@bjorn3 bjorn3 added the C-bug Category: This is a bug. label Nov 24, 2023
@bjorn3
Copy link
Member

bjorn3 commented Nov 24, 2023

Reduced to

#![feature(coroutines, coroutine_trait)]

use std::ops::Coroutine;
use std::pin::Pin;

fn main() {
    run_coroutine::<i32>();
}

fn run_coroutine<T>() {
    let mut coroutine = || {
        yield;
        return;
    };
    Pin::new(&mut coroutine).resume(());
}

@bjorn3 bjorn3 closed this as completed in 9c95819 Nov 24, 2023
@bjorn3
Copy link
Member

bjorn3 commented Nov 24, 2023

What is happening here is that coroutine has a type with the type parameter T substituted with i32, while Coroutine::resume for it expects the self parameter to have T be polymorphized, thus causing an assignment of a coroutine value with T=i32 to a place with T=T/#0 (a type parameter). The assert_assignable check rejects this as it didn't recurse into Coroutine and CoroutineWitness to hit the code path where assigning any type to a type parameter (and vice versa) is allowed when polymorphization is enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants