]> git.lizzy.rs Git - rust.git/commitdiff
Format source codes and update tests
authortopecongiro <seuchida@gmail.com>
Wed, 26 Jul 2017 08:43:17 +0000 (17:43 +0900)
committertopecongiro <seuchida@gmail.com>
Wed, 26 Jul 2017 08:43:17 +0000 (17:43 +0900)
src/comment.rs
src/expr.rs
src/imports.rs
src/patterns.rs
src/types.rs
tests/target/chains-visual.rs

index 35ff88d86d1b20c970ed3be53f47084d5ffd9af7..d332c354b12eac17887f2b9666890ff42bf7399e 100644 (file)
@@ -314,8 +314,8 @@ fn left_trim_comment_line<'a>(line: &'a str, style: &CommentStyle) -> &'a str {
             &line[opener.trim_right().len()..]
         }
     } else if line.starts_with("/* ") || line.starts_with("// ") || line.starts_with("//!") ||
-        line.starts_with("///") ||
-        line.starts_with("** ") || line.starts_with("/*!") ||
+        line.starts_with("///") || line.starts_with("** ") ||
+        line.starts_with("/*!") ||
         (line.starts_with("/**") && !line.starts_with("/**/"))
     {
         &line[3..]
index 7cebf793c600b97dbc1128102280d3d1da3a55a5..ab6bcb53e5ad4b9dd0449bd3bde0211151ba88bb 100644 (file)
@@ -657,8 +657,8 @@ fn rewrite_closure(
         }
 
         // Figure out if the block is necessary.
-        let needs_block = block.rules != ast::BlockCheckMode::Default ||
-            block.stmts.len() > 1 || context.inside_macro ||
+        let needs_block = block.rules != ast::BlockCheckMode::Default || block.stmts.len() > 1 ||
+            context.inside_macro ||
             block_contains_comment(block, context.codemap) ||
             prefix.contains('\n');
 
index d506fb583b4bb1500b4316e3e104a6706abdff21..69249a4522d3356300db231324baf15287be48b1 100644 (file)
@@ -482,18 +482,18 @@ fn rewrite_use_list(
     };
     let list_str = try_opt!(write_list(&items[first_index..], &fmt));
 
-    let result =
-        if list_str.contains('\n') && context.config.imports_indent() == IndentStyle::Block {
-            format!(
-                "{}{{\n{}{}\n{}}}",
-                path_str,
-                nested_shape.indent.to_string(context.config),
-                list_str,
-                shape.indent.to_string(context.config)
-            )
-        } else {
-            format!("{}{{{}}}", path_str, list_str)
-        };
+    let result = if list_str.contains('\n') && context.config.imports_indent() == IndentStyle::Block
+    {
+        format!(
+            "{}{{\n{}{}\n{}}}",
+            path_str,
+            nested_shape.indent.to_string(context.config),
+            list_str,
+            shape.indent.to_string(context.config)
+        )
+    } else {
+        format!("{}{{{}}}", path_str, list_str)
+    };
     Some(result)
 }
 
index 544285ec213beb87fbc04d9c9418ef7209153d97..03afe2d81b12230ead6036a1a5fede59962580c8 100644 (file)
@@ -291,17 +291,17 @@ fn rewrite_tuple_pat(
     }
 
     let wildcard_suffix_len = count_wildcard_suffix_len(context, &pat_vec, span, shape);
-    let (pat_vec, span) =
-        if context.config.condense_wildcard_suffixes() && wildcard_suffix_len >= 2 {
-            let new_item_count = 1 + pat_vec.len() - wildcard_suffix_len;
-            let sp = pat_vec[new_item_count - 1].span();
-            let snippet = context.snippet(sp);
-            let lo = sp.lo + BytePos(snippet.find_uncommented("_").unwrap() as u32);
-            pat_vec[new_item_count - 1] = TuplePatField::Dotdot(mk_sp(lo, lo + BytePos(1)));
-            (&pat_vec[..new_item_count], mk_sp(span.lo, lo + BytePos(1)))
-        } else {
-            (&pat_vec[..], span)
-        };
+    let (pat_vec, span) = if context.config.condense_wildcard_suffixes() && wildcard_suffix_len >= 2
+    {
+        let new_item_count = 1 + pat_vec.len() - wildcard_suffix_len;
+        let sp = pat_vec[new_item_count - 1].span();
+        let snippet = context.snippet(sp);
+        let lo = sp.lo + BytePos(snippet.find_uncommented("_").unwrap() as u32);
+        pat_vec[new_item_count - 1] = TuplePatField::Dotdot(mk_sp(lo, lo + BytePos(1)));
+        (&pat_vec[..new_item_count], mk_sp(span.lo, lo + BytePos(1)))
+    } else {
+        (&pat_vec[..], span)
+    };
 
     // add comma if `(x,)`
     let add_comma = path_str.is_none() && pat_vec.len() == 1 && dotdot_pos.is_none();
index 5505966f818ced17fa564790802fa9f01df91b1a..57a09a91501d89c1dace4364cfd2833511a28592 100644 (file)
@@ -632,13 +632,13 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
                 Shape::legacy(max_path_width, shape.indent + extra_offset),
             ));
 
-            Some(if context.config.spaces_within_angle_brackets() &&
-                lifetime_str.len() > 0
-            {
-                format!("for< {} > {}", lifetime_str, path_str)
-            } else {
-                format!("for<{}> {}", lifetime_str, path_str)
-            })
+            Some(
+                if context.config.spaces_within_angle_brackets() && lifetime_str.len() > 0 {
+                    format!("for< {} > {}", lifetime_str, path_str)
+                } else {
+                    format!("for<{}> {}", lifetime_str, path_str)
+                },
+            )
         } else {
             self.trait_ref.rewrite(context, shape)
         }
index c2aecd26105ef6135d2f5cd0440de1c3e6c497b9..cfd7192b8b4a030347c4239a1653a74f8be7f42f 100644 (file)
@@ -119,10 +119,10 @@ fn floaters() {
     .quux();
 
     a + match x {
-        true => "yay!",
-        false => "boo!",
-    }
-    .bar()
+            true => "yay!",
+            false => "boo!",
+        }
+        .bar()
 }
 
 fn is_replaced_content() -> bool {