]> git.lizzy.rs Git - rust.git/commitdiff
Bootstrap it. Hard.
authorMarcus Klaas <mail@marcusklaas.nl>
Thu, 12 May 2016 19:50:43 +0000 (21:50 +0200)
committerMarcus Klaas <mail@marcusklaas.nl>
Thu, 12 May 2016 19:50:43 +0000 (21:50 +0200)
18 files changed:
src/expr.rs
src/items.rs
src/lib.rs
src/lists.rs
src/patterns.rs
src/types.rs
tests/source/expr.rs
tests/source/single-line-if-else.rs
tests/source/string-lit-2.rs
tests/target/chains.rs
tests/target/closure.rs
tests/target/expr.rs
tests/target/hard-tabs.rs
tests/target/single-line-if-else.rs
tests/target/static.rs
tests/target/string-lit-2.rs
tests/target/try-conversion.rs
tests/target/type-ascription.rs

index 1edacbf765d6a1643244c902c67888d89484e90d..ebe344000148d3ce750d70def908014a1dd857f0 100644 (file)
@@ -136,14 +136,20 @@ fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Opt
                     Some(ident) => format!(" {}", ident.node),
                     None => String::new(),
                 };
-                wrap_str(format!("continue{}", id_str), context.config.max_width, width, offset)
+                wrap_str(format!("continue{}", id_str),
+                         context.config.max_width,
+                         width,
+                         offset)
             }
             ast::ExprKind::Break(ref opt_ident) => {
                 let id_str = match *opt_ident {
                     Some(ident) => format!(" {}", ident.node),
                     None => String::new(),
                 };
-                wrap_str(format!("break{}", id_str), context.config.max_width, width, offset)
+                wrap_str(format!("break{}", id_str),
+                         context.config.max_width,
+                         width,
+                         offset)
             }
             ast::ExprKind::Closure(capture, ref fn_decl, ref body, _) => {
                 rewrite_closure(capture, fn_decl, body, self.span, context, width, offset)
@@ -684,11 +690,8 @@ fn extract_comment(span: Span,
                    -> Option<String> {
     let comment_str = context.snippet(span);
     if contains_comment(&comment_str) {
-        let comment = try_opt!(rewrite_comment(comment_str.trim(),
-                                               false,
-                                               width,
-                                               offset,
-                                               context.config));
+        let comment =
+            try_opt!(rewrite_comment(comment_str.trim(), false, width, offset, context.config));
         Some(format!("\n{indent}{}\n{indent}",
                      comment,
                      indent = offset.to_string(context.config)))
@@ -788,14 +791,11 @@ fn rewrite_if_else(context: &RewriteContext,
             }
         };
 
-        let between_if_else_block = mk_sp(if_block.span.hi,
-                                          context.codemap.span_before(mk_sp(if_block.span.hi,
-                                                                            else_block.span.lo),
-                                                                      "else"));
-        let between_if_else_block_comment = extract_comment(between_if_else_block,
-                                                            &context,
-                                                            offset,
-                                                            width);
+        let between_if_else_block =
+            mk_sp(if_block.span.hi,
+                  context.codemap.span_before(mk_sp(if_block.span.hi, else_block.span.lo), "else"));
+        let between_if_else_block_comment =
+            extract_comment(between_if_else_block, &context, offset, width);
 
         let after_else = mk_sp(context.codemap
                                    .span_after(mk_sp(if_block.span.hi, else_block.span.lo),
@@ -922,11 +922,8 @@ fn rewrite_match_arm_comment(context: &RewriteContext,
     }
     let missed_str = missed_str[first..].trim();
     if !missed_str.is_empty() {
-        let comment = try_opt!(rewrite_comment(&missed_str,
-                                               false,
-                                               width,
-                                               arm_indent,
-                                               context.config));
+        let comment =
+            try_opt!(rewrite_comment(&missed_str, false, width, arm_indent, context.config));
         result.push('\n');
         result.push_str(arm_indent_str);
         result.push_str(&comment);
@@ -1150,10 +1147,9 @@ fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Opt
         let body_budget = try_opt!(width.checked_sub(context.config.tab_spaces));
         let indent = context.block_indent.block_indent(context.config);
         let inner_context = &RewriteContext { block_indent: indent, ..*context };
-        let next_line_body = try_opt!(nop_block_collapse(body.rewrite(inner_context,
-                                                                      body_budget,
-                                                                      indent),
-                                                         body_budget));
+        let next_line_body =
+            try_opt!(nop_block_collapse(body.rewrite(inner_context, body_budget, indent),
+                                        body_budget));
         let indent_str = offset.block_indent(context.config).to_string(context.config);
         let (body_prefix, body_suffix) = if context.config.wrap_match_arms {
             if context.config.match_block_trailing_comma {
@@ -1766,10 +1762,10 @@ pub fn rewrite_unary_suffix<R: Rewrite>(context: &RewriteContext,
                                         offset: Indent)
                                         -> Option<String> {
     rewrite.rewrite(context, try_opt!(width.checked_sub(suffix.len())), offset)
-           .map(|mut r| {
-               r.push_str(suffix);
-               r
-           })
+        .map(|mut r| {
+            r.push_str(suffix);
+            r
+        })
 }
 
 fn rewrite_unary_op(context: &RewriteContext,
@@ -1848,7 +1844,8 @@ fn count_line_breaks(src: &str) -> usize {
             // FIXME: DRY!
             match (rhs, new_rhs) {
                 (Some(ref orig_rhs), Some(ref replacement_rhs))
-                    if count_line_breaks(orig_rhs) > count_line_breaks(replacement_rhs) + 1 => {
+                    if count_line_breaks(orig_rhs) >
+                       count_line_breaks(replacement_rhs) + 1 => {
                     result.push_str(&format!("\n{}", new_offset.to_string(context.config)));
                     result.push_str(replacement_rhs);
                 }
index f3b4d1859a1b83fbbcbe06da94fe8d0b5ea1b125..b4b200e8b051c70230cd04fc29919e032b82a3da 100644 (file)
@@ -66,11 +66,8 @@ fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Opt
             let budget = try_opt!(width.checked_sub(context.block_indent.width() + 1));
 
             // 1 = trailing semicolon;
-            result = try_opt!(rewrite_assign_rhs(&context,
-                                                 result,
-                                                 ex,
-                                                 budget,
-                                                 context.block_indent));
+            result =
+                try_opt!(rewrite_assign_rhs(&context, result, ex, budget, context.block_indent));
         }
 
         result.push(';');
@@ -656,18 +653,17 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
 
         let has_body = !trait_items.is_empty();
 
-        let where_density = if (context.config.where_density == Density::Compressed &&
-                                (!result.contains('\n') ||
-                                 context.config.fn_args_layout == FnArgLayoutStyle::Block)) ||
-                               (context.config.fn_args_layout == FnArgLayoutStyle::Block &&
-                                result.is_empty()) ||
-                               (context.config.where_density == Density::CompressedIfEmpty &&
-                                !has_body &&
-                                !result.contains('\n')) {
-            Density::Compressed
-        } else {
-            Density::Tall
-        };
+        let where_density =
+            if (context.config.where_density == Density::Compressed &&
+                (!result.contains('\n') ||
+                 context.config.fn_args_layout == FnArgLayoutStyle::Block)) ||
+               (context.config.fn_args_layout == FnArgLayoutStyle::Block && result.is_empty()) ||
+               (context.config.where_density == Density::CompressedIfEmpty && !has_body &&
+                !result.contains('\n')) {
+                Density::Compressed
+            } else {
+                Density::Tall
+            };
 
         let where_budget = try_opt!(context.config
             .max_width
@@ -1134,9 +1130,8 @@ fn rewrite_explicit_self(explicit_self: &ast::ExplicitSelf,
             let mut_str = format_mutability(m);
             match lt {
                 Some(ref l) => {
-                    let lifetime_str = try_opt!(l.rewrite(context,
-                                                          usize::max_value(),
-                                                          Indent::empty()));
+                    let lifetime_str =
+                        try_opt!(l.rewrite(context, usize::max_value(), Indent::empty()));
                     Some(format!("&{} {}self", lifetime_str, mut_str))
                 }
                 None => Some(format!("&{}self", mut_str)),
index b825059ee208e91e9157c247a51f22de13b19f33..61ac2626e02e795c4551f3e2c94d2841ef34c8d2 100644 (file)
@@ -403,11 +403,8 @@ pub fn format_input(input: Input, config: &Config) -> (Summary, FileMap, FormatR
     let mut summary = Summary::new();
     let codemap = Rc::new(CodeMap::new());
 
-    let tty_handler = Handler::with_tty_emitter(ColorConfig::Auto,
-                                                None,
-                                                true,
-                                                false,
-                                                codemap.clone());
+    let tty_handler =
+        Handler::with_tty_emitter(ColorConfig::Auto, None, true, false, codemap.clone());
     let mut parse_session = ParseSess::with_span_handler(tty_handler, codemap.clone());
 
     let main_file = match input {
index f966e41ce99a019b7d03f9a1558c9997010d907c..b35ccfe3d699a9597979d16192a0b94b494740bb 100644 (file)
@@ -307,11 +307,8 @@ pub fn write_list<I, T>(items: I, formatting: &ListFormatting) -> Option<String>
                               comment.trim().contains('\n') ||
                               comment.trim().len() > width;
 
-            let formatted_comment = try_opt!(rewrite_comment(comment,
-                                                             block_style,
-                                                             width,
-                                                             offset,
-                                                             formatting.config));
+            let formatted_comment =
+                try_opt!(rewrite_comment(comment, block_style, width, offset, formatting.config));
 
             result.push(' ');
             result.push_str(&formatted_comment);
index ba3621fc6d523fb1c110095e24f9e8bb436272c9..4881ff76a995b97f1b01d9035daf0abcd631aa4b 100644 (file)
@@ -144,10 +144,8 @@ fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Opt
                                          |f| f.node.rewrite(context, budget, offset),
                                          context.codemap.span_after(self.span, "{"),
                                          self.span.hi);
-                let mut field_string = try_opt!(format_item_list(items,
-                                                                 budget,
-                                                                 offset,
-                                                                 context.config));
+                let mut field_string =
+                    try_opt!(format_item_list(items, budget, offset, context.config));
                 if elipses {
                     if field_string.contains('\n') {
                         field_string.push_str(",\n");
index cf65f4426b32b678ff98d14f1920186192a98b1e..0ead12a9f984a026624faa623fe798a3f10c0021 100644 (file)
@@ -375,12 +375,8 @@ fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Opt
                 // 3 = " = ".len()
                 let used_width = 3 + ty_str.len();
                 let budget = try_opt!(width.checked_sub(used_width));
-                let path_str = try_opt!(rewrite_path(context,
-                                                     false,
-                                                     None,
-                                                     path,
-                                                     budget,
-                                                     offset + used_width));
+                let path_str =
+                    try_opt!(rewrite_path(context, false, None, path, budget, offset + used_width));
                 format!("{} = {}", path_str, ty_str)
             }
         };
@@ -538,9 +534,8 @@ fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Opt
                 Some(match *lifetime {
                     Some(ref lifetime) => {
                         let lt_budget = try_opt!(width.checked_sub(2 + mut_len));
-                        let lt_str = try_opt!(lifetime.rewrite(context,
-                                                               lt_budget,
-                                                               offset + 2 + mut_len));
+                        let lt_str =
+                            try_opt!(lifetime.rewrite(context, lt_budget, offset + 2 + mut_len));
                         let lt_len = lt_str.len();
                         let budget = try_opt!(width.checked_sub(2 + mut_len + lt_len));
                         format!("&{} {}{}",
index 16953a932a3afb50879410fcc683cf1c21b85220..40fd3309a4cbb10837630920965d26c4a8a04317 100644 (file)
@@ -249,7 +249,6 @@ fn ranges() {
     let x = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa .. bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
     let y = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ... bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
     let z = ... x ;
-    let infi_range_2 = ... ;
 
     a ... b
 
index 42629ab8e37f3f23fecff129ae5dbccfdb641726..2f9c19086ff177a44c66b983d94f598254d0810d 100644 (file)
@@ -36,7 +36,7 @@ fn main() {
         do_something()
     }
 
-    let x = if veeeeeeeeery_loooooong_condition() { aaaaaaaaaaaaaaaaaaaaaaaaaaa } else { bbbbbbbbbb };
+    let x = if veeeeeeeeery_loooooong_condition() { aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa } else { bbbbbbbbbb };
   
     let x = if veeeeeeeeery_loooooong_condition()     {    aaaaaaaaaaaaaaaaaaaaaaaaa }   else  {
         bbbbbbbbbb };
index 8ba60ccac1d1269b6a312b4079ba3ab582aa0bac..c19df093176dc07a54d8ee126978e29b5086b496 100644 (file)
@@ -1,9 +1,5 @@
 fn main() -> &'static str {
-    let too_many_lines = "H\
-                          e\
-                          l\
-                          l\
-                          o";
+    let too_many_lines = "Hello";
     let leave_me = "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
                     s
                     jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj";
index 2298b5e17148250d5762b874104727d3f3d8158c..7d25046279f61299e07abf456744b7aac37370ec 100644 (file)
@@ -137,21 +137,18 @@ fn issue587() {
 fn try_shorthand() {
     let x = expr?;
     let y = expr.kaas()?.test();
-    let loooooooooooooooooooooooooooooooooooooooooong = does_this?
-                                                            .look?
-                                                            .good?
-                                                            .should_we_break?
-                                                            .after_the_first_question_mark?;
+    let loooooooooooooooooooooooooooooooooooooooooong =
+        does_this?.look?.good?.should_we_break?.after_the_first_question_mark?;
     let yyyy = expr?.another?.another?.another?.another?.another?.another?.another?.another?.test();
     let zzzz = expr?.another?.another?.another?.another?;
     let aaa = x??????????????????????????????????????????????????????????????????????????;
 
     let y = a.very
-             .loooooooooooooooooooooooooooooooooooooong()
-             .chain()
-             .inside()
-             .weeeeeeeeeeeeeee()?
-             .test()
-             .0
-             .x;
+        .loooooooooooooooooooooooooooooooooooooong()
+        .chain()
+        .inside()
+        .weeeeeeeeeeeeeee()?
+        .test()
+        .0
+        .x;
 }
index 5f40610d60318a4ef169f672ff974933a687bb82..8fe290b955a08d262502c26f7e7a469b903c6681 100644 (file)
@@ -46,23 +46,18 @@ fn main() {
         do_something_else();
     };
 
-    let arg_test = |big_argument_name, test123| {
-        looooooooooooooooooong_function_naaaaaaaaaaaaaaaaame()
-    };
+    let arg_test =
+        |big_argument_name, test123| looooooooooooooooooong_function_naaaaaaaaaaaaaaaaame();
 
-    let arg_test = |big_argument_name, test123| {
-        looooooooooooooooooong_function_naaaaaaaaaaaaaaaaame()
-    };
+    let arg_test =
+        |big_argument_name, test123| looooooooooooooooooong_function_naaaaaaaaaaaaaaaaame();
 
     let simple_closure = move || -> () {};
 
     let closure = |input: Ty| -> Option<String> { foo() };
 
-    let closure_with_return_type = |aaaaaaaaaaaaaaaaaaaaaaarg1,
-                                    aaaaaaaaaaaaaaaaaaaaaaarg2|
-                                    -> Strong {
-        "sup".to_owned()
-    };
+    let closure_with_return_type =
+        |aaaaaaaaaaaaaaaaaaaaaaarg1, aaaaaaaaaaaaaaaaaaaaaaarg2| -> Strong { "sup".to_owned() };
 
     |arg1, arg2, _, _, arg3, arg4| {
         let temp = arg4 + arg3;
index e9a051711f536e6e973198c0f9666e29429bfa7f..1378b4bf8f8da749bc1c7974f1c644f39f1a672d 100644 (file)
@@ -202,10 +202,8 @@ fn arrays() {
                                           item: 3,
                                       }]);
 
-    let z = [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
-             yyyyyyyyyyyyyyyyyyyyyyyyyyy,
-             zzzzzzzzzzzzzzzzzz,
-             q];
+    let z =
+        [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz, q];
 
     [1 + 3, 4, 5, 6, 7, 7, fncall::<Vec<_>>(3 - 1)]
 }
@@ -273,7 +271,6 @@ fn ranges() {
     let y =
         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
     let z = ...x;
-    let infi_range_2 = ...;
 
     a...b
 
index 0914959ceb104e8ec33155f39b23d7fb1ebcb3dd..1e00559b3f342d7f7a8afe2465614c5172bcd13d 100644 (file)
@@ -55,10 +55,8 @@ fn foo(a: i32,
                .go_to_next_line_with_tab()
                .go_to_next_line_with_tab();
 
-       let z = [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
-                yyyyyyyyyyyyyyyyyyyyyyyyyyy,
-                zzzzzzzzzzzzzzzzzz,
-                q];
+       let z =
+               [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz, q];
 
        fn generic<T>(arg: T) -> &SomeType
                where T: Fn(// First arg
index 27b6d773da5ff848a067ecfbecce07ad8ea4f5aa..ec4daa727a61dbcbec1abe698a185213812493ed 100644 (file)
@@ -41,7 +41,7 @@ fn main() {
     }
 
     let x = if veeeeeeeeery_loooooong_condition() {
-        aaaaaaaaaaaaaaaaaaaaaaaaaaa
+        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
     } else {
         bbbbbbbbbb
     };
index f3dbdad3e76275560be3d04f5da20f1032ded71c..f2421c1444cdfd48a6d21fbc4b1b2d9d2113ede5 100644 (file)
@@ -1,13 +1,11 @@
 const FILE_GENERIC_READ: DWORD = STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES |
                                  FILE_READ_EA | SYNCHRONIZE;
 
-static boolnames: &'static [&'static str] = &["bw", "am", "xsb", "xhp", "xenl", "eo", "gn", "hc",
-                                              "km", "hs", "in", "db", "da", "mir", "msgr", "os",
-                                              "eslok", "xt", "hz", "ul", "xon", "nxon", "mc5i",
-                                              "chts", "nrrmc", "npc", "ndscr", "ccc", "bce",
-                                              "hls", "xhpa", "crxm", "daisy", "xvpa", "sam",
-                                              "cpix", "lpix", "OTbs", "OTns", "OTnc", "OTMT",
-                                              "OTNL", "OTpt", "OTxr"];
+static boolnames: &'static [&'static str] =
+    &["bw", "am", "xsb", "xhp", "xenl", "eo", "gn", "hc", "km", "hs", "in", "db", "da", "mir",
+      "msgr", "os", "eslok", "xt", "hz", "ul", "xon", "nxon", "mc5i", "chts", "nrrmc", "npc",
+      "ndscr", "ccc", "bce", "hls", "xhpa", "crxm", "daisy", "xvpa", "sam", "cpix", "lpix",
+      "OTbs", "OTns", "OTnc", "OTMT", "OTNL", "OTpt", "OTxr"];
 
 static mut name: SomeType =
     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
index c636f878ef123ea71c0a71cb59de8e6bdf996902..7deb4215d2e59b4720b9a50b55224795ede8c43a 100644 (file)
@@ -1,9 +1,5 @@
 fn main() -> &'static str {
-    let too_many_lines = "H\
-                          e\
-                          l\
-                          l\
-                          o";
+    let too_many_lines = "Hello";
     let leave_me = "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
                     s
                     jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj";
index 2daaba88490752a0af9f9aa580a4ed602717df30..d4422cf9621412e8b12de8096ad87607006723ae 100644 (file)
@@ -4,13 +4,13 @@ fn main() {
     let x = some_expr()?;
 
     let y = a.very
-             .loooooooooooooooooooooooooooooooooooooong()
-             .chain()
-             .inside()
-             .weeeeeeeeeeeeeee()?
-             .test()
-             .0
-             .x;
+        .loooooooooooooooooooooooooooooooooooooong()
+        .chain()
+        .inside()
+        .weeeeeeeeeeeeeee()?
+        .test()
+        .0
+        .x;
 }
 
 fn test() {
index 22f037133888a9bfcc9c062cb95e85c6b3915b7a..de8d97d7b676aea7b9c35bacfd779bcbccfdc9e6 100644 (file)
@@ -1,7 +1,6 @@
 fn main() {
-    let xxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: SomeTrait<AA,
-                                                                                              BB,
-                                                                                              CC>;
+    let xxxxxxxxxxx =
+        yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: SomeTrait<AA, BB, CC>;
 
     let xxxxxxxxxxxxxxx =
         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;