Migrate forbidden_let

This commit is contained in:
finalchild 2022-08-17 23:51:01 +09:00
parent 4b695f7c4e
commit d6fdf14eb7
7 changed files with 45 additions and 18 deletions

View file

@ -0,0 +1,32 @@
//! Errors emitted by ast_passes.
use rustc_errors::fluent;
use rustc_errors::{AddSubdiagnostic, Diagnostic};
use rustc_macros::SessionDiagnostic;
use rustc_span::Span;
use crate::ast_validation::ForbiddenLetReason;
#[derive(SessionDiagnostic)]
#[error(ast_passes::forbidden_let)]
#[note]
pub struct ForbiddenLet {
#[primary_span]
pub span: Span,
#[subdiagnostic]
pub(crate) reason: ForbiddenLetReason,
}
impl AddSubdiagnostic for ForbiddenLetReason {
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
match self {
Self::GenericForbidden => {}
Self::NotSupportedOr(span) => {
diag.span_note(span, fluent::ast_passes::not_supported_or);
}
Self::NotSupportedParentheses(span) => {
diag.span_note(span, fluent::ast_passes::not_supported_parentheses);
},
}
}
}