blob: 9e9b59d3633f236027fd94edcb0c850b291ac1e7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// edition:2021
// gate-test-generator_clone
// Verifies that feature(generator_clone) doesn't allow async blocks to be cloned/copied.
#![feature(generators, generator_clone)]
use std::future::ready;
struct NonClone;
fn main() {
let inner_non_clone = async {
let non_clone = NonClone;
let () = ready(()).await;
drop(non_clone);
};
check_copy(&inner_non_clone);
//~^ ERROR : Copy` is not satisfied
check_clone(&inner_non_clone);
//~^ ERROR : Clone` is not satisfied
let non_clone = NonClone;
let outer_non_clone = async move {
drop(non_clone);
};
check_copy(&outer_non_clone);
//~^ ERROR : Copy` is not satisfied
check_clone(&outer_non_clone);
//~^ ERROR : Clone` is not satisfied
let maybe_copy_clone = async move {};
check_copy(&maybe_copy_clone);
//~^ ERROR : Copy` is not satisfied
check_clone(&maybe_copy_clone);
//~^ ERROR : Clone` is not satisfied
let inner_non_clone_fn = the_inner_non_clone_fn();
check_copy(&inner_non_clone_fn);
//~^ ERROR : Copy` is not satisfied
check_clone(&inner_non_clone_fn);
//~^ ERROR : Clone` is not satisfied
let outer_non_clone_fn = the_outer_non_clone_fn(NonClone);
check_copy(&outer_non_clone_fn);
//~^ ERROR : Copy` is not satisfied
check_clone(&outer_non_clone_fn);
//~^ ERROR : Clone` is not satisfied
let maybe_copy_clone_fn = the_maybe_copy_clone_fn();
check_copy(&maybe_copy_clone_fn);
//~^ ERROR : Copy` is not satisfied
check_clone(&maybe_copy_clone_fn);
//~^ ERROR : Clone` is not satisfied
}
async fn the_inner_non_clone_fn() {
let non_clone = NonClone;
let () = ready(()).await;
drop(non_clone);
}
async fn the_outer_non_clone_fn(non_clone: NonClone) {
let () = ready(()).await;
drop(non_clone);
}
async fn the_maybe_copy_clone_fn() {}
fn check_copy<T: Copy>(_x: &T) {}
fn check_clone<T: Clone>(_x: &T) {}
|