]> git.lizzy.rs Git - rust.git/blob - tests/ui/chalkify/builtin-copy-clone.rs
Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper
[rust.git] / tests / ui / chalkify / builtin-copy-clone.rs
1 // run-pass
2 // compile-flags: -Z trait-solver=chalk
3
4 // Test that `Clone` is correctly implemented for builtin types.
5
6 #[derive(Copy, Clone)]
7 struct S(#[allow(unused_tuple_struct_fields)] i32);
8
9 fn test_clone<T: Clone>(arg: T) {
10     let _ = arg.clone();
11 }
12
13 fn test_copy<T: Copy>(arg: T) {
14     let _ = arg;
15     let _ = arg;
16 }
17
18 fn test_copy_clone<T: Copy + Clone>(arg: T) {
19     test_copy(arg);
20     test_clone(arg);
21 }
22
23 fn foo() { }
24
25 fn main() {
26     // FIXME: add closures when they're considered WF
27     test_copy_clone(foo);
28     let f: fn() = foo;
29     test_copy_clone(f);
30     // FIXME(#86252): reinstate array test after chalk upgrade
31     //test_copy_clone([1; 56]);
32     test_copy_clone((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1));
33     test_copy_clone((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, true, 'a', 1.1));
34     test_copy_clone(());
35     test_copy_clone(((1, 1), (1, 1, 1), (1.1, 1, 1, 'a'), ()));
36
37     let a = (
38         (S(1), S(0)),
39         (
40             (S(0), S(0), S(1)),
41             S(0)
42         )
43     );
44     test_copy_clone(a);
45 }