Migrate "struct literal body without path" error to diagnostic struct

This commit is contained in:
Xiretza 2022-09-04 20:19:49 +02:00
parent ba10f2c0f2
commit 760c4352d6
2 changed files with 30 additions and 17 deletions

View file

@ -1014,3 +1014,21 @@ pub(crate) enum ExpectedSemiSugg {
#[suggestion_short(parser::sugg_add_semi, code = ";", applicability = "machine-applicable")]
AddSemi(#[primary_span] Span),
}
#[derive(Diagnostic)]
#[diag(parser::struct_literal_body_without_path)]
pub(crate) struct StructLiteralBodyWithoutPath {
#[primary_span]
pub span: Span,
#[subdiagnostic]
pub sugg: StructLiteralBodyWithoutPathSugg,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(parser::suggestion, applicability = "has-placeholders")]
pub(crate) struct StructLiteralBodyWithoutPathSugg {
#[suggestion_part(code = "{{ SomeStruct ")]
pub before: Span,
#[suggestion_part(code = " }}")]
pub after: Span,
}