diff options
| author | finalchild <finalchild2@gmail.com> | 2022-08-18 21:20:50 +0900 |
|---|---|---|
| committer | finalchild <finalchild2@gmail.com> | 2022-08-22 01:11:55 +0900 |
| commit | b28cc097cfbdc9e2f105a7e644389266027bcf7d (patch) | |
| tree | 51d5b715588f3ac289fc18bb728706c73341b1d2 | |
| parent | bfefefbcfa87cc468d081da371686432ca77c245 (diff) | |
| download | rust-b28cc097cfbdc9e2f105a7e644389266027bcf7d.tar.gz rust-b28cc097cfbdc9e2f105a7e644389266027bcf7d.zip | |
Support #[fatal(..)]
| -rw-r--r-- | compiler/rustc_ast_passes/src/ast_validation.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_ast_passes/src/errors.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/parse.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 9 |
4 files changed, 27 insertions, 2 deletions
diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 1c3a4ab7c67..c8b46dde1c7 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -331,7 +331,7 @@ impl<'a> AstValidator<'a> { let max_num_args: usize = u16::MAX.into(); if fn_decl.inputs.len() > max_num_args { let Param { span, .. } = fn_decl.inputs[0]; - self.session.emit_err(FnParamTooMany { span, max_num_args }); + self.session.emit_fatal(FnParamTooMany { span, max_num_args }); } } diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index ee375f1ced7..0287d71feb3 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -106,7 +106,7 @@ pub struct ForbiddenNonLifetimeParam { } #[derive(SessionDiagnostic)] -#[error(ast_passes::fn_param_too_many)] +#[fatal(ast_passes::fn_param_too_many)] pub struct FnParamTooMany { #[primary_span] pub span: Span, diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index b9b2356130a..17866dc6bdd 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -360,6 +360,17 @@ impl ParseSess { self.create_warning(warning).emit() } + pub fn create_fatal<'a>( + &'a self, + fatal: impl SessionDiagnostic<'a, !>, + ) -> DiagnosticBuilder<'a, !> { + fatal.into_diagnostic(self) + } + + pub fn emit_fatal<'a>(&'a self, fatal: impl SessionDiagnostic<'a, !>) -> ! { + self.create_fatal(fatal).emit() + } + #[rustc_lint_diagnostics] pub fn struct_err( &self, @@ -374,6 +385,11 @@ impl ParseSess { } #[rustc_lint_diagnostics] + pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> { + self.span_diagnostic.struct_fatal(msg) + } + + #[rustc_lint_diagnostics] pub fn struct_diagnostic<G: EmissionGuarantee>( &self, msg: impl Into<DiagnosticMessage>, diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 80de451276c..255d919eb14 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -482,6 +482,15 @@ impl Session { pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) { self.parse_sess.emit_warning(warning) } + pub fn create_fatal<'a>( + &'a self, + fatal: impl SessionDiagnostic<'a, !>, + ) -> DiagnosticBuilder<'a, !> { + self.parse_sess.create_fatal(fatal) + } + pub fn emit_fatal<'a>(&'a self, fatal: impl SessionDiagnostic<'a, !>) { + self.parse_sess.emit_fatal(fatal) + } #[inline] pub fn err_count(&self) -> usize { self.diagnostic().err_count() |
