File tree 5 files changed +32
-0
lines changed
5 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -353,6 +353,7 @@ parse_int_literal_too_large = integer literal is too large
353
353
354
354
parse_invalid_block_macro_segment = cannot use a `block` macro fragment here
355
355
.label = the `block` fragment is within this context
356
+ .suggestion = wrap this in another block
356
357
357
358
parse_invalid_char_in_escape = { parse_invalid_char_in_escape_msg } : `{ $ch } `
358
359
.label = { parse_invalid_char_in_escape_msg }
Original file line number Diff line number Diff line change @@ -333,6 +333,17 @@ pub(crate) struct InvalidBlockMacroSegment {
333
333
pub span : Span ,
334
334
#[ label]
335
335
pub context : Span ,
336
+ #[ subdiagnostic]
337
+ pub wrap : WrapInExplicitBlock ,
338
+ }
339
+
340
+ #[ derive( Subdiagnostic ) ]
341
+ #[ multipart_suggestion( parse_suggestion, applicability = "machine-applicable" ) ]
342
+ pub ( crate ) struct WrapInExplicitBlock {
343
+ #[ suggestion_part( code = "{{ " ) ]
344
+ pub lo : Span ,
345
+ #[ suggestion_part( code = " }}" ) ]
346
+ pub hi : Span ,
336
347
}
337
348
338
349
#[ derive( Diagnostic ) ]
Original file line number Diff line number Diff line change @@ -2186,6 +2186,10 @@ impl<'a> Parser<'a> {
2186
2186
self . sess . emit_err ( errors:: InvalidBlockMacroSegment {
2187
2187
span : self . token . span ,
2188
2188
context : lo. to ( self . token . span ) ,
2189
+ wrap : errors:: WrapInExplicitBlock {
2190
+ lo : self . token . span . shrink_to_lo ( ) ,
2191
+ hi : self . token . span . shrink_to_hi ( ) ,
2192
+ } ,
2189
2193
} ) ;
2190
2194
}
2191
2195
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ LL | m!({});
10
10
| ------ in this macro invocation
11
11
|
12
12
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
13
+ help: wrap this in another block
14
+ |
15
+ LL | 'lab: { $b };
16
+ | + +
13
17
14
18
error: cannot use a `block` macro fragment here
15
19
--> $DIR/bad-interpolated-block.rs:6:16
@@ -23,6 +27,10 @@ LL | m!({});
23
27
| ------ in this macro invocation
24
28
|
25
29
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
30
+ help: wrap this in another block
31
+ |
32
+ LL | unsafe { $b };
33
+ | + +
26
34
27
35
error: cannot use a `block` macro fragment here
28
36
--> $DIR/bad-interpolated-block.rs:7:23
@@ -34,6 +42,10 @@ LL | m!({});
34
42
| ------ in this macro invocation
35
43
|
36
44
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
45
+ help: wrap this in another block
46
+ |
47
+ LL | |x: u8| -> () { $b };
48
+ | + +
37
49
38
50
error: aborting due to 3 previous errors
39
51
Original file line number Diff line number Diff line change @@ -77,6 +77,10 @@ LL | m!({});
77
77
| ------ in this macro invocation
78
78
|
79
79
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
80
+ help: wrap this in another block
81
+ |
82
+ LL | 'l5 { $b };
83
+ | + +
80
84
81
85
error: labeled expression must be followed by `:`
82
86
--> $DIR/labeled-no-colon-expr.rs:14:8
You can’t perform that action at this time.
0 commit comments