]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/escape_analysis.rs
Auto merge of #4478 - tsurai:master, r=flip1995
[rust.git] / tests / ui / escape_analysis.rs
index f582596eb56a429802f8de43583bdd60af173063..78d332c7a31c9e48432fd98010f19afd11767ff9 100644 (file)
@@ -21,7 +21,7 @@ fn bar(&self) {
 
 fn main() {}
 
-fn ok_box_trait(boxed_trait: &Box<Z>) {
+fn ok_box_trait(boxed_trait: &Box<dyn Z>) {
     let boxed_local = boxed_trait;
     // done
 }
@@ -148,3 +148,23 @@ trait MyTrait {
 impl<T> MyTrait for Box<T> {
     fn do_sth(self) {}
 }
+
+// Issue #3739 - capture in closures
+mod issue_3739 {
+    use super::A;
+
+    fn consume<T>(_: T) {}
+    fn borrow<T>(_: &T) {}
+
+    fn closure_consume(x: Box<A>) {
+        let _ = move || {
+            consume(x);
+        };
+    }
+
+    fn closure_borrow(x: Box<A>) {
+        let _ = || {
+            borrow(&x);
+        };
+    }
+}