@@ -122,27 +122,26 @@ pub fn format_expr(
122
122
match expr_type {
123
123
ExprType :: Statement => {
124
124
if is_unsafe_block ( block) {
125
- rewrite_block ( block, Some ( & expr. attrs ) , context, shape)
125
+ rewrite_block ( block, Some ( & expr. attrs ) , opt_label , context, shape)
126
126
} else if let rw @ Some ( _) =
127
127
rewrite_empty_block ( context, block, Some ( & expr. attrs ) , "" , shape)
128
128
{
129
129
// Rewrite block without trying to put it in a single line.
130
130
rw
131
131
} else {
132
132
let prefix = block_prefix ( context, block, shape) ?;
133
- let label_string = rewrite_label ( opt_label) ;
134
133
135
134
rewrite_block_with_visitor (
136
135
context,
137
- & format ! ( "{}{}" , & prefix, & label_string ) ,
136
+ & prefix,
138
137
block,
139
138
Some ( & expr. attrs ) ,
140
139
shape,
141
140
true ,
142
141
)
143
142
}
144
143
}
145
- ExprType :: SubExpression => rewrite_block ( block, Some ( & expr. attrs ) , context, shape) ,
144
+ ExprType :: SubExpression => rewrite_block ( block, Some ( & expr. attrs ) , opt_label , context, shape) ,
146
145
}
147
146
}
148
147
ast:: ExprKind :: Match ( ref cond, ref arms) => {
@@ -328,6 +327,7 @@ pub fn format_expr(
328
327
rewrite_block(
329
328
block,
330
329
Some ( & expr. attrs) ,
330
+ None ,
331
331
context,
332
332
Shape :: legacy( budget, shape. indent)
333
333
) ?
@@ -645,17 +645,20 @@ pub fn rewrite_block_with_visitor(
645
645
646
646
impl Rewrite for ast:: Block {
647
647
fn rewrite ( & self , context : & RewriteContext , shape : Shape ) -> Option < String > {
648
- rewrite_block ( self , None , context, shape)
648
+ rewrite_block ( self , None , None , context, shape)
649
649
}
650
650
}
651
651
652
652
fn rewrite_block (
653
653
block : & ast:: Block ,
654
654
attrs : Option < & [ ast:: Attribute ] > ,
655
+ label : Option < ast:: Label > ,
655
656
context : & RewriteContext ,
656
657
shape : Shape ,
657
658
) -> Option < String > {
658
- let prefix = block_prefix ( context, block, shape) ?;
659
+ let unsafe_string = block_prefix ( context, block, shape) ?;
660
+ let label_string = rewrite_label ( label) ;
661
+ let prefix = format ! ( "{}{}" , unsafe_string, label_string) ;
659
662
660
663
// shape.width is used only for the single line case: either the empty block `{}`,
661
664
// or an unsafe expression `unsafe { e }`.
0 commit comments