Migrate "invalid variable declaration" errors to SessionDiagnostic
This commit is contained in:
parent
86c6ebee8f
commit
e8499cfadc
3 changed files with 50 additions and 19 deletions
|
@ -334,6 +334,35 @@ struct InInTypo {
|
|||
sugg_span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(parser::invalid_variable_declaration)]
|
||||
pub struct InvalidVariableDeclaration {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[subdiagnostic]
|
||||
pub sub: InvalidVariableDeclarationSub,
|
||||
}
|
||||
|
||||
#[derive(SessionSubdiagnostic)]
|
||||
pub enum InvalidVariableDeclarationSub {
|
||||
#[suggestion(
|
||||
parser::switch_mut_let_order,
|
||||
applicability = "maybe-incorrect",
|
||||
code = "let mut"
|
||||
)]
|
||||
SwitchMutLetOrder(#[primary_span] Span),
|
||||
#[suggestion(
|
||||
parser::missing_let_before_mut,
|
||||
applicability = "machine-applicable",
|
||||
code = "let mut"
|
||||
)]
|
||||
MissingLet(#[primary_span] Span),
|
||||
#[suggestion(parser::use_let_not_auto, applicability = "machine-applicable", code = "let")]
|
||||
UseLetNotAuto(#[primary_span] Span),
|
||||
#[suggestion(parser::use_let_not_var, applicability = "machine-applicable", code = "let")]
|
||||
UseLetNotVar(#[primary_span] Span),
|
||||
}
|
||||
|
||||
// SnapshotParser is used to create a snapshot of the parser
|
||||
// without causing duplicate errors being emitted when the `Parser`
|
||||
// is dropped.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue