]> git.lizzy.rs Git - rust.git/blobdiff - rustfmt-core/src/macros.rs
Use Indent::to_string_with_newline to avoid unnecessary allocation
[rust.git] / rustfmt-core / src / macros.rs
index 2994e1b85f276fc375139e211975756bf480cbcb..7a6e24dc6a8152781f1237867a651bc396d8d6d0 100644 (file)
@@ -250,14 +250,14 @@ pub fn rewrite_macro(
                     Some(format!("{}{}{}; {}{}", macro_name, lbr, lhs, rhs, rbr))
                 } else {
                     Some(format!(
-                        "{}{}\n{}{};\n{}{}\n{}{}",
+                        "{}{}{}{};{}{}{}{}",
                         macro_name,
                         lbr,
-                        nested_shape.indent.to_string(context.config),
+                        nested_shape.indent.to_string_with_newline(context.config),
                         lhs,
-                        nested_shape.indent.to_string(context.config),
+                        nested_shape.indent.to_string_with_newline(context.config),
                         rhs,
-                        shape.indent.to_string(context.config),
+                        shape.indent.to_string_with_newline(context.config),
                         rbr
                     ))
                 }
@@ -350,15 +350,14 @@ pub fn rewrite_macro_def(
     };
 
     if multi_branch_style {
-        result += " {\n";
-        result += &arm_shape.indent.to_string(context.config);
+        result += " {";
+        result += &arm_shape.indent.to_string_with_newline(context.config);
     }
 
     result += write_list(&branch_items, &fmt)?.as_str();
 
     if multi_branch_style {
-        result += "\n";
-        result += &indent.to_string(context.config);
+        result += &indent.to_string_with_newline(context.config);
         result += "}";
     }