]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/escape_analysis.rs
iterate List by value
[rust.git] / tests / ui / escape_analysis.rs
index cc65c6e63066de499aa14c5e35251f1b92da9a34..c0a52d832c00a2793fa49252ab0bbb88c511e4c0 100644 (file)
@@ -1,14 +1,11 @@
-// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 #![feature(box_syntax)]
-#![allow(clippy::borrowed_box, clippy::needless_pass_by_value, clippy::unused_unit)]
+#![allow(
+    clippy::borrowed_box,
+    clippy::needless_pass_by_value,
+    clippy::unused_unit,
+    clippy::redundant_clone,
+    clippy::match_single_binding
+)]
 #![warn(clippy::boxed_local)]
 
 #[derive(Clone)]
@@ -30,7 +27,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
 }
@@ -157,3 +154,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);
+        };
+    }
+}