@@ -462,7 +462,7 @@ fn rewrite_empty_block(
462462 return None ;
463463 }
464464
465- let label_str = rewrite_label ( label) ;
465+ let label_str = rewrite_label ( context , label) ;
466466 if attrs. map_or ( false , |a| !inner_attributes ( a) . is_empty ( ) ) {
467467 return None ;
468468 }
@@ -527,7 +527,7 @@ fn rewrite_single_line_block(
527527 if let Some ( block_expr) = stmt:: Stmt :: from_simple_block ( context, block, attrs) {
528528 let expr_shape = shape. offset_left ( last_line_width ( prefix) ) ?;
529529 let expr_str = block_expr. rewrite ( context, expr_shape) ?;
530- let label_str = rewrite_label ( label) ;
530+ let label_str = rewrite_label ( context , label) ;
531531 let result = format ! ( "{prefix}{label_str}{{ {expr_str} }}" ) ;
532532 if result. len ( ) <= shape. width && !result. contains ( '\n' ) {
533533 return Some ( result) ;
@@ -562,7 +562,7 @@ pub(crate) fn rewrite_block_with_visitor(
562562 }
563563
564564 let inner_attrs = attrs. map ( inner_attributes) ;
565- let label_str = rewrite_label ( label) ;
565+ let label_str = rewrite_label ( context , label) ;
566566 visitor. visit_block ( block, inner_attrs. as_deref ( ) , has_braces) ;
567567 let visitor_context = visitor. get_context ( ) ;
568568 context
@@ -939,7 +939,7 @@ impl<'a> ControlFlow<'a> {
939939 fresh_shape
940940 } ;
941941
942- let label_string = rewrite_label ( self . label ) ;
942+ let label_string = rewrite_label ( context , self . label ) ;
943943 // 1 = space after keyword.
944944 let offset = self . keyword . len ( ) + label_string. len ( ) + 1 ;
945945
@@ -1168,9 +1168,9 @@ impl<'a> Rewrite for ControlFlow<'a> {
11681168 }
11691169}
11701170
1171- fn rewrite_label ( opt_label : Option < ast:: Label > ) -> Cow < ' static , str > {
1171+ fn rewrite_label ( context : & RewriteContext < ' _ > , opt_label : Option < ast:: Label > ) -> Cow < ' static , str > {
11721172 match opt_label {
1173- Some ( label) => Cow :: from ( format ! ( "{}: " , label. ident) ) ,
1173+ Some ( label) => Cow :: from ( format ! ( "{}: " , context . snippet ( label. ident. span ) ) ) ,
11741174 None => Cow :: from ( "" ) ,
11751175 }
11761176}
0 commit comments