Add EmitResult
associated type to EmissionGuarantee
.
This lets different error levels share the same return type from `emit_*`. - A lot of inconsistencies in the `DiagCtxt` API are removed. - `Noted` is removed. - `FatalAbort` is introduced for fatal errors (abort via `raise`), replacing the `EmissionGuarantee` impl for `!`. - `Bug` is renamed `BugAbort` (to avoid clashing with `Level::Bug` and to mirror `FatalAbort`), and modified to work in the new way with bug errors (abort via panic). - Various diagnostic creators and emitters updated to the new, better signatures. Note that `DiagCtxt::bug` no longer needs to call `panic_any`, because `emit` handles that. Also shorten the obnoxiously long `diagnostic_builder_emit_producing_guarantee` name.
This commit is contained in:
parent
3a5f28f7e8
commit
f5459201e0
5 changed files with 76 additions and 76 deletions
|
@ -101,11 +101,15 @@ rustc_data_structures::static_assert_size!(
|
||||||
/// Trait for types that `DiagnosticBuilder::emit` can return as a "guarantee"
|
/// Trait for types that `DiagnosticBuilder::emit` can return as a "guarantee"
|
||||||
/// (or "proof") token that the emission happened.
|
/// (or "proof") token that the emission happened.
|
||||||
pub trait EmissionGuarantee: Sized {
|
pub trait EmissionGuarantee: Sized {
|
||||||
|
/// This exists so that bugs and fatal errors can both result in `!` (an
|
||||||
|
/// abort) when emitted, but have different aborting behaviour.
|
||||||
|
type EmitResult = Self;
|
||||||
|
|
||||||
/// Implementation of `DiagnosticBuilder::emit`, fully controlled by each
|
/// Implementation of `DiagnosticBuilder::emit`, fully controlled by each
|
||||||
/// `impl` of `EmissionGuarantee`, to make it impossible to create a value
|
/// `impl` of `EmissionGuarantee`, to make it impossible to create a value
|
||||||
/// of `Self` without actually performing the emission.
|
/// of `Self::EmitResult` without actually performing the emission.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self;
|
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
impl<'a> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
|
@ -119,7 +123,7 @@ impl<'a> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
|
|
||||||
// FIXME(eddyb) make `ErrorGuaranteed` impossible to create outside `.emit()`.
|
// FIXME(eddyb) make `ErrorGuaranteed` impossible to create outside `.emit()`.
|
||||||
impl EmissionGuarantee for ErrorGuaranteed {
|
impl EmissionGuarantee for ErrorGuaranteed {
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&DiagCtxt` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(dcx) => {
|
DiagnosticBuilderState::Emittable(dcx) => {
|
||||||
|
@ -160,7 +164,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
|
||||||
|
|
||||||
// FIXME(eddyb) should there be a `Option<ErrorGuaranteed>` impl as well?
|
// FIXME(eddyb) should there be a `Option<ErrorGuaranteed>` impl as well?
|
||||||
impl EmissionGuarantee for () {
|
impl EmissionGuarantee for () {
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&DiagCtxt` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(dcx) => {
|
DiagnosticBuilderState::Emittable(dcx) => {
|
||||||
|
@ -174,34 +178,15 @@ impl EmissionGuarantee for () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Marker type which enables implementation of `create_note` and `emit_note` functions for
|
|
||||||
/// note-without-error struct diagnostics.
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub struct Noted;
|
|
||||||
|
|
||||||
impl EmissionGuarantee for Noted {
|
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
|
||||||
match db.inner.state {
|
|
||||||
// First `.emit()` call, the `&DiagCtxt` is still available.
|
|
||||||
DiagnosticBuilderState::Emittable(dcx) => {
|
|
||||||
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
|
||||||
dcx.emit_diagnostic_without_consuming(&mut db.inner.diagnostic);
|
|
||||||
}
|
|
||||||
// `.emit()` was previously called, disallowed from repeating it.
|
|
||||||
DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Noted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Marker type which enables implementation of `create_bug` and `emit_bug` functions for
|
/// Marker type which enables implementation of `create_bug` and `emit_bug` functions for
|
||||||
/// bug struct diagnostics.
|
/// bug diagnostics.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Bug;
|
pub struct BugAbort;
|
||||||
|
|
||||||
impl EmissionGuarantee for Bug {
|
impl EmissionGuarantee for BugAbort {
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
type EmitResult = !;
|
||||||
|
|
||||||
|
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&DiagCtxt` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(dcx) => {
|
DiagnosticBuilderState::Emittable(dcx) => {
|
||||||
|
@ -217,8 +202,15 @@ impl EmissionGuarantee for Bug {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EmissionGuarantee for ! {
|
/// Marker type which enables implementation of `create_fatal` and `emit_fatal` functions for
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
/// fatal diagnostics.
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct FatalAbort;
|
||||||
|
|
||||||
|
impl EmissionGuarantee for FatalAbort {
|
||||||
|
type EmitResult = !;
|
||||||
|
|
||||||
|
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&DiagCtxt` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(dcx) => {
|
DiagnosticBuilderState::Emittable(dcx) => {
|
||||||
|
@ -235,7 +227,7 @@ impl EmissionGuarantee for ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
|
impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&DiagCtxt` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(dcx) => {
|
DiagnosticBuilderState::Emittable(dcx) => {
|
||||||
|
@ -313,8 +305,8 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
/// but there are various places that rely on continuing to use `self`
|
/// but there are various places that rely on continuing to use `self`
|
||||||
/// after calling `emit`.
|
/// after calling `emit`.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn emit(&mut self) -> G {
|
pub fn emit(&mut self) -> G::EmitResult {
|
||||||
G::diagnostic_builder_emit_producing_guarantee(self)
|
G::emit_producing_guarantee(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit the diagnostic unless `delay` is true,
|
/// Emit the diagnostic unless `delay` is true,
|
||||||
|
@ -322,7 +314,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
///
|
///
|
||||||
/// See `emit` and `delay_as_bug` for details.
|
/// See `emit` and `delay_as_bug` for details.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn emit_unless(&mut self, delay: bool) -> G {
|
pub fn emit_unless(&mut self, delay: bool) -> G::EmitResult {
|
||||||
if delay {
|
if delay {
|
||||||
self.downgrade_to_delayed_bug();
|
self.downgrade_to_delayed_bug();
|
||||||
}
|
}
|
||||||
|
@ -409,7 +401,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
/// In the meantime, though, callsites are required to deal with the "bug"
|
/// In the meantime, though, callsites are required to deal with the "bug"
|
||||||
/// locally in whichever way makes the most sense.
|
/// locally in whichever way makes the most sense.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn delay_as_bug(&mut self) -> G {
|
pub fn delay_as_bug(&mut self) -> G::EmitResult {
|
||||||
self.downgrade_to_delayed_bug();
|
self.downgrade_to_delayed_bug();
|
||||||
self.emit()
|
self.emit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#![doc(rust_logo)]
|
#![doc(rust_logo)]
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
#![feature(array_windows)]
|
#![feature(array_windows)]
|
||||||
|
#![feature(associated_type_defaults)]
|
||||||
#![feature(extract_if)]
|
#![feature(extract_if)]
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
|
@ -401,7 +402,7 @@ pub use diagnostic::{
|
||||||
AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgValue, DiagnosticId,
|
AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgValue, DiagnosticId,
|
||||||
DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic,
|
DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic,
|
||||||
};
|
};
|
||||||
pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, Noted};
|
pub use diagnostic_builder::{BugAbort, DiagnosticBuilder, EmissionGuarantee, FatalAbort};
|
||||||
pub use diagnostic_impls::{
|
pub use diagnostic_impls::{
|
||||||
DiagnosticArgFromDisplay, DiagnosticSymbolList, ExpectedLifetimeParameter,
|
DiagnosticArgFromDisplay, DiagnosticSymbolList, ExpectedLifetimeParameter,
|
||||||
IndicateAnonymousLifetime, InvalidFlushedDelayedDiagnosticLevel, LabelKind,
|
IndicateAnonymousLifetime, InvalidFlushedDelayedDiagnosticLevel, LabelKind,
|
||||||
|
@ -907,7 +908,7 @@ impl DiagCtxt {
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, !> {
|
) -> DiagnosticBuilder<'_, FatalAbort> {
|
||||||
let mut result = self.struct_fatal(msg);
|
let mut result = self.struct_fatal(msg);
|
||||||
result.set_span(span);
|
result.set_span(span);
|
||||||
result
|
result
|
||||||
|
@ -921,7 +922,7 @@ impl DiagCtxt {
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
code: DiagnosticId,
|
code: DiagnosticId,
|
||||||
) -> DiagnosticBuilder<'_, !> {
|
) -> DiagnosticBuilder<'_, FatalAbort> {
|
||||||
let mut result = self.struct_span_fatal(span, msg);
|
let mut result = self.struct_span_fatal(span, msg);
|
||||||
result.code(code);
|
result.code(code);
|
||||||
result
|
result
|
||||||
|
@ -930,7 +931,10 @@ impl DiagCtxt {
|
||||||
/// Construct a builder at the `Fatal` level with the `msg`.
|
/// Construct a builder at the `Fatal` level with the `msg`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
|
pub fn struct_fatal(
|
||||||
|
&self,
|
||||||
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
) -> DiagnosticBuilder<'_, FatalAbort> {
|
||||||
DiagnosticBuilder::new(self, Level::Fatal, msg)
|
DiagnosticBuilder::new(self, Level::Fatal, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1101,8 +1105,7 @@ impl DiagCtxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> ! {
|
pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> ! {
|
||||||
DiagnosticBuilder::<diagnostic_builder::Bug>::new(self, Bug, msg).emit();
|
DiagnosticBuilder::<BugAbort>::new(self, Bug, msg).emit()
|
||||||
panic::panic_any(ExplicitBug);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1294,37 +1297,34 @@ impl DiagCtxt {
|
||||||
|
|
||||||
pub fn create_fatal<'a>(
|
pub fn create_fatal<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
fatal: impl IntoDiagnostic<'a, !>,
|
fatal: impl IntoDiagnostic<'a, FatalAbort>,
|
||||||
) -> DiagnosticBuilder<'a, !> {
|
) -> DiagnosticBuilder<'a, FatalAbort> {
|
||||||
fatal.into_diagnostic(self, Level::Fatal)
|
fatal.into_diagnostic(self, Level::Fatal)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
|
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, FatalAbort>) -> ! {
|
||||||
self.create_fatal(fatal).emit()
|
self.create_fatal(fatal).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_bug<'a>(
|
pub fn create_bug<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
bug: impl IntoDiagnostic<'a, diagnostic_builder::Bug>,
|
bug: impl IntoDiagnostic<'a, BugAbort>,
|
||||||
) -> DiagnosticBuilder<'a, diagnostic_builder::Bug> {
|
) -> DiagnosticBuilder<'a, BugAbort> {
|
||||||
bug.into_diagnostic(self, Level::Bug)
|
bug.into_diagnostic(self, Level::Bug)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emit_bug<'a>(
|
pub fn emit_bug<'a>(&'a self, bug: impl IntoDiagnostic<'a, BugAbort>) -> ! {
|
||||||
&'a self,
|
|
||||||
bug: impl IntoDiagnostic<'a, diagnostic_builder::Bug>,
|
|
||||||
) -> diagnostic_builder::Bug {
|
|
||||||
self.create_bug(bug).emit()
|
self.create_bug(bug).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, Noted>) -> Noted {
|
pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, ()>) {
|
||||||
self.create_note(note).emit()
|
self.create_note(note).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_note<'a>(
|
pub fn create_note<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
note: impl IntoDiagnostic<'a, Noted>,
|
note: impl IntoDiagnostic<'a, ()>,
|
||||||
) -> DiagnosticBuilder<'a, Noted> {
|
) -> DiagnosticBuilder<'a, ()> {
|
||||||
note.into_diagnostic(self, Level::Note)
|
note.into_diagnostic(self, Level::Note)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@ use rustc_ast::ast::{self, AttrStyle};
|
||||||
use rustc_ast::token::{self, CommentKind, Delimiter, Token, TokenKind};
|
use rustc_ast::token::{self, CommentKind, Delimiter, Token, TokenKind};
|
||||||
use rustc_ast::tokenstream::TokenStream;
|
use rustc_ast::tokenstream::TokenStream;
|
||||||
use rustc_ast::util::unicode::contains_text_flow_control_chars;
|
use rustc_ast::util::unicode::contains_text_flow_control_chars;
|
||||||
use rustc_errors::{error_code, Applicability, Diagnostic, DiagnosticBuilder, StashKey};
|
use rustc_errors::{
|
||||||
|
error_code, Applicability, Diagnostic, DiagnosticBuilder, FatalAbort, StashKey,
|
||||||
|
};
|
||||||
use rustc_lexer::unescape::{self, EscapeError, Mode};
|
use rustc_lexer::unescape::{self, EscapeError, Mode};
|
||||||
use rustc_lexer::{Base, DocStyle, RawStrError};
|
use rustc_lexer::{Base, DocStyle, RawStrError};
|
||||||
use rustc_lexer::{Cursor, LiteralKind};
|
use rustc_lexer::{Cursor, LiteralKind};
|
||||||
|
@ -344,7 +346,7 @@ impl<'a> StringReader<'a> {
|
||||||
to_pos: BytePos,
|
to_pos: BytePos,
|
||||||
m: &str,
|
m: &str,
|
||||||
c: char,
|
c: char,
|
||||||
) -> DiagnosticBuilder<'a, !> {
|
) -> DiagnosticBuilder<'a, FatalAbort> {
|
||||||
self.sess
|
self.sess
|
||||||
.dcx
|
.dcx
|
||||||
.struct_span_fatal(self.mk_sp(from_pos, to_pos), format!("{}: {}", m, escaped_char(c)))
|
.struct_span_fatal(self.mk_sp(from_pos, to_pos), format!("{}: {}", m, escaped_char(c)))
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
|
||||||
use rustc_errors::{emitter::SilentEmitter, DiagCtxt};
|
use rustc_errors::{emitter::SilentEmitter, DiagCtxt};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
fallback_fluent_bundle, Diagnostic, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
|
fallback_fluent_bundle, Diagnostic, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
|
||||||
ErrorGuaranteed, IntoDiagnostic, Level, MultiSpan, Noted, StashKey,
|
ErrorGuaranteed, FatalAbort, IntoDiagnostic, Level, MultiSpan, StashKey,
|
||||||
};
|
};
|
||||||
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
|
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
|
@ -346,26 +346,26 @@ impl ParseSess {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn create_note<'a>(
|
pub fn create_note<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
note: impl IntoDiagnostic<'a, Noted>,
|
note: impl IntoDiagnostic<'a, ()>,
|
||||||
) -> DiagnosticBuilder<'a, Noted> {
|
) -> DiagnosticBuilder<'a, ()> {
|
||||||
note.into_diagnostic(&self.dcx, Level::Note)
|
note.into_diagnostic(&self.dcx, Level::Note)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, Noted>) -> Noted {
|
pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, ()>) {
|
||||||
self.create_note(note).emit()
|
self.create_note(note).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn create_fatal<'a>(
|
pub fn create_fatal<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
fatal: impl IntoDiagnostic<'a, !>,
|
fatal: impl IntoDiagnostic<'a, FatalAbort>,
|
||||||
) -> DiagnosticBuilder<'a, !> {
|
) -> DiagnosticBuilder<'a, FatalAbort> {
|
||||||
fatal.into_diagnostic(&self.dcx, Level::Fatal)
|
fatal.into_diagnostic(&self.dcx, Level::Fatal)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
|
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, FatalAbort>) -> ! {
|
||||||
self.create_fatal(fatal).emit()
|
self.create_fatal(fatal).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +386,10 @@ impl ParseSess {
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
|
pub fn struct_fatal(
|
||||||
|
&self,
|
||||||
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
) -> DiagnosticBuilder<'_, FatalAbort> {
|
||||||
self.dcx.struct_fatal(msg)
|
self.dcx.struct_fatal(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ use rustc_errors::json::JsonEmitter;
|
||||||
use rustc_errors::registry::Registry;
|
use rustc_errors::registry::Registry;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
error_code, fallback_fluent_bundle, DiagCtxt, DiagnosticBuilder, DiagnosticId,
|
error_code, fallback_fluent_bundle, DiagCtxt, DiagnosticBuilder, DiagnosticId,
|
||||||
DiagnosticMessage, ErrorGuaranteed, FluentBundle, IntoDiagnostic, LazyFallbackBundle,
|
DiagnosticMessage, ErrorGuaranteed, FatalAbort, FluentBundle, IntoDiagnostic,
|
||||||
MultiSpan, Noted, TerminalUrl,
|
LazyFallbackBundle, MultiSpan, TerminalUrl,
|
||||||
};
|
};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
pub use rustc_span::def_id::StableCrateId;
|
pub use rustc_span::def_id::StableCrateId;
|
||||||
|
@ -428,7 +428,7 @@ impl Session {
|
||||||
&self,
|
&self,
|
||||||
sp: S,
|
sp: S,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, !> {
|
) -> DiagnosticBuilder<'_, FatalAbort> {
|
||||||
self.dcx().struct_span_fatal(sp, msg)
|
self.dcx().struct_span_fatal(sp, msg)
|
||||||
}
|
}
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
|
@ -437,11 +437,14 @@ impl Session {
|
||||||
sp: S,
|
sp: S,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
code: DiagnosticId,
|
code: DiagnosticId,
|
||||||
) -> DiagnosticBuilder<'_, !> {
|
) -> DiagnosticBuilder<'_, FatalAbort> {
|
||||||
self.dcx().struct_span_fatal_with_code(sp, msg, code)
|
self.dcx().struct_span_fatal_with_code(sp, msg, code)
|
||||||
}
|
}
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
|
pub fn struct_fatal(
|
||||||
|
&self,
|
||||||
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
) -> DiagnosticBuilder<'_, FatalAbort> {
|
||||||
self.dcx().struct_fatal(msg)
|
self.dcx().struct_fatal(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,23 +528,23 @@ impl Session {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn create_note<'a>(
|
pub fn create_note<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
note: impl IntoDiagnostic<'a, Noted>,
|
note: impl IntoDiagnostic<'a, ()>,
|
||||||
) -> DiagnosticBuilder<'a, Noted> {
|
) -> DiagnosticBuilder<'a, ()> {
|
||||||
self.parse_sess.create_note(note)
|
self.parse_sess.create_note(note)
|
||||||
}
|
}
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, Noted>) -> Noted {
|
pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, ()>) {
|
||||||
self.parse_sess.emit_note(note)
|
self.parse_sess.emit_note(note)
|
||||||
}
|
}
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn create_fatal<'a>(
|
pub fn create_fatal<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
fatal: impl IntoDiagnostic<'a, !>,
|
fatal: impl IntoDiagnostic<'a, FatalAbort>,
|
||||||
) -> DiagnosticBuilder<'a, !> {
|
) -> DiagnosticBuilder<'a, FatalAbort> {
|
||||||
self.parse_sess.create_fatal(fatal)
|
self.parse_sess.create_fatal(fatal)
|
||||||
}
|
}
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
|
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, FatalAbort>) -> ! {
|
||||||
self.parse_sess.emit_fatal(fatal)
|
self.parse_sess.emit_fatal(fatal)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1780,7 +1783,7 @@ impl EarlyDiagCtxt {
|
||||||
pub fn early_struct_error(
|
pub fn early_struct_error(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, !> {
|
) -> DiagnosticBuilder<'_, FatalAbort> {
|
||||||
self.dcx.struct_fatal(msg)
|
self.dcx.struct_fatal(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue