about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Cameron <nrc@ncameron.org>2017-04-06 21:26:13 +1200
committerGitHub <noreply@github.com>2017-04-06 21:26:13 +1200
commitbdcb8d663e6b413e7a837cf5eeff5b8b78f722b6 (patch)
tree156dd174962d756aa9174006ec6a5f4b00f8db29
parentfa732ede8bd8fbce31209d5c6ecb7b0d3a966eb4 (diff)
parent8d22e85e48bf46b3056b8e0173940a8bb4f69c31 (diff)
Merge pull request #1438 from topecongiro/poor-formatting/method-chains
Lookup the last element of 'subexpr_list' instead of the first one
-rw-r--r--src/bin/cargo-fmt.rs3
-rw-r--r--src/chains.rs2
-rw-r--r--tests/source/chains-visual.rs29
-rw-r--r--tests/target/chains-visual.rs34
4 files changed, 66 insertions, 2 deletions
diff --git a/src/bin/cargo-fmt.rs b/src/bin/cargo-fmt.rs
index 0fcd0fd3f2d..ea747aa4702 100644
--- a/src/bin/cargo-fmt.rs
+++ b/src/bin/cargo-fmt.rs
@@ -199,7 +199,8 @@ fn get_targets(workspace_hitlist: WorkspaceHitlist) -> Result<Vec<Target>, std::
     // is used inside a workspace.
     // To ensure backward compatability, we only use `cargo metadata` for workspaces.
     // TODO: Is it possible only use metadata or read-manifest
-    let output = Command::new("cargo").arg("metadata")
+    let output = Command::new("cargo")
+        .arg("metadata")
         .arg("--no-deps")
         .output()?;
     if output.status.success() {
diff --git a/src/chains.rs b/src/chains.rs
index 2c2b4ef63ea..0181cd3d099 100644
--- a/src/chains.rs
+++ b/src/chains.rs
@@ -217,7 +217,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
 
     let first_connector = if extend || subexpr_list.is_empty() {
         ""
-    } else if let ast::ExprKind::Try(_) = subexpr_list[0].node {
+    } else if let ast::ExprKind::Try(_) = subexpr_list.last().unwrap().node {
         ""
     } else {
         &*connector
diff --git a/tests/source/chains-visual.rs b/tests/source/chains-visual.rs
index f0be8acdce9..198691d82b5 100644
--- a/tests/source/chains-visual.rs
+++ b/tests/source/chains-visual.rs
@@ -115,3 +115,32 @@ fn issue587() {
 
     std::mem::transmute(dl.symbol::<()>("init").unwrap())
 }
+
+fn issue_1389() {
+    let names = String::from_utf8(names)?.split('|').map(str::to_owned).collect();
+}
+
+fn issue1217() -> Result<Mnemonic, Error> {
+let random_chars: String = OsRng::new()?
+    .gen_ascii_chars()
+    .take(self.bit_length)
+    .collect();
+
+    Ok(Mnemonic::new(&random_chars))
+}
+
+fn issue1236(options: Vec<String>) -> Result<Option<String>> {
+let process = Command::new("dmenu").stdin(Stdio::piped())
+    .stdout(Stdio::piped())
+    .spawn()
+    .chain_err(|| "failed to spawn dmenu")?;
+}
+
+fn issue1434() {
+    for _ in 0..100 {
+        let prototype_id = PrototypeIdData::from_reader::<_, B>(&mut self.file_cursor).chain_err(|| {
+            format!("could not read prototype ID at offset {:#010x}",
+                    current_offset)
+        })?;
+    }
+}
diff --git a/tests/target/chains-visual.rs b/tests/target/chains-visual.rs
index 2795237d51b..2763b339084 100644
--- a/tests/target/chains-visual.rs
+++ b/tests/target/chains-visual.rs
@@ -134,3 +134,37 @@ fn issue587() {
 
     std::mem::transmute(dl.symbol::<()>("init").unwrap())
 }
+
+fn issue_1389() {
+    let names = String::from_utf8(names)?
+        .split('|')
+        .map(str::to_owned)
+        .collect();
+}
+
+fn issue1217() -> Result<Mnemonic, Error> {
+    let random_chars: String = OsRng::new()?
+        .gen_ascii_chars()
+        .take(self.bit_length)
+        .collect();
+
+    Ok(Mnemonic::new(&random_chars))
+}
+
+fn issue1236(options: Vec<String>) -> Result<Option<String>> {
+    let process = Command::new("dmenu")
+        .stdin(Stdio::piped())
+        .stdout(Stdio::piped())
+        .spawn()
+        .chain_err(|| "failed to spawn dmenu")?;
+}
+
+fn issue1434() {
+    for _ in 0..100 {
+        let prototype_id = PrototypeIdData::from_reader::<_, B>(&mut self.file_cursor)
+            .chain_err(|| {
+                           format!("could not read prototype ID at offset {:#010x}",
+                                   current_offset)
+                       })?;
+    }
+}