about summary refs log tree commit diff
path: root/tests/ui/not-clone-closure.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/not-clone-closure.rs')
-rw-r--r--tests/ui/not-clone-closure.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/ui/not-clone-closure.rs b/tests/ui/not-clone-closure.rs
new file mode 100644
index 00000000000..25635bc8331
--- /dev/null
+++ b/tests/ui/not-clone-closure.rs
@@ -0,0 +1,12 @@
+// Check that closures do not implement `Clone` if their environment is not `Clone`.
+
+struct S(i32);
+
+fn main() {
+    let a = S(5);
+    let hello = move || {
+        println!("Hello {}", a.0);
+    };
+
+    let hello = hello.clone(); //~ ERROR the trait bound `S: Clone` is not satisfied
+}