Support #[fatal(..)]
This commit is contained in:
parent
bfefefbcfa
commit
b28cc097cf
4 changed files with 27 additions and 2 deletions
|
@ -331,7 +331,7 @@ impl<'a> AstValidator<'a> {
|
||||||
let max_num_args: usize = u16::MAX.into();
|
let max_num_args: usize = u16::MAX.into();
|
||||||
if fn_decl.inputs.len() > max_num_args {
|
if fn_decl.inputs.len() > max_num_args {
|
||||||
let Param { span, .. } = fn_decl.inputs[0];
|
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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ pub struct ForbiddenNonLifetimeParam {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(ast_passes::fn_param_too_many)]
|
#[fatal(ast_passes::fn_param_too_many)]
|
||||||
pub struct FnParamTooMany {
|
pub struct FnParamTooMany {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
|
|
@ -360,6 +360,17 @@ impl ParseSess {
|
||||||
self.create_warning(warning).emit()
|
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]
|
#[rustc_lint_diagnostics]
|
||||||
pub fn struct_err(
|
pub fn struct_err(
|
||||||
&self,
|
&self,
|
||||||
|
@ -373,6 +384,11 @@ impl ParseSess {
|
||||||
self.span_diagnostic.struct_warn(msg)
|
self.span_diagnostic.struct_warn(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustc_lint_diagnostics]
|
||||||
|
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
|
||||||
|
self.span_diagnostic.struct_fatal(msg)
|
||||||
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
pub fn struct_diagnostic<G: EmissionGuarantee>(
|
pub fn struct_diagnostic<G: EmissionGuarantee>(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -482,6 +482,15 @@ impl Session {
|
||||||
pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) {
|
pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) {
|
||||||
self.parse_sess.emit_warning(warning)
|
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]
|
#[inline]
|
||||||
pub fn err_count(&self) -> usize {
|
pub fn err_count(&self) -> usize {
|
||||||
self.diagnostic().err_count()
|
self.diagnostic().err_count()
|
||||||
|
|
Loading…
Add table
Reference in a new issue