File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -200,14 +200,22 @@ pub(crate) fn format_expr(
200200 }
201201 ast:: ExprKind :: Continue ( ref opt_label) => {
202202 let id_str = match * opt_label {
203- Some ( label) => format ! ( " {}" , label. ident) ,
203+ Some ( label) => {
204+ // Ident lose the `r#` prefix in raw labels, so use the original snippet
205+ let label_name = context. snippet ( label. ident . span ) ;
206+ format ! ( " {}" , label_name)
207+ }
204208 None => String :: new ( ) ,
205209 } ;
206210 Ok ( format ! ( "continue{id_str}" ) )
207211 }
208212 ast:: ExprKind :: Break ( ref opt_label, ref opt_expr) => {
209213 let id_str = match * opt_label {
210- Some ( label) => format ! ( " {}" , label. ident) ,
214+ Some ( label) => {
215+ // Ident lose the `r#` prefix in raw labels, so use the original snippet
216+ let label_name = context. snippet ( label. ident . span ) ;
217+ format ! ( " {}" , label_name)
218+ }
211219 None => String :: new ( ) ,
212220 } ;
213221
Original file line number Diff line number Diff line change 1+ // rustfmt-edition: 2021
2+
3+ fn test_break ( ) {
4+ ' r#if: {
5+ break ' r#if;
6+ }
7+
8+ ' r#a: {
9+ break ' r#a;
10+ }
11+ }
12+
13+ fn test_continue ( ) {
14+ ' r#if: {
15+ continue ' r#if;
16+ }
17+
18+ ' r#a: {
19+ continue ' r#a;
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments