about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2019-04-22 14:35:37 -0700
committerTyler Mandry <tmandry@gmail.com>2019-04-24 15:57:03 -0700
commitc75e0890beade386ff15acdcc1028497094cd867 (patch)
tree2c4995a7540942dd97727e88cccdd1ce706f7df1 /src/test
parentb2c0fd087682c7cd61dbf44f02cefd28b0d230ed (diff)
downloadrust-c75e0890beade386ff15acdcc1028497094cd867.tar.gz
rust-c75e0890beade386ff15acdcc1028497094cd867.zip
chalkify: Add Copy/Clone builtins
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/chalkify/builtin-copy-clone.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/run-pass/chalkify/builtin-copy-clone.rs b/src/test/run-pass/chalkify/builtin-copy-clone.rs
new file mode 100644
index 00000000000..4f69714bc74
--- /dev/null
+++ b/src/test/run-pass/chalkify/builtin-copy-clone.rs
@@ -0,0 +1,43 @@
+// compile-flags: -Z chalk
+
+// Test that `Clone` is correctly implemented for builtin types.
+
+#[derive(Copy, Clone)]
+struct S(i32);
+
+fn test_clone<T: Clone>(arg: T) {
+    let _ = arg.clone();
+}
+
+fn test_copy<T: Copy>(arg: T) {
+    let _ = arg;
+    let _ = arg;
+}
+
+fn test_copy_clone<T: Copy + Clone>(arg: T) {
+    test_copy(arg);
+    test_clone(arg);
+}
+
+fn foo() { }
+
+fn main() {
+    test_copy_clone(foo);
+    let f: fn() = foo;
+    test_copy_clone(f);
+    // FIXME: add closures when they're considered WF
+    test_copy_clone([1; 56]);
+    test_copy_clone((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1));
+    test_copy_clone((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, true, 'a', 1.1));
+    test_copy_clone(());
+    test_copy_clone(((1, 1), (1, 1, 1), (1.1, 1, 1, 'a'), ()));
+
+    let a = (
+        (S(1), S(0)),
+        (
+            (S(0), S(0), S(1)),
+            S(0)
+        )
+    );
+    test_copy_clone(a);
+}