Fix negative overflow and missing '..' on struct lit base exprs
This commit is contained in:
parent
ce2c4f6be6
commit
9bd502ad54
3 changed files with 23 additions and 3 deletions
11
src/expr.rs
11
src/expr.rs
|
@ -1108,9 +1108,14 @@ fn rewrite_struct_lit<'a>(context: &RewriteContext,
|
|||
}
|
||||
StructLitField::Base(ref expr) => {
|
||||
// 2 = ..
|
||||
expr.rewrite(inner_context, h_budget - 2, indent + 2)
|
||||
.map(|s| format!("..{}", s))
|
||||
.unwrap_or(context.snippet(expr.span))
|
||||
format!("..{}",
|
||||
h_budget.checked_sub(2)
|
||||
.and_then(|h_budget| {
|
||||
expr.rewrite(inner_context,
|
||||
h_budget,
|
||||
indent + 2)
|
||||
})
|
||||
.unwrap_or(context.snippet(expr.span)))
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue