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,
context,
shape,
)
{
) {
// If the first line of the last method does not fit into a single line
// after the others, allow new lines.
almost_total + first_line_width(&last[0]) < context.config.max_width()

View file

@ -588,8 +588,7 @@ pub fn format_impl(
&result,
&where_clause_str,
&item,
))
{
)) {
result.push_str(&where_clause_str);
if where_clause_str.contains('\n') {
let white_space = offset.to_string(context.config);
@ -736,8 +735,7 @@ fn format_impl_ref_and_type(
true,
polarity_str,
result_len,
)
{
) {
result.push_str(&trait_ref_str);
} else {
let generics_str = try_opt!(rewrite_generics_inner(
@ -2114,8 +2112,7 @@ fn rewrite_fn_base(
!has_braces,
put_args_in_block && ret_str.is_empty(),
Some(span.hi),
)
{
) {
if !where_clause_str.contains('\n') {
if last_line_width(&result) + where_clause_str.len() > context.config.max_width() {
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 {
Some(ref internal_string) if internal_string == "_" => true,
_ => false,
})
{
}) {
suffix_len += 1;
if item.pre_comment.is_some() || item.post_comment.is_some() {

View file

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