Rollup merge of #112978 - compiler-errors:bad-block-sugg, r=davidtwco
Add suggestion for bad block fragment error Makes it a bit clearer how to fix this parser restriction
This commit is contained in:
commit
e992895c1d
5 changed files with 32 additions and 0 deletions
|
@ -333,6 +333,17 @@ pub(crate) struct InvalidBlockMacroSegment {
|
|||
pub span: Span,
|
||||
#[label]
|
||||
pub context: Span,
|
||||
#[subdiagnostic]
|
||||
pub wrap: WrapInExplicitBlock,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")]
|
||||
pub(crate) struct WrapInExplicitBlock {
|
||||
#[suggestion_part(code = "{{ ")]
|
||||
pub lo: Span,
|
||||
#[suggestion_part(code = " }}")]
|
||||
pub hi: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
|
@ -2192,6 +2192,10 @@ impl<'a> Parser<'a> {
|
|||
self.sess.emit_err(errors::InvalidBlockMacroSegment {
|
||||
span: self.token.span,
|
||||
context: lo.to(self.token.span),
|
||||
wrap: errors::WrapInExplicitBlock {
|
||||
lo: self.token.span.shrink_to_lo(),
|
||||
hi: self.token.span.shrink_to_hi(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue