@@ -110,39 +110,37 @@ impl<'a> State<'a> {
110
110
}
111
111
112
112
fn print_expr_vec ( & mut self , exprs : & [ P < ast:: Expr > ] ) {
113
- let ib = self . ibox ( INDENT_UNIT ) ;
114
- self . word ( "[" ) ;
115
- self . commasep_exprs ( Inconsistent , exprs) ;
116
- self . word ( "]" ) ;
117
- self . end ( ib ) ;
113
+ self . with_ibox ( INDENT_UNIT , | this : & mut Self | {
114
+ this . word ( "[" ) ;
115
+ this . commasep_exprs ( Inconsistent , exprs) ;
116
+ this . word ( "]" ) ;
117
+ } ) ;
118
118
}
119
119
120
120
pub ( super ) fn print_expr_anon_const (
121
121
& mut self ,
122
122
expr : & ast:: AnonConst ,
123
123
attrs : & [ ast:: Attribute ] ,
124
124
) {
125
- let ib = self . ibox ( INDENT_UNIT ) ;
126
- self . word ( "const" ) ;
127
- self . nbsp ( ) ;
128
- if let ast:: ExprKind :: Block ( block, None ) = & expr. value . kind {
129
- let cb = self . cbox ( 0 ) ;
130
- let ib = self . ibox ( 0 ) ;
131
- self . print_block_with_attrs ( block, attrs, cb, ib) ;
132
- } else {
133
- self . print_expr ( & expr. value , FixupContext :: default ( ) ) ;
134
- }
135
- self . end ( ib) ;
125
+ self . with_ibox ( INDENT_UNIT , |this| {
126
+ this. word ( "const" ) ;
127
+ this. nbsp ( ) ;
128
+ if let ast:: ExprKind :: Block ( block, None ) = & expr. value . kind {
129
+ this. with_cbox_ibox_print_block_with_attrs ( 0 , 0 , block, attrs, |_| { } ) ;
130
+ } else {
131
+ this. print_expr ( & expr. value , FixupContext :: default ( ) ) ;
132
+ }
133
+ } ) ;
136
134
}
137
135
138
136
fn print_expr_repeat ( & mut self , element : & ast:: Expr , count : & ast:: AnonConst ) {
139
- let ib = self . ibox ( INDENT_UNIT ) ;
140
- self . word ( "[" ) ;
141
- self . print_expr ( element, FixupContext :: default ( ) ) ;
142
- self . word_space ( ";" ) ;
143
- self . print_expr ( & count. value , FixupContext :: default ( ) ) ;
144
- self . word ( "]" ) ;
145
- self . end ( ib ) ;
137
+ self . with_ibox ( INDENT_UNIT , |this| {
138
+ this . word ( "[" ) ;
139
+ this . print_expr ( element, FixupContext :: default ( ) ) ;
140
+ this . word_space ( ";" ) ;
141
+ this . print_expr ( & count. value , FixupContext :: default ( ) ) ;
142
+ this . word ( "]" ) ;
143
+ } ) ;
146
144
}
147
145
148
146
fn print_expr_struct (
@@ -438,14 +436,12 @@ impl<'a> State<'a> {
438
436
ast:: ExprKind :: Type ( expr, ty) => {
439
437
self . word ( "builtin # type_ascribe" ) ;
440
438
self . popen ( ) ;
441
- let ib = self . ibox ( 0 ) ;
442
- self . print_expr ( expr, FixupContext :: default ( ) ) ;
443
-
444
- self . word ( "," ) ;
445
- self . space_if_not_bol ( ) ;
446
- self . print_type ( ty) ;
447
-
448
- self . end ( ib) ;
439
+ self . with_ibox ( 0 , |this| {
440
+ this. print_expr ( expr, FixupContext :: default ( ) ) ;
441
+ this. word ( "," ) ;
442
+ this. space_if_not_bol ( ) ;
443
+ this. print_type ( ty) ;
444
+ } ) ;
449
445
self . pclose ( ) ;
450
446
}
451
447
ast:: ExprKind :: Let ( pat, scrutinee, _, _) => {
@@ -457,12 +453,11 @@ impl<'a> State<'a> {
457
453
self . print_ident ( label. ident ) ;
458
454
self . word_space ( ":" ) ;
459
455
}
460
- let cb = self . cbox ( 0 ) ;
461
- let ib = self . ibox ( 0 ) ;
462
- self . word_nbsp ( "while" ) ;
463
- self . print_expr_as_cond ( test) ;
464
- self . space ( ) ;
465
- self . print_block_with_attrs ( blk, attrs, cb, ib) ;
456
+ self . with_cbox_ibox_print_block_with_attrs ( 0 , 0 , blk, attrs, |this| {
457
+ this. word_nbsp ( "while" ) ;
458
+ this. print_expr_as_cond ( test) ;
459
+ this. space ( ) ;
460
+ }
466
461
}
467
462
ast:: ExprKind :: ForLoop { pat, iter, body, label, kind } => {
468
463
if let Some ( label) = label {
@@ -833,6 +828,7 @@ impl<'a> State<'a> {
833
828
if arm. attrs . is_empty ( ) {
834
829
self . space ( ) ;
835
830
}
831
+ // njn: hmm, tricky case for the closure approach
836
832
let cb = self . cbox ( INDENT_UNIT ) ;
837
833
let ib = self . ibox ( 0 ) ;
838
834
self . maybe_print_comment ( arm. pat . span . lo ( ) ) ;
@@ -874,7 +870,7 @@ impl<'a> State<'a> {
874
870
// other path :(
875
871
self . word ( "," ) ;
876
872
}
877
- self . end ( cb) ; // Close enclosing cbox.
873
+ self . end ( cb) ; // Close enclosing cbox. // njn: remove low-value comments of this sort
878
874
}
879
875
880
876
fn print_closure_binder ( & mut self , binder : & ast:: ClosureBinder ) {
0 commit comments