File tree 2 files changed +31
-2
lines changed
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(
200
200
}
201
201
ast:: ExprKind :: Continue ( ref opt_label) => {
202
202
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
+ }
204
208
None => String :: new ( ) ,
205
209
} ;
206
210
Ok ( format ! ( "continue{id_str}" ) )
207
211
}
208
212
ast:: ExprKind :: Break ( ref opt_label, ref opt_expr) => {
209
213
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
+ }
211
219
None => String :: new ( ) ,
212
220
} ;
213
221
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