]> git.lizzy.rs Git - rust.git/blob - src/test/ui/chalkify/builtin-copy-clone.rs
Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup
[rust.git] / src / test / ui / chalkify / builtin-copy-clone.rs
1 // run-pass
2 // compile-flags: -Z chalk
3
4 // Test that `Clone` is correctly implemented for builtin types.
5
6 #[derive(Copy, Clone)]
7 struct S(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     test_copy_clone(foo);
27     let f: fn() = foo;
28     test_copy_clone(f);
29     // FIXME: add closures when they're considered WF
30     test_copy_clone([1; 56]);
31     test_copy_clone((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1));
32     test_copy_clone((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, true, 'a', 1.1));
33     test_copy_clone(());
34     test_copy_clone(((1, 1), (1, 1, 1), (1.1, 1, 1, 'a'), ()));
35
36     let a = (
37         (S(1), S(0)),
38         (
39             (S(0), S(0), S(1)),
40             S(0)
41         )
42     );
43     test_copy_clone(a);
44 }