]> git.lizzy.rs Git - rust.git/commitdiff
Use offset_left instead of shrink_left
authorSeiichi Uchida <seuchida@gmail.com>
Wed, 19 Jul 2017 13:50:28 +0000 (22:50 +0900)
committerSeiichi Uchida <seuchida@gmail.com>
Wed, 19 Jul 2017 15:41:36 +0000 (00:41 +0900)
src/chains.rs
src/comment.rs
src/expr.rs
src/items.rs
tests/target/expr.rs
tests/target/issue-1239.rs

index fdf0a80709b3f418e69406aab9d88a58f2e2f387..5c98308e40c09a3807b06fea87b2dce5f1c4de7c 100644 (file)
@@ -561,7 +561,7 @@ fn choose_first_connector<'a>(
     if subexpr_list.is_empty() {
         ""
     } else if extend || subexpr_list.last().map_or(false, is_try) ||
-               is_extendable_parent(context, parent_str)
+        is_extendable_parent(context, parent_str)
     {
         // 1 = ";", being conservative here.
         if last_line_width(parent_str) + first_line_width(first_child_str) + 1 <=
index b3fd171b86f1f06c01f37dc9917020f8dbb63102..35ff88d86d1b20c970ed3be53f47084d5ffd9af7 100644 (file)
@@ -124,7 +124,7 @@ fn comment_style(orig: &str, normalize_comments: bool) -> CommentStyle {
             CommentStyle::DoubleSlash
         }
     } else if (orig.starts_with("///") && orig.chars().nth(3).map_or(true, |c| c != '/')) ||
-               (orig.starts_with("/**") && !orig.starts_with("/**/"))
+        (orig.starts_with("/**") && !orig.starts_with("/**/"))
     {
         CommentStyle::TripleSlash
     } else if orig.starts_with("//!") || orig.starts_with("/*!") {
@@ -314,13 +314,13 @@ 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.starts_with("/**") && !line.starts_with("/**/"))
     {
         &line[3..]
     } else if line.starts_with("/*") || line.starts_with("* ") || line.starts_with("//") ||
-               line.starts_with("**")
+        line.starts_with("**")
     {
         &line[2..]
     } else if line.starts_with('*') {
@@ -795,7 +795,7 @@ fn remove_comment_header(comment: &str) -> &str {
     } else if comment.starts_with("//") {
         &comment[2..]
     } else if (comment.starts_with("/**") && !comment.starts_with("/**/")) ||
-               comment.starts_with("/*!")
+        comment.starts_with("/*!")
     {
         &comment[3..comment.len() - 2]
     } else {
index 09220e9ac80c587d5e6f8b2a4774f36221da8d1c..896ecebb68e789896fce41593ca0a0568a7af640 100644 (file)
@@ -375,7 +375,7 @@ pub fn rewrite_pair<LHS, RHS>(
                 }
 
                 // Try rewriting the rhs into the remaining space.
-                let rhs_shape = shape.shrink_left(last_line_width(&result) + suffix.len());
+                let rhs_shape = shape.offset_left(last_line_width(&result) + suffix.len());
                 if let Some(rhs_shape) = rhs_shape {
                     if let Some(rhs_result) = rhs.rewrite(context, rhs_shape) {
                         // FIXME this should always hold.
@@ -572,7 +572,7 @@ fn rewrite_closure_fn_decl(
 
     // 1 = |
     let argument_offset = nested_shape.indent + 1;
-    let arg_shape = try_opt!(nested_shape.shrink_left(1)).visual_indent(0);
+    let arg_shape = try_opt!(nested_shape.offset_left(1)).visual_indent(0);
     let ret_str = try_opt!(fn_decl.output.rewrite(context, arg_shape));
 
     let arg_items = itemize_list(
@@ -1168,7 +1168,7 @@ fn rewrite_cond(
         let constr_shape = if self.nested_if {
             // We are part of an if-elseif-else chain. Our constraints are tightened.
             // 7 = "} else " .len()
-            try_opt!(shape.shrink_left(7))
+            try_opt!(shape.offset_left(7))
         } else {
             shape
         };
@@ -1243,7 +1243,7 @@ fn rewrite_cond(
         let block_sep = if self.cond.is_none() && between_kwd_cond_comment.is_some() {
             ""
         } else if context.config.control_brace_style() == ControlBraceStyle::AlwaysNextLine ||
-                   force_newline_brace
+            force_newline_brace
         {
             alt_block_sep
         } else {
@@ -2573,7 +2573,7 @@ enum StructLitField<'a> {
             }
             StructLitField::Base(expr) => {
                 // 2 = ..
-                expr.rewrite(context, try_opt!(v_shape.shrink_left(2)))
+                expr.rewrite(context, try_opt!(v_shape.offset_left(2)))
                     .map(|s| format!("..{}", s))
             }
         };
index aa83d9a2b0dcfcd4bc1eda7cd8ba40136e832bce..4e989fe64e2aa6d2f70533c2c0584fedaa9ec984 100644 (file)
@@ -280,7 +280,7 @@ pub fn rewrite_fn(
         if force_newline_brace {
             newline_brace = true;
         } else if self.config.fn_brace_style() != BraceStyle::AlwaysNextLine &&
-                   !result.contains('\n')
+            !result.contains('\n')
         {
             newline_brace = false;
         }
index 26963540fcca036a69897b455f30a8371a2ad759..4d8ab906789b5155928b997724c69458f2d6db83 100644 (file)
@@ -351,7 +351,7 @@ fn complex_if_else() {
     {
         ha();
     } else if xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +
-               xxxxxxxxx
+        xxxxxxxxx
     {
         yo();
     }
index 8db0d195ae6a8f2441eac2cc725be42552a89232..6b5163cf7963c26b3e7e3ab7bcc72e60c0211087 100644 (file)
@@ -4,8 +4,8 @@ fn foo() {
         condition__uses_alignment_for_first_if__2
     {
     } else if condition__no_alignment_for_later_else__0 ||
-               condition__no_alignment_for_later_else__1 ||
-               condition__no_alignment_for_later_else__2
+        condition__no_alignment_for_later_else__1 ||
+        condition__no_alignment_for_later_else__2
     {
     };
 }