Format source codes and update tests

This commit is contained in:
topecongiro 2017-07-26 17:43:17 +09:00
parent 6b8f62fcc8
commit 38614e7af1
6 changed files with 38 additions and 38 deletions

View file

@ -314,8 +314,8 @@ 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[3..]

View file

@ -657,8 +657,8 @@ fn rewrite_closure(
}
// Figure out if the block is necessary.
let needs_block = block.rules != ast::BlockCheckMode::Default ||
block.stmts.len() > 1 || context.inside_macro ||
let needs_block = block.rules != ast::BlockCheckMode::Default || block.stmts.len() > 1 ||
context.inside_macro ||
block_contains_comment(block, context.codemap) ||
prefix.contains('\n');

View file

@ -482,18 +482,18 @@ fn rewrite_use_list(
};
let list_str = try_opt!(write_list(&items[first_index..], &fmt));
let result =
if list_str.contains('\n') && context.config.imports_indent() == IndentStyle::Block {
format!(
"{}{{\n{}{}\n{}}}",
path_str,
nested_shape.indent.to_string(context.config),
list_str,
shape.indent.to_string(context.config)
)
} else {
format!("{}{{{}}}", path_str, list_str)
};
let result = if list_str.contains('\n') && context.config.imports_indent() == IndentStyle::Block
{
format!(
"{}{{\n{}{}\n{}}}",
path_str,
nested_shape.indent.to_string(context.config),
list_str,
shape.indent.to_string(context.config)
)
} else {
format!("{}{{{}}}", path_str, list_str)
};
Some(result)
}

View file

@ -291,17 +291,17 @@ fn rewrite_tuple_pat(
}
let wildcard_suffix_len = count_wildcard_suffix_len(context, &pat_vec, span, shape);
let (pat_vec, span) =
if context.config.condense_wildcard_suffixes() && wildcard_suffix_len >= 2 {
let new_item_count = 1 + pat_vec.len() - wildcard_suffix_len;
let sp = pat_vec[new_item_count - 1].span();
let snippet = context.snippet(sp);
let lo = sp.lo + BytePos(snippet.find_uncommented("_").unwrap() as u32);
pat_vec[new_item_count - 1] = TuplePatField::Dotdot(mk_sp(lo, lo + BytePos(1)));
(&pat_vec[..new_item_count], mk_sp(span.lo, lo + BytePos(1)))
} else {
(&pat_vec[..], span)
};
let (pat_vec, span) = if context.config.condense_wildcard_suffixes() && wildcard_suffix_len >= 2
{
let new_item_count = 1 + pat_vec.len() - wildcard_suffix_len;
let sp = pat_vec[new_item_count - 1].span();
let snippet = context.snippet(sp);
let lo = sp.lo + BytePos(snippet.find_uncommented("_").unwrap() as u32);
pat_vec[new_item_count - 1] = TuplePatField::Dotdot(mk_sp(lo, lo + BytePos(1)));
(&pat_vec[..new_item_count], mk_sp(span.lo, lo + BytePos(1)))
} else {
(&pat_vec[..], span)
};
// add comma if `(x,)`
let add_comma = path_str.is_none() && pat_vec.len() == 1 && dotdot_pos.is_none();

View file

@ -632,13 +632,13 @@ impl Rewrite for ast::PolyTraitRef {
Shape::legacy(max_path_width, shape.indent + extra_offset),
));
Some(if context.config.spaces_within_angle_brackets() &&
lifetime_str.len() > 0
{
format!("for< {} > {}", lifetime_str, path_str)
} else {
format!("for<{}> {}", lifetime_str, path_str)
})
Some(
if context.config.spaces_within_angle_brackets() && lifetime_str.len() > 0 {
format!("for< {} > {}", lifetime_str, path_str)
} else {
format!("for<{}> {}", lifetime_str, path_str)
},
)
} else {
self.trait_ref.rewrite(context, shape)
}

View file

@ -119,10 +119,10 @@ fn floaters() {
.quux();
a + match x {
true => "yay!",
false => "boo!",
}
.bar()
true => "yay!",
false => "boo!",
}
.bar()
}
fn is_replaced_content() -> bool {