]> git.lizzy.rs Git - rust.git/commitdiff
Format source codes and update tests
authortopecongiro <seuchida@gmail.com>
Wed, 26 Jul 2017 07:30:58 +0000 (16:30 +0900)
committertopecongiro <seuchida@gmail.com>
Wed, 26 Jul 2017 07:30:58 +0000 (16:30 +0900)
src/expr.rs
src/items.rs
src/types.rs
src/visitor.rs
tests/target/configs-control_style-rfc.rs
tests/target/expr.rs
tests/target/loop.rs

index 67214a96c60b0b80d5f1cf50bdf20d43b00a0ad3..8c8e245d2022d105714d9dddfaf1356e2da948d7 100644 (file)
@@ -334,8 +334,7 @@ fn needs_space_before_range(context: &RewriteContext, lhs: &ast::Expr) -> bool {
             shape,
         ),
         ast::ExprKind::Catch(ref block) => {
-            if let rewrite @ Some(_) =
-                rewrite_single_line_block(context, "do catch ", block, shape)
+            if let rewrite @ Some(_) = rewrite_single_line_block(context, "do catch ", block, shape)
             {
                 return rewrite;
             }
@@ -826,8 +825,7 @@ fn rewrite_empty_block(
     block: &ast::Block,
     shape: Shape,
 ) -> Option<String> {
-    if block.stmts.is_empty() && !block_contains_comment(block, context.codemap) &&
-        shape.width >= 2
+    if block.stmts.is_empty() && !block_contains_comment(block, context.codemap) && shape.width >= 2
     {
         return Some("{}".to_owned());
     }
index ac19e85a1133f551fc5d86d2ae652e6ce76dfa53..63e6eb7bc66e8a0fef1426236469b0409e9ca498 100644 (file)
@@ -2734,9 +2734,7 @@ fn format_generics(
     let shape = Shape::legacy(context.budget(used_width + offset.width()), offset);
     let mut result = try_opt!(rewrite_generics(context, generics, shape, span));
 
-    let same_line_brace = if !generics.where_clause.predicates.is_empty() ||
-        result.contains('\n')
-    {
+    let same_line_brace = if !generics.where_clause.predicates.is_empty() || result.contains('\n') {
         let budget = context
             .config
             .max_width()
index c34a3bfaa6a820116fa703b6971ae1c2af5d05fa..5505966f818ced17fa564790802fa9f01df91b1a 100644 (file)
@@ -44,12 +44,11 @@ pub fn rewrite_path(
 ) -> Option<String> {
     let skip_count = qself.map_or(0, |x| x.position);
 
-    let mut result =
-        if path.is_global() && qself.is_none() && path_context != PathContext::Import {
-            "::".to_owned()
-        } else {
-            String::new()
-        };
+    let mut result = if path.is_global() && qself.is_none() && path_context != PathContext::Import {
+        "::".to_owned()
+    } else {
+        String::new()
+    };
 
     let mut span_lo = path.span.lo;
 
index 0f7005e2856844132604b0490022432b06bd5f31..c657a4050e2160cdfc249abbc43c0735add06420 100644 (file)
@@ -328,8 +328,7 @@ pub fn visit_item(&mut self, item: &ast::Item) {
             }
             ast::ItemKind::Trait(..) => {
                 self.format_missing_with_indent(item.span.lo);
-                if let Some(trait_str) =
-                    format_trait(&self.get_context(), item, self.block_indent)
+                if let Some(trait_str) = format_trait(&self.get_context(), item, self.block_indent)
                 {
                     self.buffer.push_str(&trait_str);
                     self.last_pos = source!(self, item.span).hi;
index 8033aff208f67e274efe4a32cadd2a217f5fb294..48aa74317365b515136fe8cd84922a719e1d6ee3 100644 (file)
@@ -12,8 +12,7 @@ fn main() {
                 foo
             }
             if ai_timer.elapsed_time().as_microseconds() > ai_time.as_microseconds() {
-                if ball.position().y + ball_radius >
-                    right_paddle.position().y + paddle_size.y / 2.
+                if ball.position().y + ball_radius > right_paddle.position().y + paddle_size.y / 2.
                 {
                     foo
                 }
index dde596394a8fadc5bd9007b80011a3bfc740cb0b..661637b743e9c5a796f0c3d0f2520bf1ecd631ce 100644 (file)
@@ -346,12 +346,10 @@ fn complex_if_else() {
         ha();
     } else if xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxx {
         yo();
-    } else if let Some(x) =
-        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+    } else if let Some(x) = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
     {
         ha();
-    } else if xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +
-        xxxxxxxxx
+    } else if xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxx
     {
         yo();
     }
index 2dfbff93a65d1c238d3b878b9aab7e3533b58972..815f920a3c233cce0d15eb546f446c686fccf2fb 100644 (file)
@@ -12,9 +12,9 @@ fn main() {
         // Just comments
     }
 
-    'a: while loooooooooooooooooooooooooooooooooong_variable_name + another_value >
-        some_other_value
-    {}
+    'a: while loooooooooooooooooooooooooooooooooong_variable_name + another_value > some_other_value
+    {
+    }
 
     while aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {
     }
@@ -22,8 +22,7 @@ fn main() {
     while aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa {
     }
 
-    'b: for xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx in
-        some_iter(arg1, arg2)
+    'b: for xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx in some_iter(arg1, arg2)
     {
         // do smth
     }