1 // gate-test-generator_clone
2 // Verifies that non-static generators can be cloned/copied if all their upvars and locals held
3 // across awaits can be cloned/copied.
5 #![feature(generators, generator_clone)]
10 let copyable: u32 = 123;
11 let clonable_0: Vec<u32> = Vec::new();
12 let clonable_1: Vec<u32> = Vec::new();
13 let non_clonable: NonClone = NonClone;
15 let gen_copy_0 = move || {
19 check_copy(&gen_copy_0);
20 check_clone(&gen_copy_0);
21 let gen_copy_1 = move || {
34 check_copy(&gen_copy_1);
35 check_clone(&gen_copy_1);
36 let gen_clone_0 = move || {
42 check_copy(&gen_clone_0);
43 //~^ ERROR the trait bound `Vec<u32>: Copy` is not satisfied
44 //~| ERROR the trait bound `Vec<char>: Copy` is not satisfied
45 check_clone(&gen_clone_0);
46 let gen_clone_1 = move || {
58 check_copy(&gen_clone_1);
59 //~^ ERROR the trait bound `Vec<u32>: Copy` is not satisfied
60 //~| ERROR the trait bound `Vec<char>: Copy` is not satisfied
61 check_clone(&gen_clone_1);
62 let gen_non_clone = move || {
66 check_copy(&gen_non_clone);
67 //~^ ERROR the trait bound `NonClone: Copy` is not satisfied
68 check_clone(&gen_non_clone);
69 //~^ ERROR the trait bound `NonClone: Clone` is not satisfied
72 fn check_copy<T: Copy>(_x: &T) {}
73 fn check_clone<T: Clone>(_x: &T) {}