]> git.lizzy.rs Git - rust.git/blobdiff - tests/target/closure.rs
Add a test
[rust.git] / tests / target / closure.rs
index c94d98b3dda5d26d86d4590fce3541e7ab34cdc2..2005d85bf175fc26f088ba64f7fc64d57045e1de 100644 (file)
@@ -4,13 +4,17 @@
 fn main() {
     let square = (|i: i32| i * i);
 
-    let commented =
-        |// first
-         a, // argument
-         // second
-         b: WithType, // argument
-         // ignored
-         _| (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
+    let commented = |// first
+                     a, // argument
+                     // second
+                     b: WithType, // argument
+                     // ignored
+                     _| {
+        (
+            aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+            bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+        )
+    };
 
     let block_body = move |xxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
                            ref yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy| {
@@ -20,9 +24,9 @@ fn main() {
     let loooooooooooooong_name = |field| {
         // format comments.
         if field.node.attrs.len() > 0 {
-            field.node.attrs[0].span.lo
+            field.node.attrs[0].span.lo()
         } else {
-            field.span.lo
+            field.span.lo()
         }
     };
 
@@ -56,7 +60,17 @@ fn main() {
     |arg1, arg2, _, _, arg3, arg4| {
         let temp = arg4 + arg3;
         arg2 * arg1 - temp
-    }
+    };
+
+    let block_body_with_comment = args.iter().map(|a| {
+        // Emitting only dep-info is possible only for final crate type, as
+        // as others may emit required metadata for dependent crate types
+        if a.starts_with("--emit") && is_final_crate_type && !self.workspace_mode {
+            "--emit=dep-info"
+        } else {
+            a
+        }
+    });
 }
 
 fn issue311() {
@@ -90,10 +104,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
     pub fn eq_expr(&self, left: &Expr, right: &Expr) -> bool {
         match (&left.node, &right.node) {
             (&ExprBinary(l_op, ref ll, ref lr), &ExprBinary(r_op, ref rl, ref rr)) => {
-                l_op.node == r_op.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr) ||
-                swap_binop(l_op.node, ll, lr).map_or(false, |(l_op, ll, lr)| {
-                    l_op == r_op.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
-                })
+                l_op.node == r_op.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
+                    || swap_binop(l_op.node, ll, lr).map_or(false, |(l_op, ll, lr)| {
+                        l_op == r_op.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
+                    })
             }
         }
     }
@@ -101,10 +115,10 @@ pub fn eq_expr(&self, left: &Expr, right: &Expr) -> bool {
 
 fn foo() {
     lifetimes_iter___map(|lasdfasfd| {
-                             let hi = if l.bounds.is_empty() {
-                                 l.lifetime.span.hi
-                             };
-                         });
+        let hi = if l.bounds.is_empty() {
+            l.lifetime.span.hi()
+        };
+    });
 }
 
 fn issue1405() {
@@ -124,18 +138,77 @@ fn issue470() {
     {
         {
             {
-                let explicit_arg_decls = explicit_arguments
-                    .into_iter()
-                    .enumerate()
-                    .map(|(index, (ty, pattern))| {
-                             let lvalue = Lvalue::Arg(index as u32);
-                             block = this.pattern(block,
-                                                  argument_extent,
-                                                  hair::PatternRef::Hair(pattern),
-                                                  &lvalue);
-                             ArgDecl { ty: ty }
-                         });
+                let explicit_arg_decls = explicit_arguments.into_iter().enumerate().map(
+                    |(index, (ty, pattern))| {
+                        let lvalue = Lvalue::Arg(index as u32);
+                        block = this.pattern(
+                            block,
+                            argument_extent,
+                            hair::PatternRef::Hair(pattern),
+                            &lvalue,
+                        );
+                        ArgDecl { ty: ty }
+                    },
+                );
             }
         }
     }
 }
+
+// #1509
+impl Foo {
+    pub fn bar(&self) {
+        Some(SomeType {
+            push_closure_out_to_100_chars: iter(otherwise_it_works_ok.into_iter().map(|f| Ok(f))),
+        })
+    }
+}
+
+fn issue1329() {
+    aaaaaaaaaaaaaaaa
+        .map(|x| {
+            x += 1;
+            x
+        })
+        .filter
+}
+
+fn issue325() {
+    let f =
+        || unsafe { xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx };
+}
+
+fn issue1697() {
+    Test.func_a(
+        A_VERY_LONG_CONST_VARIABLE_NAME,
+        move |arg1, arg2, arg3, arg4| arg1 + arg2 + arg3 + arg4,
+    )
+}
+
+fn issue1694() {
+    foooooo(
+        |_referencefffffffff: _, _target_reference: _, _oid: _, _target_oid: _| {
+            format!("refs/pull/{}/merge", pr_id)
+        },
+    )
+}
+
+fn issue1713() {
+    rayon::join(
+        || recurse(left, is_less, pred, limit),
+        || recurse(right, is_less, Some(pivot), limit),
+    );
+
+    rayon::join(
+        1,
+        || recurse(left, is_less, pred, limit),
+        2,
+        || recurse(right, is_less, Some(pivot), limit),
+    );
+}
+
+fn issue2063() {
+    |ctx: Ctx<(String, String)>| -> io::Result<Response> {
+        Ok(Response::new().with_body(ctx.params.0))
+    }
+}