about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authortopecongiro <seuchida@gmail.com>2017-05-03 11:26:25 +0900
committertopecongiro <seuchida@gmail.com>2017-05-03 11:26:25 +0900
commitf5da9d779fd0e72c97823eb808e13d44ebad86fb (patch)
tree9bdf015f9dcc8a019542ee0b8a4f40adbeb59bbb /src
parente91d498b8f771ed9ddc1abbedf4d261883d4d505 (diff)
Format source codes
Diffstat (limited to 'src')
-rw-r--r--src/file_lines.rs12
-rw-r--r--src/items.rs14
-rw-r--r--src/string.rs5
-rw-r--r--src/types.rs4
4 files changed, 11 insertions, 24 deletions
diff --git a/src/file_lines.rs b/src/file_lines.rs
index f11a0aaf6e2..b52d790ed37 100644
--- a/src/file_lines.rs
+++ b/src/file_lines.rs
@@ -123,10 +123,8 @@ impl FileLines {
             Some(ref map) => map,
         };
 
-        match canonicalize_path_string(range.file_name()).and_then(|canonical| {
-                                                                       map.get_vec(&canonical)
-                                                                           .ok_or(())
-                                                                   }) {
+        match canonicalize_path_string(range.file_name())
+                  .and_then(|canonical| map.get_vec(&canonical).ok_or(())) {
             Ok(ranges) => ranges.iter().any(|r| r.contains(Range::from(range))),
             Err(_) => false,
         }
@@ -140,10 +138,8 @@ impl FileLines {
             Some(ref map) => map,
         };
 
-        match canonicalize_path_string(range.file_name()).and_then(|canonical| {
-                                                                       map.get_vec(&canonical)
-                                                                           .ok_or(())
-                                                                   }) {
+        match canonicalize_path_string(range.file_name())
+                  .and_then(|canonical| map.get_vec(&canonical).ok_or(())) {
             Ok(ranges) => ranges.iter().any(|r| r.intersects(Range::from(range))),
             Err(_) => false,
         }
diff --git a/src/items.rs b/src/items.rs
index 8ea97b177e8..0b2ca5a52cb 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -278,8 +278,7 @@ impl<'a> FmtVisitor<'a> {
             result.push(' ');
         }
 
-        self.single_line_fn(&result, block)
-            .or_else(|| Some(result))
+        self.single_line_fn(&result, block).or_else(|| Some(result))
     }
 
     pub fn rewrite_required_fn(&mut self,
@@ -912,9 +911,7 @@ fn format_struct_struct(context: &RewriteContext,
         let snippet = context.snippet(mk_sp(body_lo, span.hi - BytePos(1)));
         if snippet.trim().is_empty() {
             // `struct S {}`
-        } else if snippet
-                      .trim_right_matches(&[' ', '\t'][..])
-                      .ends_with('\n') {
+        } else if snippet.trim_right_matches(&[' ', '\t'][..]).ends_with('\n') {
             // fix indent
             result.push_str(&snippet.trim_right());
             result.push('\n');
@@ -1030,9 +1027,7 @@ fn format_tuple_struct(context: &RewriteContext,
         let snippet = context.snippet(mk_sp(body_lo, context.codemap.span_before(span, ")")));
         if snippet.is_empty() {
             // `struct S ()`
-        } else if snippet
-                      .trim_right_matches(&[' ', '\t'][..])
-                      .ends_with('\n') {
+        } else if snippet.trim_right_matches(&[' ', '\t'][..]).ends_with('\n') {
             result.push_str(&snippet.trim_right());
             result.push('\n');
             result.push_str(&offset.to_string(context.config));
@@ -1229,8 +1224,7 @@ impl Rewrite for ast::StructField {
         let type_offset = shape.indent.block_indent(context.config);
         let rewrite_type_in_next_line = || {
             let budget = try_opt!(context.config.max_width.checked_sub(type_offset.width()));
-            self.ty
-                .rewrite(context, Shape::legacy(budget, type_offset))
+            self.ty.rewrite(context, Shape::legacy(budget, type_offset))
         };
 
         let last_line_width = last_line_width(&result) + type_annotation_spacing.1.len();
diff --git a/src/string.rs b/src/string.rs
index e1e0681ba56..37a569ce67d 100644
--- a/src/string.rs
+++ b/src/string.rs
@@ -51,10 +51,7 @@ pub fn rewrite_string<'a>(orig: &str, fmt: &StringFormat<'a>) -> Option<String>
     let ender_length = fmt.line_end.len();
     // If we cannot put at least a single character per line, the rewrite won't
     // succeed.
-    let max_chars = try_opt!(shape
-                                 .width
-                                 .checked_sub(fmt.opener.len() + ender_length + 1)) +
-                    1;
+    let max_chars = try_opt!(shape.width.checked_sub(fmt.opener.len() + ender_length + 1)) + 1;
 
     // Snip a line at a time from `orig` until it is used up. Push the snippet
     // onto result.
diff --git a/src/types.rs b/src/types.rs
index ca98401db14..e2a95c66832 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -704,9 +704,9 @@ fn rewrite_bare_fn(bare_fn: &ast::BareFnTy,
                                       .lifetimes
                                       .iter()
                                       .map(|l| {
-                                               l.rewrite(context,
+            l.rewrite(context,
                       Shape::legacy(try_opt!(shape.width.checked_sub(6)), shape.indent + 4))
-                                           })
+        })
                                       .intersperse(Some(", ".to_string()))
                                       .collect::<Option<String>>()));
         result.push_str("> ");