Migrate forbidden_let
This commit is contained in:
parent
4b695f7c4e
commit
d6fdf14eb7
7 changed files with 45 additions and 18 deletions
32
compiler/rustc_ast_passes/src/errors.rs
Normal file
32
compiler/rustc_ast_passes/src/errors.rs
Normal 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);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue