This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +32
-0
lines changed Expand file tree Collapse file tree 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
353353
354354parse_invalid_block_macro_segment = cannot use a `block` macro fragment here
355355 .label = the `block` fragment is within this context
356+ .suggestion = wrap this in another block
356357
357358parse_invalid_char_in_escape = { parse_invalid_char_in_escape_msg } : `{ $ch } `
358359 .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 {
333333 pub span : Span ,
334334 #[ label]
335335 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 ,
336347}
337348
338349#[ derive( Diagnostic ) ]
Original file line number Diff line number Diff line change @@ -2192,6 +2192,10 @@ impl<'a> Parser<'a> {
21922192 self . sess . emit_err ( errors:: InvalidBlockMacroSegment {
21932193 span : self . token . span ,
21942194 context : lo. to ( self . token . span ) ,
2195+ wrap : errors:: WrapInExplicitBlock {
2196+ lo : self . token . span . shrink_to_lo ( ) ,
2197+ hi : self . token . span . shrink_to_hi ( ) ,
2198+ } ,
21952199 } ) ;
21962200 }
21972201
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ LL | m!({});
1010 | ------ in this macro invocation
1111 |
1212 = 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+ | + +
1317
1418error: cannot use a `block` macro fragment here
1519 --> $DIR/bad-interpolated-block.rs:6:16
@@ -23,6 +27,10 @@ LL | m!({});
2327 | ------ in this macro invocation
2428 |
2529 = 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+ | + +
2634
2735error: cannot use a `block` macro fragment here
2836 --> $DIR/bad-interpolated-block.rs:7:23
@@ -34,6 +42,10 @@ LL | m!({});
3442 | ------ in this macro invocation
3543 |
3644 = 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+ | + +
3749
3850error: aborting due to 3 previous errors
3951
Original file line number Diff line number Diff line change @@ -77,6 +77,10 @@ LL | m!({});
7777 | ------ in this macro invocation
7878 |
7979 = 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+ | + +
8084
8185error: labeled expression must be followed by `:`
8286 --> $DIR/labeled-no-colon-expr.rs:14:8
You can’t perform that action at this time.
0 commit comments