@@ -203,7 +203,7 @@ fn rewrite_closure(capture: ast::CaptureClause,
203
203
204
204
let fmt = ListFormatting :: for_fn ( argument_budget, argument_offset) ;
205
205
let prefix = format ! ( "{}|{}|" , mover, write_list( & arg_items. collect:: <Vec <_>>( ) , & fmt) ) ;
206
- let block_indent = closure_block_indent ( context, offset) ;
206
+ let closure_indent = closure_indent ( context, offset) ;
207
207
208
208
// Try to format closure body as a single line expression without braces.
209
209
if body. stmts . is_empty ( ) {
@@ -232,11 +232,11 @@ fn rewrite_closure(capture: ast::CaptureClause,
232
232
233
233
// We couldn't format the closure body as a single line expression; fall
234
234
// back to block formatting.
235
- let inner_context = & RewriteContext { block_indent : block_indent , .. * context } ;
235
+ let inner_context = context . overflow_context ( closure_indent - context. block_indent ) ;
236
236
let body_rewrite = if let ast:: Expr_ :: ExprBlock ( ref inner) = body. expr . as_ref ( ) . unwrap ( ) . node {
237
- inner. rewrite ( inner_context, 0 , 0 )
237
+ inner. rewrite ( & inner_context, 0 , 0 )
238
238
} else {
239
- body. rewrite ( inner_context, 0 , 0 )
239
+ body. rewrite ( & inner_context, 0 , 0 )
240
240
} ;
241
241
242
242
Some ( format ! ( "{} {}" , prefix, try_opt!( body_rewrite) ) )
@@ -868,8 +868,8 @@ fn rewrite_call(context: &RewriteContext,
868
868
// 2 is for parens.
869
869
let remaining_width = try_opt ! ( width. checked_sub( extra_offset + 2 ) ) ;
870
870
let offset = offset + extra_offset + 1 ;
871
- let block_indent = expr_block_indent ( context, offset) ;
872
- let inner_context = & RewriteContext { block_indent : block_indent , .. * context } ;
871
+ let inner_indent = expr_indent ( context, offset) ;
872
+ let inner_context = context . overflow_context ( inner_indent - context. block_indent ) ;
873
873
874
874
let items = itemize_list ( context. codemap ,
875
875
args. iter ( ) ,
@@ -878,7 +878,7 @@ fn rewrite_call(context: &RewriteContext,
878
878
|item| item. span . hi ,
879
879
// Take old span when rewrite fails.
880
880
|item| {
881
- item. rewrite ( inner_context, remaining_width, offset)
881
+ item. rewrite ( & inner_context, remaining_width, offset)
882
882
. unwrap_or ( context. snippet ( item. span ) )
883
883
} ,
884
884
callee. span . hi + BytePos ( 1 ) ,
@@ -901,8 +901,8 @@ macro_rules! block_indent_helper {
901
901
) ;
902
902
}
903
903
904
- block_indent_helper ! ( expr_block_indent , expr_indent_style) ;
905
- block_indent_helper ! ( closure_block_indent , closure_indent_style) ;
904
+ block_indent_helper ! ( expr_indent , expr_indent_style) ;
905
+ block_indent_helper ! ( closure_indent , closure_indent_style) ;
906
906
907
907
fn rewrite_paren ( context : & RewriteContext ,
908
908
subexpr : & ast:: Expr ,
@@ -1192,7 +1192,9 @@ pub fn rewrite_assign_rhs<S: Into<String>>(context: &RewriteContext,
1192
1192
result. push_str ( & format ! ( "\n {}" , make_indent( new_offset) ) ) ;
1193
1193
1194
1194
let max_width = try_opt ! ( context. config. max_width. checked_sub( new_offset + 1 ) ) ;
1195
- let rhs = try_opt ! ( ex. rewrite( & context. overflow_context( ) , max_width, new_offset) ) ;
1195
+ let rhs = try_opt ! ( ex. rewrite( & context. overflow_context( context. config. tab_spaces) ,
1196
+ max_width,
1197
+ new_offset) ) ;
1196
1198
1197
1199
result. push_str ( & rhs) ;
1198
1200
}
0 commit comments