]> git.lizzy.rs Git - rust.git/blobdiff - tests/target/chains.rs
Tidy up and pass tests
[rust.git] / tests / target / chains.rs
index 2720f51d5f3078c57d58d465e7fdc9921861ff18..8a41eec2bde313c8e528880be1d83b4d1c7fec56 100644 (file)
@@ -1,6 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-single_line_if_else_max_width: 0
-// rustfmt-chain_one_line_max: 100
+// rustfmt-use_small_heuristics: false
 // Test chain formatting.
 
 fn main() {
@@ -23,10 +22,12 @@ fn main() {
         false => (),
     });
 
-    loong_func().quux(move || if true {
-        1
-    } else {
-        2
+    loong_func().quux(move || {
+        if true {
+            1
+        } else {
+            2
+        }
     });
 
     some_fuuuuuuuuunction().method_call_a(aaaaa, bbbbb, |c| {
@@ -53,6 +54,14 @@ fn main() {
     let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum =
         xxxxxxx.map(|x| x + 5).map(|x| x / 2).fold(0, |acc, x| acc + x);
 
+    body.fold(Body::new(), |mut body, chunk| {
+        body.extend(chunk);
+        Ok(body)
+    }).and_then(move |body| {
+        let req = Request::from_parts(parts, body);
+        f(req).map_err(|_| io::Error::new(io::ErrorKind::Other, ""))
+    });
+
     aaaaaaaaaaaaaaaa
         .map(|x| {
             x += 1;
@@ -100,11 +109,12 @@ fn floaters() {
     }.bar()
         .baz();
 
-    Foo { x: val }
-        .baz(|| {
-            force();
-            multiline();
-        })
+    Foo {
+        x: val,
+    }.baz(|| {
+        force();
+        multiline();
+    })
         .quux();
 
     Foo {
@@ -150,9 +160,7 @@ fn try_shorthand() {
         .0
         .x;
 
-    parameterized(f, substs, def_id, Ns::Value, &[], |tcx| {
-        tcx.lookup_item_type(def_id).generics
-    })?;
+    parameterized(f, substs, def_id, Ns::Value, &[], |tcx| tcx.lookup_item_type(def_id).generics)?;
     fooooooooooooooooooooooooooo()?
         .bar()?
         .baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz()?;
@@ -183,3 +191,71 @@ fn issue1392() {
         "#.trim(),
     );
 }
+
+// #2067
+impl Settings {
+    fn save(&self) -> Result<()> {
+        let mut file = File::create(&settings_path)
+            .chain_err(|| ErrorKind::WriteError(settings_path.clone()))?;
+    }
+}
+
+fn issue2126() {
+    {
+        {
+            {
+                {
+                    {
+                        let x = self.span_from(
+                            sub_span.expect("No span found for struct arant variant"),
+                        );
+                        self.sspanpan_from_span(
+                            sub_span.expect("No span found for struct variant"),
+                        );
+                        let x = self.spanpan_from_span(
+                            sub_span.expect("No span found for struct variant"),
+                        )?;
+                    }
+                }
+            }
+        }
+    }
+}
+
+// #2200
+impl Foo {
+    pub fn from_ast(diagnostic: &::errors::Handler, attrs: &[ast::Attribute]) -> Attributes {
+        let other_attrs = attrs
+            .iter()
+            .filter_map(|attr| {
+                attr.with_desugared_doc(|attr| {
+                    if attr.check_name("doc") {
+                        if let Some(mi) = attr.meta() {
+                            if let Some(value) = mi.value_str() {
+                                doc_strings.push(DocFragment::Include(
+                                    line,
+                                    attr.span,
+                                    filename,
+                                    contents,
+                                ));
+                            }
+                        }
+                    }
+                })
+            })
+            .collect();
+    }
+}
+
+// #2415
+// Avoid orphan in chain
+fn issue2415() {
+    let base_url = (|| {
+        // stuff
+
+        Ok((|| {
+            // stuff
+            Some(value.to_string())
+        })().ok_or("")?)
+    })().unwrap_or_else(|_: Box<::std::error::Error>| String::from(""));
+}