about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authortopecongiro <seuchida@gmail.com>2017-05-19 19:31:29 +0900
committertopecongiro <seuchida@gmail.com>2017-05-23 11:37:33 +0900
commit77a2e9858b44598454aa6240475255cd5547d519 (patch)
tree254e585d3202349e1a0bacf57eb94fd8da5843e2 /src
parentf2ec5a7bac3f8bdda148307c576f41f2ca005828 (diff)
Format source codes
Diffstat (limited to 'src')
-rw-r--r--src/expr.rs14
-rw-r--r--src/items.rs8
-rw-r--r--src/lists.rs3
-rw-r--r--src/missed_spans.rs2
-rw-r--r--src/patterns.rs2
-rw-r--r--src/types.rs42
-rw-r--r--src/visitor.rs8
7 files changed, 44 insertions, 35 deletions
diff --git a/src/expr.rs b/src/expr.rs
index 7226357f7a3..31953380a73 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -120,7 +120,7 @@ fn format_expr(expr: &ast::Expr,
                                 expr_type == ExprType::SubExpression,
                                 false,
                                 expr.span)
-                    .rewrite(context, shape)
+                .rewrite(context, shape)
         }
         ast::ExprKind::IfLet(ref pat, ref cond, ref if_block, ref else_block) => {
             ControlFlow::new_if(cond,
@@ -130,7 +130,7 @@ fn format_expr(expr: &ast::Expr,
                                 expr_type == ExprType::SubExpression,
                                 false,
                                 expr.span)
-                    .rewrite(context, shape)
+                .rewrite(context, shape)
         }
         ast::ExprKind::Match(ref cond, ref arms) => {
             rewrite_match(context, cond, arms, shape, expr.span)
@@ -372,7 +372,7 @@ pub fn rewrite_array<'a, I>(expr_iter: I,
                              |item| item.rewrite(context, nested_shape),
                              span.lo,
                              span.hi)
-            .collect::<Vec<_>>();
+        .collect::<Vec<_>>();
 
     if items.is_empty() {
         if context.config.spaces_within_square_brackets() {
@@ -716,7 +716,7 @@ impl Rewrite for ast::Stmt {
                             },
                             context,
                             try_opt!(shape.sub_width(suffix.len())))
-                        .map(|s| s + suffix)
+                    .map(|s| s + suffix)
             }
             ast::StmtKind::Mac(..) |
             ast::StmtKind::Item(..) => None,
@@ -1012,7 +1012,7 @@ impl<'a> Rewrite for ControlFlow<'a> {
                                         false,
                                         true,
                                         mk_sp(else_block.span.lo, self.span.hi))
-                            .rewrite(context, shape)
+                        .rewrite(context, shape)
                 }
                 ast::ExprKind::If(ref cond, ref if_block, ref next_else_block) => {
                     ControlFlow::new_if(cond,
@@ -1022,7 +1022,7 @@ impl<'a> Rewrite for ControlFlow<'a> {
                                         false,
                                         true,
                                         mk_sp(else_block.span.lo, self.span.hi))
-                            .rewrite(context, shape)
+                        .rewrite(context, shape)
                 }
                 _ => {
                     last_in_chain = true;
@@ -1065,7 +1065,7 @@ impl<'a> Rewrite for ControlFlow<'a> {
                                 .as_ref()
                                 .map_or(between_sep, |s| &**s),
                             after_else_comment.as_ref().map_or(after_sep, |s| &**s))
-                             .ok());
+                         .ok());
             result.push_str(&try_opt!(rewrite));
         }
 
diff --git a/src/items.rs b/src/items.rs
index 953aecb3305..f98cf9507e1 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -332,7 +332,7 @@ impl<'a> FmtVisitor<'a> {
                             let suffix = if semicolon_for_expr(e) { ";" } else { "" };
 
                             e.rewrite(&self.get_context(),
-                                         Shape::indented(self.block_indent, self.config))
+                                      Shape::indented(self.block_indent, self.config))
                                 .map(|s| s + suffix)
                                 .or_else(|| Some(self.snippet(e.span)))
                         }
@@ -376,7 +376,7 @@ impl<'a> FmtVisitor<'a> {
                                            enum_def.variants.is_empty(),
                                            self.block_indent,
                                            mk_sp(span.lo, body_start))
-                .unwrap();
+            .unwrap();
         self.buffer.push_str(&generics_str);
 
         self.last_pos = body_start;
@@ -941,7 +941,7 @@ fn format_struct_struct(context: &RewriteContext,
                      |field| field.rewrite(context, Shape::legacy(item_budget, item_indent)),
                      context.codemap.span_after(span, "{"),
                      span.hi)
-                .collect::<Vec<_>>();
+            .collect::<Vec<_>>();
     // 1 = ,
     let budget = context.config.max_width() - offset.width() + context.config.tab_spaces() - 1;
 
@@ -1295,7 +1295,7 @@ pub fn rewrite_static(prefix: &str,
                            lhs,
                            expr,
                            Shape::legacy(remaining_width, offset.block_only()))
-                .map(|s| s + ";")
+            .map(|s| s + ";")
     } else {
         let lhs = format!("{}{};", prefix, ty_str);
         Some(lhs)
diff --git a/src/lists.rs b/src/lists.rs
index a48f9a382e6..3448f8a446a 100644
--- a/src/lists.rs
+++ b/src/lists.rs
@@ -266,7 +266,8 @@ pub fn write_list<I, T>(items: I, formatting: &ListFormatting) -> Option<String>
         // Post-comments
         if tactic != DefinitiveListTactic::Vertical && item.post_comment.is_some() {
             let comment = item.post_comment.as_ref().unwrap();
-            let formatted_comment = try_opt!(rewrite_comment(comment,
+            let formatted_comment =
+                try_opt!(rewrite_comment(comment,
                                          true,
                                          Shape::legacy(formatting.shape.width, Indent::empty()),
                                          formatting.config));
diff --git a/src/missed_spans.rs b/src/missed_spans.rs
index 2f4dda2a1b4..d6157cd6a29 100644
--- a/src/missed_spans.rs
+++ b/src/missed_spans.rs
@@ -163,7 +163,7 @@ impl<'a> FmtVisitor<'a> {
                                                           Shape::legacy(comment_width,
                                                                         self.block_indent),
                                                           self.config)
-                                                 .unwrap());
+                                             .unwrap());
 
                     last_wspace = None;
                     line_start = offset + subslice.len();
diff --git a/src/patterns.rs b/src/patterns.rs
index 5dc70f6d2d8..afea0ddb299 100644
--- a/src/patterns.rs
+++ b/src/patterns.rs
@@ -293,7 +293,7 @@ fn rewrite_tuple_pat(pats: &[ptr::P<ast::Pat>],
                                          |item| item.rewrite(context, nested_shape),
                                          context.codemap.span_after(span, "("),
                                          span.hi - BytePos(1))
-            .collect();
+        .collect();
 
     // Condense wildcard string suffix into a single ..
     let wildcard_suffix_len = count_wildcard_suffix_len(&items);
diff --git a/src/types.rs b/src/types.rs
index ffa9639005a..570755d4441 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -364,7 +364,9 @@ impl Rewrite for ast::WherePredicate {
                 let colon = type_bound_colon(context);
 
                 if !bound_lifetimes.is_empty() {
-                    let lifetime_str: String = try_opt!(bound_lifetimes.iter()
+                    let lifetime_str: String =
+                        try_opt!(bound_lifetimes
+                                     .iter()
                                      .map(|lt| lt.rewrite(context, shape))
                                      .intersperse(Some(", ".to_string()))
                                      .collect());
@@ -376,14 +378,17 @@ impl Rewrite for ast::WherePredicate {
                     // 6 = "for<> ".len()
                     let used_width = lifetime_str.len() + type_str.len() + colon.len() + 6;
                     let budget = try_opt!(shape.width.checked_sub(used_width));
-                    let bounds_str: String = try_opt!(bounds.iter()
-                                                    .map(|ty_bound| {
-                                                        ty_bound.rewrite(context,
-                                                                         Shape::legacy(budget,
-                                                                         shape.indent + used_width))
-                                                    })
-                                                    .intersperse(Some(joiner.to_string()))
-                                                    .collect());
+                    let bounds_str: String =
+                        try_opt!(bounds
+                                     .iter()
+                                     .map(|ty_bound| {
+                                              ty_bound.rewrite(context,
+                                                               Shape::legacy(budget,
+                                                                             shape.indent +
+                                                                             used_width))
+                                          })
+                                     .intersperse(Some(joiner.to_string()))
+                                     .collect());
 
                     if context.config.spaces_within_angle_brackets() && lifetime_str.len() > 0 {
                         format!("for< {} > {}{}{}",
@@ -401,14 +406,17 @@ impl Rewrite for ast::WherePredicate {
                     };
                     let used_width = type_str.len() + colon.len();
                     let budget = try_opt!(shape.width.checked_sub(used_width));
-                    let bounds_str: String = try_opt!(bounds.iter()
-                                                    .map(|ty_bound| {
-                                                        ty_bound.rewrite(context,
-                                                                         Shape::legacy(budget,
-                                                                         shape.indent + used_width))
-                                                    })
-                                                    .intersperse(Some(joiner.to_string()))
-                                                    .collect());
+                    let bounds_str: String =
+                        try_opt!(bounds
+                                     .iter()
+                                     .map(|ty_bound| {
+                                              ty_bound.rewrite(context,
+                                                               Shape::legacy(budget,
+                                                                             shape.indent +
+                                                                             used_width))
+                                          })
+                                     .intersperse(Some(joiner.to_string()))
+                                     .collect());
 
                     format!("{}{}{}", type_str, colon, bounds_str)
                 }
diff --git a/src/visitor.rs b/src/visitor.rs
index 0e6817be4f7..96327ef96a7 100644
--- a/src/visitor.rs
+++ b/src/visitor.rs
@@ -282,10 +282,10 @@ impl<'a> FmtVisitor<'a> {
                                            item.span,
                                            indent,
                                            None)
-                            .map(|s| match *def {
-                                     ast::VariantData::Tuple(..) => s + ";",
-                                     _ => s,
-                                 })
+                        .map(|s| match *def {
+                                 ast::VariantData::Tuple(..) => s + ";",
+                                 _ => s,
+                             })
                 };
                 self.push_rewrite(item.span, rewrite);
             }