]> git.lizzy.rs Git - rust.git/commitdiff
Fixup formatting
authorNick Cameron <ncameron@mozilla.com>
Sun, 14 Oct 2018 22:52:27 +0000 (11:52 +1300)
committerNick Cameron <ncameron@mozilla.com>
Sun, 14 Oct 2018 22:52:27 +0000 (11:52 +1300)
src/expr.rs
src/lists.rs
src/macros.rs
src/pairs.rs
src/string.rs
src/utils.rs

index 8a5b3de7a147756f066b2577cf9c38e076630392..47777e4c5c484dcdaa9f76c5612eaaace2876307 100644 (file)
@@ -898,10 +898,11 @@ fn rewrite_cond(
             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));
                 }
index 57f778896d3002020c89db427060b20fe99e77bc..6005ae6fd259a429db2d41c8070da685655381b6 100644 (file)
@@ -146,10 +146,12 @@ pub fn inner_as_ref(&self) -> &str {
     }
 
     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 {
index dab27d8a073bf08930fd0bbc6cb37a5290a03306..49f4a03ee1db8a7afecdf7f05e8eb8186b6817df 100644 (file)
@@ -1168,22 +1168,24 @@ 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)
-                    }
-                    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)
+                        }
+                        None => String::new(),
+                    },
+                )
+                .collect::<Vec<_>>()
+                .join("\n"),
     )
 }
 
index c4451a8e466093cff12969ac2fd9cf7f4f901c89..79ae3081f1f8886dffbb11642e9c3b536f38d09f 100644 (file)
@@ -204,11 +204,12 @@ pub(crate) fn rewrite_pair<LHS, RHS>(
         // If the length of the lhs is equal to or shorter than the tab width or
         // the rhs looks like block expression, we put the rhs on the same
         // line with the lhs even if the rhs is multi-lined.
-        let allow_same_line = lhs_result.len() <= tab_spaces || rhs_result
-            .lines()
-            .next()
-            .map(|first_line| first_line.ends_with('{'))
-            .unwrap_or(false);
+        let allow_same_line = lhs_result.len() <= tab_spaces
+            || rhs_result
+                .lines()
+                .next()
+                .map(|first_line| first_line.ends_with('{'))
+                .unwrap_or(false);
         if !rhs_result.contains('\n') || allow_same_line {
             let one_line_width = last_line_width(&lhs_result)
                 + pp.infix.len()
@@ -308,10 +309,7 @@ fn flatten(&self, same_op: bool) -> Option<PairList<ast::Expr>> {
         }
 
         assert_eq!(list.len() - 1, separators.len());
-        Some(PairList {
-            list,
-            separators,
-        })
+        Some(PairList { list, separators })
     }
 }
 
index 2fe13db2139cf46d1077af470c9be1dacbedc2a4..b3f6daadfac6d2ff50c3542b41731fc710b6626d 100644 (file)
@@ -287,11 +287,12 @@ fn break_string(max_chars: usize, trim_end: bool, line_end: &str, input: &[&str]
         return break_at(max_chars - 1);
     }
     if let Some(url_index_end) = detect_url(input, max_chars) {
-        let index_plus_ws = url_index_end + input[url_index_end..]
-            .iter()
-            .skip(1)
-            .position(|grapheme| not_whitespace_except_line_feed(grapheme))
-            .unwrap_or(0);
+        let index_plus_ws = url_index_end
+            + input[url_index_end..]
+                .iter()
+                .skip(1)
+                .position(|grapheme| not_whitespace_except_line_feed(grapheme))
+                .unwrap_or(0);
         return if trim_end {
             SnippetState::LineEnd(
                 input[..=url_index_end].join("").to_string(),
index 63b238a781761d8e73f7684b445ef9df6e3a3f7b..421ab38e3f839be435015ccef6bfe7c8b225920a 100644 (file)
@@ -324,10 +324,11 @@ 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.source_map.lookup_line_range($span))
+        !$self.config.file_lines().is_all()
+            && !$self
+                .config
+                .file_lines()
+                .intersects(&$self.source_map.lookup_line_range($span))
     };
 }