]> git.lizzy.rs Git - rust.git/blobdiff - tests/target/chains.rs
Do not allow single-lined closure with block body
[rust.git] / tests / target / chains.rs
index 298c79ae91a8a2be6ba1ab48795636efaf2662df..2720f51d5f3078c57d58d465e7fdc9921861ff18 100644 (file)
@@ -19,15 +19,15 @@ fn main() {
     // Test case where first chain element isn't a path, but is shorter than
     // the size of a tab.
     x().y(|| match cond() {
-              true => (),
-              false => (),
-          });
+        true => (),
+        false => (),
+    });
 
     loong_func().quux(move || if true {
-                          1
-                      } else {
-                          2
-                      });
+        1
+    } else {
+        2
+    });
 
     some_fuuuuuuuuunction().method_call_a(aaaaa, bbbbb, |c| {
         let x = c;
@@ -45,7 +45,9 @@ fn main() {
         });
 
     fffffffffffffffffffffffffffffffffff(a, {
-        SCRIPT_TASK_ROOT.with(|root| { *root.borrow_mut() = Some(&script_task); });
+        SCRIPT_TASK_ROOT.with(|root| {
+            *root.borrow_mut() = Some(&script_task);
+        });
     });
 
     let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum =
@@ -53,9 +55,9 @@ fn main() {
 
     aaaaaaaaaaaaaaaa
         .map(|x| {
-                 x += 1;
-                 x
-             })
+            x += 1;
+            x
+        })
         .filter(some_mod::some_filter)
 }
 
@@ -81,10 +83,12 @@ fn floaters() {
         match x {
             PushParam => {
                 // params are 1-indexed
-                stack.push(mparams[match cur.to_digit(10) {
-                                       Some(d) => d as usize - 1,
-                                       None => return Err("bad param number".to_owned()),
-                                   }].clone());
+                stack.push(
+                    mparams[match cur.to_digit(10) {
+                                Some(d) => d as usize - 1,
+                                None => return Err("bad param number".to_owned()),
+                            }].clone(),
+                );
             }
         }
     }
@@ -98,22 +102,21 @@ fn floaters() {
 
     Foo { x: val }
         .baz(|| {
-                 force();
-                 multiline();
-             })
+            force();
+            multiline();
+        })
         .quux();
 
     Foo {
         y: i_am_multi_line,
         z: ok,
     }.baz(|| {
-              force();
-              multiline();
-          })
+        force();
+        multiline();
+    })
         .quux();
 
-    a +
-    match x {
+    a + match x {
         true => "yay!",
         false => "boo!",
     }.bar()
@@ -163,7 +166,20 @@ fn issue_1004() {
     }?;
 
     ty::tls::with(|tcx| {
-                      let tap = ty::Binder(TraitAndProjections(principal, projections));
-                      in_binder(f, tcx, &ty::Binder(""), Some(tap))
-                  })?;
+        let tap = ty::Binder(TraitAndProjections(principal, projections));
+        in_binder(f, tcx, &ty::Binder(""), Some(tap))
+    })?;
+}
+
+fn issue1392() {
+    test_method(
+        r#"
+        if foo {
+            a();
+        }
+        else {
+            b();
+        }
+        "#.trim(),
+    );
 }