Struct rustc_errors::DiagCtxt

source ·
pub struct DiagCtxt {
    pub(crate) inner: Lock<DiagCtxtInner>,
}
Expand description

A DiagCtxt deals with errors and other compiler output. Certain errors (fatal, bug, unimpl) may cause immediate exit, others log errors for later reporting.

Fields§

§inner: Lock<DiagCtxtInner>

Implementations§

source§

impl DiagCtxt

source

pub fn with_tty_emitter( sm: Option<Lrc<SourceMap>>, fallback_bundle: LazyFallbackBundle ) -> Self

source

pub fn disable_warnings(self) -> Self

source

pub fn with_flags(self, flags: DiagCtxtFlags) -> Self

source

pub fn with_ice_file(self, ice_file: PathBuf) -> Self

source

pub fn with_emitter(emitter: Box<DynEmitter>) -> Self

source

pub fn eagerly_translate<'a>( &self, message: DiagnosticMessage, args: impl Iterator<Item = DiagnosticArg<'a>> ) -> SubdiagnosticMessage

Translate message eagerly with args to SubdiagnosticMessage::Eager.

source

pub fn eagerly_translate_to_string<'a>( &self, message: DiagnosticMessage, args: impl Iterator<Item = DiagnosticArg<'a>> ) -> String

Translate message eagerly with args to String.

source

pub fn can_emit_warnings(&self) -> bool

source

pub fn reset_err_count(&self)

Resets the diagnostic error count as well as the cached emitted diagnostics.

NOTE: do not call this function from rustc. It is only meant to be called from external tools that want to reuse a Parser cleaning the previously emitted diagnostics as well as the overall count of emitted error diagnostics.

source

pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic)

Stash a given diagnostic with the given Span and StashKey as the key. Retrieve a stashed diagnostic with steal_diagnostic.

source

pub fn steal_diagnostic( &self, span: Span, key: StashKey ) -> Option<DiagnosticBuilder<'_, ()>>

Steal a previously stashed diagnostic with the given Span and StashKey as the key.

source

pub fn has_stashed_diagnostic(&self, span: Span, key: StashKey) -> bool

source

pub fn emit_stashed_diagnostics(&self)

Emit all stashed diagnostics.

source

pub fn err_count(&self) -> usize

This excludes lint errors, delayed bugs, and stashed errors.

source

pub fn stashed_err_count(&self) -> usize

This excludes normal errors, lint errors and delayed bugs. Unless absolutely necessary, avoid using this. It’s dubious because stashed errors can later be cancelled, so the presence of a stashed error at some point of time doesn’t guarantee anything – there are no ErrorGuaranteeds here.

source

pub fn has_errors(&self) -> Option<ErrorGuaranteed>

This excludes lint errors, delayed bugs, and stashed errors.

source

pub fn has_errors_or_lint_errors(&self) -> Option<ErrorGuaranteed>

This excludes delayed bugs and stashed errors. Unless absolutely necessary, prefer has_errors to this method.

source

pub fn has_errors_or_lint_errors_or_delayed_bugs( &self ) -> Option<ErrorGuaranteed>

This excludes stashed errors. Unless absolutely necessary, prefer has_errors or has_errors_or_lint_errors to this method.

source

pub fn print_error_count(&self, registry: &Registry)

source

pub fn abort_if_errors(&self)

source

pub fn must_teach(&self, code: ErrCode) -> bool

true if we haven’t taught a diagnostic with this code already. The caller must then teach the user about such a diagnostic.

Used to suppress emitting the same error multiple times with extended explanation when calling -Zteach.

source

pub fn force_print_diagnostic(&self, db: Diagnostic)

source

pub fn emit_diagnostic(&self, diagnostic: Diagnostic) -> Option<ErrorGuaranteed>

source

pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str)

source

pub fn emit_future_breakage_report(&self)

source

pub fn emit_unused_externs( &self, lint_level: Level, loud: bool, unused_externs: &[&str] )

source

pub fn update_unstable_expectation_id( &self, unstable_to_stable: &FxIndexMap<LintExpectationId, LintExpectationId> )

source

pub fn steal_fulfilled_expectation_ids(&self) -> FxHashSet<LintExpectationId>

This methods steals all LintExpectationIds that are stored inside DiagCtxtInner and indicate that the linked expectation has been fulfilled.

source

pub fn flush_delayed(&self)

source§

impl DiagCtxt

source

pub fn struct_bug( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, BugAbort>

source

pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> !

source

pub fn struct_span_bug( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, BugAbort>

source

pub fn span_bug( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> !

source

pub fn create_bug<'a>( &'a self, bug: impl IntoDiagnostic<'a, BugAbort> ) -> DiagnosticBuilder<'a, BugAbort>

source

pub fn emit_bug<'a>(&'a self, bug: impl IntoDiagnostic<'a, BugAbort>) -> !

source

pub fn struct_fatal( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, FatalAbort>

source

pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> !

source

pub fn struct_span_fatal( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, FatalAbort>

source

pub fn span_fatal( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> !

source

pub fn create_fatal<'a>( &'a self, fatal: impl IntoDiagnostic<'a, FatalAbort> ) -> DiagnosticBuilder<'a, FatalAbort>

source

pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, FatalAbort>) -> !

source

pub fn create_almost_fatal<'a>( &'a self, fatal: impl IntoDiagnostic<'a, FatalError> ) -> DiagnosticBuilder<'a, FatalError>

source

pub fn emit_almost_fatal<'a>( &'a self, fatal: impl IntoDiagnostic<'a, FatalError> ) -> FatalError

source

pub fn struct_err( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_>

source

pub fn err(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed

source

pub fn struct_span_err( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_>

source

pub fn span_err( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> ErrorGuaranteed

source

pub fn create_err<'a>( &'a self, err: impl IntoDiagnostic<'a> ) -> DiagnosticBuilder<'a>

source

pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed

source

pub fn delayed_bug(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed

Ensures that an error is printed. See Level::DelayedBug.

source

pub fn span_delayed_bug( &self, sp: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> ErrorGuaranteed

Ensures that an error is printed. See Level::DelayedBug.

Note: this function used to be called delay_span_bug. It was renamed to match similar functions like span_err, span_warn, etc.

source

pub fn good_path_delayed_bug(&self, msg: impl Into<DiagnosticMessage>)

Ensures that a diagnostic is printed. See Level::GoodPathDelayedBug.

source

pub fn struct_warn( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>

source

pub fn warn(&self, msg: impl Into<DiagnosticMessage>)

source

pub fn struct_span_warn( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>

source

pub fn span_warn( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> )

source

pub fn create_warn<'a>( &'a self, warning: impl IntoDiagnostic<'a, ()> ) -> DiagnosticBuilder<'a, ()>

source

pub fn emit_warn<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>)

source

pub fn struct_note( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>

source

pub fn note(&self, msg: impl Into<DiagnosticMessage>)

source

pub fn struct_span_note( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>

source

pub fn span_note( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> )

source

pub fn create_note<'a>( &'a self, note: impl IntoDiagnostic<'a, ()> ) -> DiagnosticBuilder<'a, ()>

source

pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, ()>)

source

pub fn struct_help( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>

source

pub fn struct_allow( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>

source

pub fn struct_expect( &self, msg: impl Into<DiagnosticMessage>, id: LintExpectationId ) -> DiagnosticBuilder<'_, ()>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 448 bytes