Format source codes

This commit is contained in:
topecongiro 2017-06-17 21:17:20 +09:00
parent 3dcd3d7fb0
commit 91bd1fdc86
4 changed files with 7 additions and 14 deletions

View file

@ -226,8 +226,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
total_span, total_span,
context, context,
shape, shape,
) ) {
{
// If the first line of the last method does not fit into a single line // If the first line of the last method does not fit into a single line
// after the others, allow new lines. // after the others, allow new lines.
almost_total + first_line_width(&last[0]) < context.config.max_width() almost_total + first_line_width(&last[0]) < context.config.max_width()

View file

@ -588,8 +588,7 @@ pub fn format_impl(
&result, &result,
&where_clause_str, &where_clause_str,
&item, &item,
)) )) {
{
result.push_str(&where_clause_str); result.push_str(&where_clause_str);
if where_clause_str.contains('\n') { if where_clause_str.contains('\n') {
let white_space = offset.to_string(context.config); let white_space = offset.to_string(context.config);
@ -736,8 +735,7 @@ fn format_impl_ref_and_type(
true, true,
polarity_str, polarity_str,
result_len, result_len,
) ) {
{
result.push_str(&trait_ref_str); result.push_str(&trait_ref_str);
} else { } else {
let generics_str = try_opt!(rewrite_generics_inner( let generics_str = try_opt!(rewrite_generics_inner(
@ -2114,8 +2112,7 @@ fn rewrite_fn_base(
!has_braces, !has_braces,
put_args_in_block && ret_str.is_empty(), put_args_in_block && ret_str.is_empty(),
Some(span.hi), Some(span.hi),
) ) {
{
if !where_clause_str.contains('\n') { if !where_clause_str.contains('\n') {
if last_line_width(&result) + where_clause_str.len() > context.config.max_width() { if last_line_width(&result) + where_clause_str.len() > context.config.max_width() {
result.push('\n'); result.push('\n');

View file

@ -376,8 +376,7 @@ fn count_wildcard_suffix_len(
for item in items.iter().rev().take_while(|i| match i.item { for item in items.iter().rev().take_while(|i| match i.item {
Some(ref internal_string) if internal_string == "_" => true, Some(ref internal_string) if internal_string == "_" => true,
_ => false, _ => false,
}) }) {
{
suffix_len += 1; suffix_len += 1;
if item.pre_comment.is_some() || item.post_comment.is_some() { if item.pre_comment.is_some() || item.post_comment.is_some() {

View file

@ -298,8 +298,7 @@ impl<'a> FmtVisitor<'a> {
item, item,
self.block_indent, self.block_indent,
where_span_end, where_span_end,
) ) {
{
self.buffer.push_str(&impl_str); self.buffer.push_str(&impl_str);
self.last_pos = source!(self, item.span).hi; self.last_pos = source!(self, item.span).hi;
} }
@ -310,8 +309,7 @@ impl<'a> FmtVisitor<'a> {
&self.get_context(), &self.get_context(),
item, item,
self.block_indent, self.block_indent,
) ) {
{
self.buffer.push_str(&trait_str); self.buffer.push_str(&trait_str);
self.last_pos = source!(self, item.span).hi; self.last_pos = source!(self, item.span).hi;
} }