@@ -122,27 +122,26 @@ pub fn format_expr(
122122 match expr_type {
123123 ExprType :: Statement => {
124124 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)
126126 } else if let rw @ Some ( _) =
127127 rewrite_empty_block ( context, block, Some ( & expr. attrs ) , "" , shape)
128128 {
129129 // Rewrite block without trying to put it in a single line.
130130 rw
131131 } else {
132132 let prefix = block_prefix ( context, block, shape) ?;
133- let label_string = rewrite_label ( opt_label) ;
134133
135134 rewrite_block_with_visitor (
136135 context,
137- & format ! ( "{}{}" , & prefix, & label_string ) ,
136+ & prefix,
138137 block,
139138 Some ( & expr. attrs ) ,
140139 shape,
141140 true ,
142141 )
143142 }
144143 }
145- ExprType :: SubExpression => rewrite_block ( block, Some ( & expr. attrs ) , context, shape) ,
144+ ExprType :: SubExpression => rewrite_block ( block, Some ( & expr. attrs ) , opt_label , context, shape) ,
146145 }
147146 }
148147 ast:: ExprKind :: Match ( ref cond, ref arms) => {
@@ -328,6 +327,7 @@ pub fn format_expr(
328327 rewrite_block(
329328 block,
330329 Some ( & expr. attrs) ,
330+ None ,
331331 context,
332332 Shape :: legacy( budget, shape. indent)
333333 ) ?
@@ -645,17 +645,20 @@ pub fn rewrite_block_with_visitor(
645645
646646impl Rewrite for ast:: Block {
647647 fn rewrite ( & self , context : & RewriteContext , shape : Shape ) -> Option < String > {
648- rewrite_block ( self , None , context, shape)
648+ rewrite_block ( self , None , None , context, shape)
649649 }
650650}
651651
652652fn rewrite_block (
653653 block : & ast:: Block ,
654654 attrs : Option < & [ ast:: Attribute ] > ,
655+ label : Option < ast:: Label > ,
655656 context : & RewriteContext ,
656657 shape : Shape ,
657658) -> 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) ;
659662
660663 // shape.width is used only for the single line case: either the empty block `{}`,
661664 // or an unsafe expression `unsafe { e }`.
0 commit comments