1
Fork 0

Fix negative overflow and missing '..' on struct lit base exprs

This commit is contained in:
Sebastian Ullrich 2015-09-20 15:18:41 +02:00
parent ce2c4f6be6
commit 9bd502ad54
3 changed files with 23 additions and 3 deletions

View file

@ -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)))
}
}
},