mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-25 22:22:44 +00:00
Avoid an integer underflow panic. Fixes #229.
This commit is contained in:
parent
b59ab9c13f
commit
6cf74956b3
@ -1026,7 +1026,7 @@ fn rewrite_field(context: &RewriteContext,
|
||||
-> Option<String> {
|
||||
let name = &field.ident.node.to_string();
|
||||
let overhead = name.len() + 2;
|
||||
let expr = field.expr.rewrite(context, width - overhead, offset + overhead);
|
||||
let expr = field.expr.rewrite(context, try_opt!(width.checked_sub(overhead)), offset + overhead);
|
||||
expr.map(|s| format!("{}: {}", name, s))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user