2024-11-06 17:50:24 +00:00
|
|
|
//@compile-flags: --diagnostic-width=300
|
2023-10-19 21:46:28 +00:00
|
|
|
// gate-test-coroutine_clone
|
|
|
|
// Verifies that static coroutines cannot be cloned/copied.
|
2024-12-21 15:27:23 +00:00
|
|
|
// This is important: the cloned coroutine would reference state of the original
|
|
|
|
// coroutine, leading to semantic nonsense.
|
2022-03-21 05:57:10 +00:00
|
|
|
|
2024-04-11 13:15:34 +00:00
|
|
|
#![feature(coroutines, coroutine_clone, stmt_expr_attributes)]
|
2022-03-21 05:57:10 +00:00
|
|
|
|
|
|
|
fn main() {
|
2024-04-11 13:15:34 +00:00
|
|
|
let gen = #[coroutine]
|
|
|
|
static move || {
|
2022-03-21 05:57:10 +00:00
|
|
|
yield;
|
|
|
|
};
|
|
|
|
check_copy(&gen);
|
|
|
|
//~^ ERROR Copy` is not satisfied
|
|
|
|
check_clone(&gen);
|
|
|
|
//~^ ERROR Clone` is not satisfied
|
|
|
|
}
|
|
|
|
|
|
|
|
fn check_copy<T: Copy>(_x: &T) {}
|
|
|
|
fn check_clone<T: Clone>(_x: &T) {}
|