Avoid overflow

This commit is contained in:
topecongiro 2017-06-14 00:06:48 +09:00
parent bb215e2b89
commit c4d84b44ba
2 changed files with 8 additions and 4 deletions

@ -1684,7 +1684,7 @@ fn rewrite_explicit_self(
Some(ref l) => {
let lifetime_str = try_opt!(l.rewrite(
context,
Shape::legacy(usize::max_value(), Indent::empty()),
Shape::legacy(context.config.max_width(), Indent::empty()),
));
Some(format!("&{} {}self", lifetime_str, mut_str))
}
@ -1697,7 +1697,7 @@ fn rewrite_explicit_self(
let mutability = explicit_self_mutability(&args[0]);
let type_str = try_opt!(ty.rewrite(
context,
Shape::legacy(usize::max_value(), Indent::empty()),
Shape::legacy(context.config.max_width(), Indent::empty()),
));
Some(format!(

@ -148,8 +148,12 @@ impl Indent {
}
pub fn block_unindent(mut self, config: &Config) -> Indent {
self.block_indent -= config.tab_spaces();
self
if self.block_indent < config.tab_spaces() {
Indent::new(self.block_indent, 0)
} else {
self.block_indent -= config.tab_spaces();
self
}
}
pub fn width(&self) -> usize {