about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2018-07-06 11:58:22 +1200
committerNick Cameron <ncameron@mozilla.com>2018-07-12 21:37:28 +1200
commit486f8fd8e7b02b08832cd2bedf62afa351bdf672 (patch)
treeac92bff9feac6ae6fb5c44d7a897c3fef5e185e1 /src
parenta4cdb68925e4cb3a2df74df61da333136afae582 (diff)
Fixup formatting of tests and source
Diffstat (limited to 'src')
-rw-r--r--src/attr.rs3
-rw-r--r--src/bin/main.rs3
-rw-r--r--src/closures.rs3
-rw-r--r--src/expr.rs12
-rw-r--r--src/items.rs9
-rw-r--r--src/lists.rs9
-rw-r--r--src/macros.rs33
-rw-r--r--src/overflow.rs6
-rw-r--r--src/reorder.rs13
-rw-r--r--src/string.rs3
-rw-r--r--src/test/mod.rs3
-rw-r--r--src/utils.rs9
-rw-r--r--src/vertical.rs7
13 files changed, 60 insertions, 53 deletions
diff --git a/src/attr.rs b/src/attr.rs
index 3c545bdda70..555c0eb96e7 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -194,7 +194,8 @@ fn has_newlines_before_after_comment(comment: &str) -> (&str, &str) {
             .rev()
             .take_while(|c| c.is_whitespace())
             .filter(|&c| c == '\n')
-            .count() > 1
+            .count()
+            > 1
     };
     (if mlb { "\n" } else { "" }, if mla { "\n" } else { "" })
 }
diff --git a/src/bin/main.rs b/src/bin/main.rs
index b11e7ef18dd..cd5e58437e6 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -38,7 +38,8 @@ fn main() {
 
     let exit_code = match execute(&opts) {
         Ok((exit_mode, summary)) => {
-            if summary.has_operational_errors() || summary.has_parsing_errors()
+            if summary.has_operational_errors()
+                || summary.has_parsing_errors()
                 || ((summary.has_diff || summary.has_check_errors())
                     && exit_mode == ExitCodeMode::Check)
             {
diff --git a/src/closures.rs b/src/closures.rs
index 5e2f01053f1..42b883589db 100644
--- a/src/closures.rs
+++ b/src/closures.rs
@@ -363,7 +363,8 @@ where
                 })
                 .unwrap_or(false)
         })
-        .count() > 1
+        .count()
+        > 1
 }
 
 fn is_block_closure_forced(context: &RewriteContext, expr: &ast::Expr) -> bool {
diff --git a/src/expr.rs b/src/expr.rs
index 7f39e93b267..c4675cbcdf7 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -863,16 +863,16 @@ impl<'a> ControlFlow<'a> {
             && context
                 .config
                 .width_heuristics()
-                .single_line_if_else_max_width > 0
+                .single_line_if_else_max_width
+                > 0
         {
             let trial = self.rewrite_single_line(&pat_expr_string, context, shape.width);
 
             if let Some(cond_str) = trial {
-                if cond_str.len()
-                    <= context
-                        .config
-                        .width_heuristics()
-                        .single_line_if_else_max_width
+                if cond_str.len() <= context
+                    .config
+                    .width_heuristics()
+                    .single_line_if_else_max_width
                 {
                     return Some((cond_str, 0));
                 }
diff --git a/src/items.rs b/src/items.rs
index 84a24e7149e..00db19f3b6c 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -1382,7 +1382,8 @@ fn format_tuple_struct(
         )?;
     }
 
-    if !where_clause_str.is_empty() && !where_clause_str.contains('\n')
+    if !where_clause_str.is_empty()
+        && !where_clause_str.contains('\n')
         && (result.contains('\n')
             || offset.block_indent + result.len() + where_clause_str.len() + 1
                 > context.config.max_width())
@@ -2527,7 +2528,8 @@ fn rewrite_where_clause_rfc_style(
         && comment_before.is_empty()
         && comment_after.is_empty()
         && !preds_str.contains('\n')
-        && 6 + preds_str.len() <= shape.width || where_single_line
+        && 6 + preds_str.len() <= shape.width
+        || where_single_line
     {
         Cow::from(" ")
     } else {
@@ -2737,7 +2739,8 @@ fn format_generics(
             false,
         )?;
         result.push_str(&where_clause_str);
-        brace_pos == BracePos::ForceSameLine || brace_style == BraceStyle::PreferSameLine
+        brace_pos == BracePos::ForceSameLine
+            || brace_style == BraceStyle::PreferSameLine
             || (generics.where_clause.predicates.is_empty()
                 && trimmed_last_line_width(&result) == 1)
     } else {
diff --git a/src/lists.rs b/src/lists.rs
index d0ac21d4bba..29c7e40fb17 100644
--- a/src/lists.rs
+++ b/src/lists.rs
@@ -97,11 +97,10 @@ impl ListItem {
     }
 
     pub fn is_different_group(&self) -> bool {
-        self.inner_as_ref().contains('\n') || self.pre_comment.is_some()
-            || self
-                .post_comment
-                .as_ref()
-                .map_or(false, |s| s.contains('\n'))
+        self.inner_as_ref().contains('\n') || self.pre_comment.is_some() || self
+            .post_comment
+            .as_ref()
+            .map_or(false, |s| s.contains('\n'))
     }
 
     pub fn is_multiline(&self) -> bool {
diff --git a/src/macros.rs b/src/macros.rs
index 8468dbf1591..76f50b30a54 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -1107,23 +1107,22 @@ fn indent_macro_snippet(
         .min()?;
 
     Some(
-        first_line + "\n"
-            + &trimmed_lines
-                .iter()
-                .map(
-                    |&(trimmed, ref line, prefix_space_width)| match prefix_space_width {
-                        _ if !trimmed => line.to_owned(),
-                        Some(original_indent_width) => {
-                            let new_indent_width = indent.width()
-                                + original_indent_width.saturating_sub(min_prefix_space_width);
-                            let new_indent = Indent::from_width(context.config, new_indent_width);
-                            format!("{}{}", new_indent.to_string(context.config), line.trim())
-                        }
-                        None => String::new(),
-                    },
-                )
-                .collect::<Vec<_>>()
-                .join("\n"),
+        first_line + "\n" + &trimmed_lines
+            .iter()
+            .map(
+                |&(trimmed, ref line, prefix_space_width)| match prefix_space_width {
+                    _ if !trimmed => line.to_owned(),
+                    Some(original_indent_width) => {
+                        let new_indent_width = indent.width() + original_indent_width
+                            .saturating_sub(min_prefix_space_width);
+                        let new_indent = Indent::from_width(context.config, new_indent_width);
+                        format!("{}{}", new_indent.to_string(context.config), line.trim())
+                    }
+                    None => String::new(),
+                },
+            )
+            .collect::<Vec<_>>()
+            .join("\n"),
     )
 }
 
diff --git a/src/overflow.rs b/src/overflow.rs
index 8fccf3da735..54e594d814f 100644
--- a/src/overflow.rs
+++ b/src/overflow.rs
@@ -320,15 +320,13 @@ impl<'a, T: 'a + Rewrite + ToExpr + Spanned> Context<'a, T> {
                                     ListTactic::HorizontalVertical,
                                     Separator::Comma,
                                     self.nested_shape.width,
-                                )
-                                    == DefinitiveListTactic::Horizontal
+                                ) == DefinitiveListTactic::Horizontal
                                 && definitive_tactic(
                                     &list_items[num_args_before + 1..],
                                     ListTactic::HorizontalVertical,
                                     Separator::Comma,
                                     self.nested_shape.width,
-                                )
-                                    == DefinitiveListTactic::Horizontal;
+                                ) == DefinitiveListTactic::Horizontal;
 
                             if one_line {
                                 tactic = DefinitiveListTactic::SpecialMacro(num_args_before);
diff --git a/src/reorder.rs b/src/reorder.rs
index 9908c402a43..5947b4ae87f 100644
--- a/src/reorder.rs
+++ b/src/reorder.rs
@@ -242,12 +242,13 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
         let item_length = items
             .iter()
             .take_while(|ppi| {
-                item_kind.is_same_item_kind(&***ppi) && (!in_group || {
-                    let current = self.codemap.lookup_line_range(ppi.span());
-                    let in_same_group = current.lo < last.hi + 2;
-                    last = current;
-                    in_same_group
-                })
+                item_kind.is_same_item_kind(&***ppi)
+                    && (!in_group || {
+                        let current = self.codemap.lookup_line_range(ppi.span());
+                        let in_same_group = current.lo < last.hi + 2;
+                        last = current;
+                        in_same_group
+                    })
             })
             .count();
         let items = &items[..item_length];
diff --git a/src/string.rs b/src/string.rs
index a5453c0a8ed..39eaf57d72e 100644
--- a/src/string.rs
+++ b/src/string.rs
@@ -72,7 +72,8 @@ pub fn rewrite_string<'a>(
     // succeed.
     let mut max_chars = shape
         .width
-        .checked_sub(fmt.opener.len() + ender_length + 1)? + 1;
+        .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/test/mod.rs b/src/test/mod.rs
index 233055a067e..633f9f8bd3f 100644
--- a/src/test/mod.rs
+++ b/src/test/mod.rs
@@ -703,7 +703,8 @@ impl ConfigCodeBlock {
             .unwrap()
             .split('\n')
             .nth(0)
-            .unwrap_or("") == "#![rustfmt::skip]";
+            .unwrap_or("")
+            == "#![rustfmt::skip]";
 
         if self.config_name.is_none() && !fmt_skip {
             write_message(&format!(
diff --git a/src/utils.rs b/src/utils.rs
index a8f8592d2f2..48b71d9a84f 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -295,11 +295,10 @@ pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
 // Return true if the given span does not intersect with file lines.
 macro_rules! out_of_file_lines_range {
     ($self:ident, $span:expr) => {
-        !$self.config.file_lines().is_all()
-            && !$self
-                .config
-                .file_lines()
-                .intersects(&$self.codemap.lookup_line_range($span))
+        !$self.config.file_lines().is_all() && !$self
+            .config
+            .file_lines()
+            .intersects(&$self.codemap.lookup_line_range($span))
     };
 }
 
diff --git a/src/vertical.rs b/src/vertical.rs
index 58422d782ac..1b7fdb9be1d 100644
--- a/src/vertical.rs
+++ b/src/vertical.rs
@@ -173,11 +173,14 @@ pub fn rewrite_with_alignment<T: AlignedItem>(
         let rest_span = mk_sp(init_last_pos, span.hi());
         let rest_str = rewrite_with_alignment(rest, context, shape, rest_span, one_line_width)?;
         Some(
-            result + spaces + "\n"
+            result
+                + spaces
+                + "\n"
                 + &shape
                     .indent
                     .block_indent(context.config)
-                    .to_string(context.config) + &rest_str,
+                    .to_string(context.config)
+                + &rest_str,
         )
     }
 }