@@ -176,9 +176,8 @@ fn format_expr(expr: &ast::Expr,
176176 ast:: ExprKind :: Mac ( ref mac) => {
177177 // Failure to rewrite a marco should not imply failure to
178178 // rewrite the expression.
179- rewrite_macro ( mac, None , context, shape, MacroPosition :: Expression ) . or_else ( || {
180- wrap_str ( context. snippet ( expr. span ) , context. config . max_width , shape)
181- } )
179+ rewrite_macro ( mac, None , context, shape, MacroPosition :: Expression )
180+ . or_else ( || wrap_str ( context. snippet ( expr. span ) , context. config . max_width , shape) )
182181 }
183182 ast:: ExprKind :: Ret ( None ) => wrap_str ( "return" . to_owned ( ) , context. config . max_width , shape) ,
184183 ast:: ExprKind :: Ret ( Some ( ref expr) ) => {
@@ -582,14 +581,18 @@ fn rewrite_closure(capture: ast::CaptureBy,
582581
583582 let block_threshold = context. config . closure_block_indent_threshold ;
584583 if block_threshold < 0 || rewrite. matches ( '\n' ) . count ( ) <= block_threshold as usize {
585- return Some ( format ! ( "{} {}" , prefix, rewrite) ) ;
584+ if let Some ( rewrite) = wrap_str ( rewrite, context. config . max_width , shape) {
585+ return Some ( format ! ( "{} {}" , prefix, rewrite) ) ;
586+ }
586587 }
587588
588589 // The body of the closure is big enough to be block indented, that
589590 // means we must re-format.
590591 let block_shape = shape. block ( ) ;
591592 let rewrite = try_opt ! ( block. rewrite( & context, block_shape) ) ;
592- Some ( format ! ( "{} {}" , prefix, rewrite) )
593+ Some ( format ! ( "{} {}" ,
594+ prefix,
595+ try_opt!( wrap_str( rewrite, block_shape. width, block_shape) ) ) )
593596 }
594597}
595598
@@ -1341,11 +1344,10 @@ impl Rewrite for ast::Arm {
13411344 // 4 = ` => `.len()
13421345 if shape. width > pat_width + comma. len ( ) + 4 {
13431346 let arm_shape = shape
1344- . shrink_left ( pat_width + 4 )
1347+ . offset_left ( pat_width + 4 )
13451348 . unwrap ( )
13461349 . sub_width ( comma. len ( ) )
1347- . unwrap ( )
1348- . block ( ) ;
1350+ . unwrap ( ) ;
13491351 let rewrite = nop_block_collapse ( body. rewrite ( context, arm_shape) , arm_shape. width ) ;
13501352 let is_block = if let ast:: ExprKind :: Block ( ..) = body. node {
13511353 true
0 commit comments