@@ -144,7 +144,7 @@ impl<'a> FmtVisitor<'a> {
144
144
145
145
// Check if vertical layout was forced by compute_budget_for_args.
146
146
if one_line_budget <= 0 {
147
- if config ! ( fn_args_paren_newline) {
147
+ if self . config . fn_args_paren_newline {
148
148
result. push ( '\n' ) ;
149
149
result. push_str ( & make_indent ( arg_indent) ) ;
150
150
arg_indent = arg_indent + 1 ; // extra space for `(`
@@ -170,8 +170,8 @@ impl<'a> FmtVisitor<'a> {
170
170
// If we've already gone multi-line, or the return type would push
171
171
// over the max width, then put the return type on a new line.
172
172
if result. contains ( "\n " ) ||
173
- result. len ( ) + indent + ret_str. len ( ) > config ! ( max_width) {
174
- let indent = match config ! ( fn_return_indent) {
173
+ result. len ( ) + indent + ret_str. len ( ) > self . config . max_width {
174
+ let indent = match self . config . fn_return_indent {
175
175
ReturnIndent :: WithWhereClause => indent + 4 ,
176
176
// TODO we might want to check that using the arg indent doesn't
177
177
// blow our budget, and if it does, then fallback to the where
@@ -363,15 +363,15 @@ impl<'a> FmtVisitor<'a> {
363
363
if !newline_brace {
364
364
used_space += 2 ;
365
365
}
366
- let one_line_budget = if used_space > config ! ( max_width) {
366
+ let one_line_budget = if used_space > self . config . max_width {
367
367
0
368
368
} else {
369
- config ! ( max_width) - used_space
369
+ self . config . max_width - used_space
370
370
} ;
371
371
372
372
// 2 = `()`
373
373
let used_space = indent + result. len ( ) + 2 ;
374
- let max_space = config ! ( ideal_width) + config ! ( leeway) ;
374
+ let max_space = self . config . ideal_width + self . config . leeway ;
375
375
debug ! ( "compute_budgets_for_args: used_space: {}, max_space: {}" ,
376
376
used_space, max_space) ;
377
377
if used_space < max_space {
@@ -383,9 +383,9 @@ impl<'a> FmtVisitor<'a> {
383
383
384
384
// Didn't work. we must force vertical layout and put args on a newline.
385
385
if let None = budgets {
386
- let new_indent = indent + config ! ( tab_spaces) ;
386
+ let new_indent = indent + self . config . tab_spaces ;
387
387
let used_space = new_indent + 2 ; // account for `(` and `)`
388
- let max_space = config ! ( ideal_width) + config ! ( leeway) ;
388
+ let max_space = self . config . ideal_width + self . config . leeway ;
389
389
if used_space > max_space {
390
390
// Whoops! bankrupt.
391
391
// TODO take evasive action, perhaps kill the indent or something.
@@ -398,7 +398,7 @@ impl<'a> FmtVisitor<'a> {
398
398
}
399
399
400
400
fn newline_for_brace ( & self , where_clause : & ast:: WhereClause ) -> bool {
401
- match config ! ( fn_brace_style) {
401
+ match self . config . fn_brace_style {
402
402
BraceStyle :: AlwaysNextLine => true ,
403
403
BraceStyle :: SameLineWhere if where_clause. predicates . len ( ) > 0 => true ,
404
404
_ => false ,
@@ -421,7 +421,7 @@ impl<'a> FmtVisitor<'a> {
421
421
self . changes . push_str_span ( span, & generics_str) ;
422
422
423
423
self . last_pos = body_start;
424
- self . block_indent += config ! ( tab_spaces) ;
424
+ self . block_indent += self . config . tab_spaces ;
425
425
for ( i, f) in enum_def. variants . iter ( ) . enumerate ( ) {
426
426
let next_span_start: BytePos = if i == enum_def. variants . len ( ) - 1 {
427
427
span. hi
@@ -431,7 +431,7 @@ impl<'a> FmtVisitor<'a> {
431
431
432
432
self . visit_variant ( f, i == enum_def. variants . len ( ) - 1 , next_span_start) ;
433
433
}
434
- self . block_indent -= config ! ( tab_spaces) ;
434
+ self . block_indent -= self . config . tab_spaces ;
435
435
436
436
self . format_missing_with_indent ( span. lo + BytePos ( enum_snippet. rfind ( '}' ) . unwrap ( ) as u32 ) ) ;
437
437
self . changes . push_str_span ( span, "}" ) ;
@@ -478,8 +478,8 @@ impl<'a> FmtVisitor<'a> {
478
478
+ field. node . name . to_string ( ) . len ( )
479
479
+ 1 ; // 1 = (
480
480
481
- let comma_cost = if config ! ( enum_trailing_comma) { 1 } else { 0 } ;
482
- let budget = config ! ( ideal_width) - indent - comma_cost - 1 ; // 1 = )
481
+ let comma_cost = if self . config . enum_trailing_comma { 1 } else { 0 } ;
482
+ let budget = self . config . ideal_width - indent - comma_cost - 1 ; // 1 = )
483
483
484
484
let fmt = ListFormatting {
485
485
tactic : ListTactic :: HorizontalVertical ,
@@ -500,13 +500,13 @@ impl<'a> FmtVisitor<'a> {
500
500
501
501
// Make sure we do not exceed column limit
502
502
// 4 = " = ,"
503
- assert ! ( config! ( max_width) >= vis. len( ) + name. len( ) + expr_snippet. len( ) + 4 ,
503
+ assert ! ( self . config. max_width >= vis. len( ) + name. len( ) + expr_snippet. len( ) + 4 ,
504
504
"Enum variant exceeded column limit" ) ;
505
505
}
506
506
507
507
self . changes . push_str_span ( field. span , & result) ;
508
508
509
- if !last_field || config ! ( enum_trailing_comma) {
509
+ if !last_field || self . config . enum_trailing_comma {
510
510
self . changes . push_str_span ( field. span , "," ) ;
511
511
}
512
512
}
@@ -543,11 +543,11 @@ impl<'a> FmtVisitor<'a> {
543
543
// This will drop the comment in between the header and body.
544
544
self . last_pos = span. lo + BytePos ( struct_snippet. find_uncommented ( "{" ) . unwrap ( ) as u32 + 1 ) ;
545
545
546
- self . block_indent += config ! ( tab_spaces) ;
546
+ self . block_indent += self . config . tab_spaces ;
547
547
for ( i, f) in struct_def. fields . iter ( ) . enumerate ( ) {
548
548
self . visit_field ( f, i == struct_def. fields . len ( ) - 1 , span. lo , & struct_snippet) ;
549
549
}
550
- self . block_indent -= config ! ( tab_spaces) ;
550
+ self . block_indent -= self . config . tab_spaces ;
551
551
552
552
self . format_missing_with_indent ( span. lo + BytePos ( struct_snippet. rfind ( '}' ) . unwrap ( ) as u32 ) ) ;
553
553
self . changes . push_str_span ( span, "}" ) ;
@@ -608,21 +608,21 @@ impl<'a> FmtVisitor<'a> {
608
608
609
609
let mut field_str = match name {
610
610
Some ( name) => {
611
- let budget = config ! ( ideal_width) - self . block_indent ;
611
+ let budget = self . config . ideal_width - self . block_indent ;
612
612
// 3 is being conservative and assuming that there will be a trailing comma.
613
613
if self . block_indent + vis. len ( ) + name. len ( ) + typ. len ( ) + 3 > budget {
614
614
format ! ( "{}{}:\n {}{}" ,
615
615
vis,
616
616
name,
617
- & make_indent( self . block_indent + config! ( tab_spaces) ) ,
617
+ & make_indent( self . block_indent + self . config. tab_spaces) ,
618
618
typ)
619
619
} else {
620
620
format ! ( "{}{}: {}" , vis, name, typ)
621
621
}
622
622
}
623
623
None => format ! ( "{}{}" , vis, typ) ,
624
624
} ;
625
- if !last_field || config ! ( struct_trailing_comma) {
625
+ if !last_field || self . config . struct_trailing_comma {
626
626
field_str. push ( ',' ) ;
627
627
}
628
628
self . changes . push_str_span ( field. span , & field_str) ;
@@ -647,7 +647,7 @@ impl<'a> FmtVisitor<'a> {
647
647
return result;
648
648
}
649
649
650
- let budget = config ! ( max_width) - indent - 2 ;
650
+ let budget = self . config . max_width - indent - 2 ;
651
651
// TODO might need to insert a newline if the generics are really long
652
652
result. push ( '<' ) ;
653
653
@@ -723,7 +723,7 @@ impl<'a> FmtVisitor<'a> {
723
723
. zip ( comments. into_iter ( ) )
724
724
. collect ( ) ;
725
725
726
- let budget = config ! ( ideal_width) + config ! ( leeway) - indent - 10 ;
726
+ let budget = self . config . ideal_width + self . config . leeway - indent - 10 ;
727
727
let fmt = ListFormatting {
728
728
tactic : ListTactic :: Vertical ,
729
729
separator : "," ,
0 commit comments