@@ -1229,8 +1229,6 @@ impl Rewrite for ast::Arm {
1229
1229
trimmed_last_line_width( & pats_str) ) ) ;
1230
1230
1231
1231
let pats_str = format ! ( "{}{}" , pats_str, guard_str) ;
1232
- // Where the next text can start.
1233
- let line_start = trimmed_last_line_width ( & pats_str) ;
1234
1232
1235
1233
let body = match body. node {
1236
1234
ast:: ExprKind :: Block ( ref block) if !is_unsafe_block ( block) &&
@@ -1249,14 +1247,12 @@ impl Rewrite for ast::Arm {
1249
1247
let alt_block_sep = String :: from ( "\n " ) +
1250
1248
& shape. indent . block_only ( ) . to_string ( context. config ) ;
1251
1249
1250
+ let pat_width = extra_offset ( & pats_str, shape) ;
1252
1251
// Let's try and get the arm body on the same line as the condition.
1253
1252
// 4 = ` => `.len()
1254
- if shape. width > line_start + comma. len ( ) + 4 {
1253
+ if shape. width > pat_width + comma. len ( ) + 4 {
1255
1254
let arm_shape =
1256
- shape. shrink_left ( line_start + 4 ) . unwrap ( ) . sub_width ( comma. len ( ) ) . unwrap ( ) . block ( ) ;
1257
- // TODO
1258
- // let offset = Indent::new(shape.indent.block_indent,
1259
- // line_start + 4 - shape.indent.block_indent);
1255
+ shape. shrink_left ( pat_width + 4 ) . unwrap ( ) . sub_width ( comma. len ( ) ) . unwrap ( ) . block ( ) ;
1260
1256
let rewrite = nop_block_collapse ( body. rewrite ( context, arm_shape) , arm_shape. width ) ;
1261
1257
let is_block = if let ast:: ExprKind :: Block ( ..) = body. node {
1262
1258
true
@@ -1285,9 +1281,6 @@ impl Rewrite for ast::Arm {
1285
1281
1286
1282
// FIXME: we're doing a second rewrite of the expr; This may not be
1287
1283
// necessary.
1288
- // TODO
1289
- // let body_budget = try_opt!(shape.width.checked_sub(context.config.tab_spaces));
1290
- // let indent = shape.indent.block_only().block_indent(context.config);
1291
1284
let body_shape = try_opt ! ( shape. sub_width( context. config. tab_spaces) )
1292
1285
. block_indent ( context. config . tab_spaces ) ;
1293
1286
let next_line_body = try_opt ! ( nop_block_collapse( body. rewrite( context, body_shape) ,
@@ -1338,10 +1331,8 @@ fn rewrite_guard(context: &RewriteContext,
1338
1331
// 4 = ` if `, 5 = ` => {`
1339
1332
let overhead = pattern_width + 4 + 5 ;
1340
1333
if overhead < shape. width {
1341
- let cond_str =
1342
- guard. rewrite ( context,
1343
- Shape :: legacy ( shape. width - overhead,
1344
- shape. indent + pattern_width + 4 ) ) ;
1334
+ let cond_shape = shape. shrink_left ( pattern_width + 4 ) . unwrap ( ) . sub_width ( 5 ) . unwrap ( ) ;
1335
+ let cond_str = guard. rewrite ( context, cond_shape) ;
1345
1336
if let Some ( cond_str) = cond_str {
1346
1337
return Some ( format ! ( " if {}" , cond_str) ) ;
1347
1338
}
0 commit comments