Merge pull request #2173 from topecongiro/assignment-with-100-chars

Assignment whose lhs has 100 chars
This commit is contained in:
Nick Cameron 2017-12-11 17:04:41 +13:00 committed by GitHub
commit fc52a4d33f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 2 deletions

View file

@ -2764,7 +2764,11 @@ pub fn rewrite_assign_rhs<S: Into<String>, R: Rewrite>(
0
};
// 1 = space between operator and rhs.
let orig_shape = shape.offset_left(last_line_width + 1)?;
let orig_shape = shape.offset_left(last_line_width + 1).unwrap_or(Shape {
width: 0,
offset: shape.offset + last_line_width + 1,
..shape
});
let rhs = choose_rhs(context, ex, orig_shape, ex.rewrite(context, orig_shape))?;
Some(lhs + &rhs)
}

View file

@ -945,7 +945,9 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
// FIXME(#2055): rustfmt fails to format when there are comments between trait bounds.
if !type_param_bounds.is_empty() {
let ident_hi = context.codemap.span_after(item.span, &format!("{}", item.ident));
let ident_hi = context
.codemap
.span_after(item.span, &format!("{}", item.ident));
let bound_hi = type_param_bounds.last().unwrap().span().hi();
let snippet = context.snippet(mk_sp(ident_hi, bound_hi));
if contains_comment(&snippet) {

View file

@ -45,6 +45,11 @@ some_ridiculously_loooooooooooooooooooooong_function(10000 * 30000000000 + 40000
+ 2 + 3 {
}
if let ast::ItemKind::Trait(_, unsafety, ref generics, ref type_param_bounds, ref trait_items) = item.node
{
// nothing
}
let test = if true { 5 } else { 3 };
if cond() {

View file

@ -70,6 +70,12 @@ fn foo() -> bool {
) = 1 + 2 + 3
{}
if let ast::ItemKind::Trait(_, unsafety, ref generics, ref type_param_bounds, ref trait_items) =
item.node
{
// nothing
}
let test = if true { 5 } else { 3 };
if cond() {