diff --git a/src/comment.rs b/src/comment.rs index 35ff88d86d1..d332c354b12 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -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..] diff --git a/src/expr.rs b/src/expr.rs index 7cebf793c60..ab6bcb53e5a 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -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'); diff --git a/src/imports.rs b/src/imports.rs index d506fb583b4..69249a4522d 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -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) } diff --git a/src/patterns.rs b/src/patterns.rs index 544285ec213..03afe2d81b1 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -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(); diff --git a/src/types.rs b/src/types.rs index 5505966f818..57a09a91501 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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) } diff --git a/tests/target/chains-visual.rs b/tests/target/chains-visual.rs index c2aecd26105..cfd7192b8b4 100644 --- a/tests/target/chains-visual.rs +++ b/tests/target/chains-visual.rs @@ -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 {