feat/refactor: improve errors in case of ident with number at start
This commit is contained in:
parent
8824994ccd
commit
252e0b3385
9 changed files with 68 additions and 45 deletions
|
@ -939,6 +939,7 @@ pub(crate) struct ExpectedIdentifier {
|
|||
pub token: Token,
|
||||
pub suggest_raw: Option<SuggEscapeToUseAsIdentifier>,
|
||||
pub suggest_remove_comma: Option<SuggRemoveComma>,
|
||||
pub help_cannot_start_number: Option<HelpIdentifierStartsWithNumber>,
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedIdentifier {
|
||||
|
@ -975,10 +976,18 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedIdentifier {
|
|||
sugg.add_to_diagnostic(&mut diag);
|
||||
}
|
||||
|
||||
if let Some(help) = self.help_cannot_start_number {
|
||||
help.add_to_diagnostic(&mut diag);
|
||||
}
|
||||
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[help(parse_invalid_identifier_with_leading_number)]
|
||||
pub(crate) struct HelpIdentifierStartsWithNumber;
|
||||
|
||||
pub(crate) struct ExpectedSemi {
|
||||
pub span: Span,
|
||||
pub token: Token,
|
||||
|
@ -1207,14 +1216,6 @@ pub(crate) struct SelfParamNotFirst {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(parse_invalid_identifier_with_leading_number)]
|
||||
pub(crate) struct InvalidIdentiferStartsWithNumber {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(parse_const_generic_without_braces)]
|
||||
pub(crate) struct ConstGenericWithoutBraces {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue