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
impl DiagCtxt
pub fn with_tty_emitter( sm: Option<Lrc<SourceMap>>, fallback_bundle: LazyFallbackBundle ) -> Self
pub fn disable_warnings(self) -> Self
pub fn with_flags(self, flags: DiagCtxtFlags) -> Self
pub fn with_ice_file(self, ice_file: PathBuf) -> Self
pub fn with_emitter(emitter: Box<DynEmitter>) -> Self
sourcepub fn eagerly_translate<'a>(
&self,
message: DiagnosticMessage,
args: impl Iterator<Item = DiagnosticArg<'a>>
) -> SubdiagnosticMessage
pub fn eagerly_translate<'a>( &self, message: DiagnosticMessage, args: impl Iterator<Item = DiagnosticArg<'a>> ) -> SubdiagnosticMessage
Translate message
eagerly with args
to SubdiagnosticMessage::Eager
.
sourcepub fn eagerly_translate_to_string<'a>(
&self,
message: DiagnosticMessage,
args: impl Iterator<Item = DiagnosticArg<'a>>
) -> String
pub fn eagerly_translate_to_string<'a>( &self, message: DiagnosticMessage, args: impl Iterator<Item = DiagnosticArg<'a>> ) -> String
Translate message
eagerly with args
to String
.
pub fn can_emit_warnings(&self) -> bool
sourcepub fn reset_err_count(&self)
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.
sourcepub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic)
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
.
sourcepub fn steal_diagnostic(
&self,
span: Span,
key: StashKey
) -> Option<DiagnosticBuilder<'_, ()>>
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.
pub fn has_stashed_diagnostic(&self, span: Span, key: StashKey) -> bool
sourcepub fn emit_stashed_diagnostics(&self) -> Option<ErrorGuaranteed>
pub fn emit_stashed_diagnostics(&self) -> Option<ErrorGuaranteed>
Emit all stashed diagnostics.
sourcepub fn struct_span_warn(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ()>
pub fn struct_span_warn( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>
Construct a builder at the Warning
level at the given span
and with the msg
.
An emit
call on the builder will only emit if can_emit_warnings
is true
.
sourcepub fn struct_warn(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ()>
pub fn struct_warn( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>
Construct a builder at the Warning
level with the msg
.
An emit
call on the builder will only emit if can_emit_warnings
is true
.
sourcepub fn struct_allow(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ()>
pub fn struct_allow( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>
Construct a builder at the Allow
level with the msg
.
sourcepub fn struct_expect(
&self,
msg: impl Into<DiagnosticMessage>,
id: LintExpectationId
) -> DiagnosticBuilder<'_, ()>
pub fn struct_expect( &self, msg: impl Into<DiagnosticMessage>, id: LintExpectationId ) -> DiagnosticBuilder<'_, ()>
Construct a builder at the Expect
level with the msg
.
sourcepub fn struct_span_err(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_>
pub fn struct_span_err( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_>
Construct a builder at the Error
level at the given span
and with the msg
.
sourcepub fn struct_err(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_>
pub fn struct_err( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_>
Construct a builder at the Error
level with the msg
.
sourcepub fn struct_span_fatal(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, FatalAbort>
pub fn struct_span_fatal( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, FatalAbort>
Construct a builder at the Fatal
level at the given span
and with the msg
.
sourcepub fn struct_fatal(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, FatalAbort>
pub fn struct_fatal( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, FatalAbort>
Construct a builder at the Fatal
level with the msg
.
sourcepub fn struct_help(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ()>
pub fn struct_help( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>
Construct a builder at the Help
level with the msg
.
sourcepub fn struct_note(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ()>
pub fn struct_note( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>
Construct a builder at the Note
level with the msg
.
sourcepub fn struct_bug(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, BugAbort>
pub fn struct_bug( &self, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, BugAbort>
Construct a builder at the Bug
level with the msg
.
sourcepub fn struct_span_bug(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, BugAbort>
pub fn struct_span_bug( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, BugAbort>
Construct a builder at the Bug
level at the given span
with the msg
.
pub fn span_fatal( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> !
pub fn span_err( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> ErrorGuaranteed
pub fn span_warn( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> )
pub fn span_bug( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> !
sourcepub fn delayed_bug(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed
pub fn delayed_bug(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed
Ensures that compilation cannot succeed.
If this function has been called but no errors have been emitted and compilation succeeds, it will cause an internal compiler error (ICE).
This can be used in code paths that should never run on successful compilations.
For example, it can be used to create an ErrorGuaranteed
(but you should prefer threading through the ErrorGuaranteed
from an error emission
directly).
sourcepub fn span_delayed_bug(
&self,
sp: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>
) -> ErrorGuaranteed
pub fn span_delayed_bug( &self, sp: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> ErrorGuaranteed
Like delayed_bug
, but takes an additional span.
Note: this function used to be called delay_span_bug
. It was renamed
to match similar functions like span_err
, span_warn
, etc.
pub fn good_path_delayed_bug(&self, msg: impl Into<DiagnosticMessage>)
pub fn span_note( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> )
pub fn struct_span_note( &self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage> ) -> DiagnosticBuilder<'_, ()>
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> !
pub fn err(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed
pub fn warn(&self, msg: impl Into<DiagnosticMessage>)
pub fn note(&self, msg: impl Into<DiagnosticMessage>)
pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> !
sourcepub fn has_errors(&self) -> Option<ErrorGuaranteed>
pub fn has_errors(&self) -> Option<ErrorGuaranteed>
This excludes lint errors and delayed bugs.
sourcepub fn has_errors_or_lint_errors(&self) -> Option<ErrorGuaranteed>
pub fn has_errors_or_lint_errors(&self) -> Option<ErrorGuaranteed>
This excludes delayed bugs. Unless absolutely necessary, prefer
has_errors
to this method.
sourcepub fn has_errors_or_lint_errors_or_delayed_bugs(
&self
) -> Option<ErrorGuaranteed>
pub fn has_errors_or_lint_errors_or_delayed_bugs( &self ) -> Option<ErrorGuaranteed>
Unless absolutely necessary, prefer has_errors
or
has_errors_or_lint_errors
to this method.
pub fn print_error_count(&self, registry: &Registry)
pub fn take_future_breakage_diagnostics(&self) -> Vec<Diagnostic>
pub fn abort_if_errors(&self)
sourcepub fn must_teach(&self, code: ErrCode) -> bool
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
.
pub fn force_print_diagnostic(&self, db: Diagnostic)
pub fn emit_diagnostic(&self, diagnostic: Diagnostic) -> Option<ErrorGuaranteed>
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed
pub fn create_err<'a>( &'a self, err: impl IntoDiagnostic<'a> ) -> DiagnosticBuilder<'a>
pub fn create_warn<'a>( &'a self, warning: impl IntoDiagnostic<'a, ()> ) -> DiagnosticBuilder<'a, ()>
pub fn emit_warn<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>)
pub fn create_almost_fatal<'a>( &'a self, fatal: impl IntoDiagnostic<'a, FatalError> ) -> DiagnosticBuilder<'a, FatalError>
pub fn emit_almost_fatal<'a>( &'a self, fatal: impl IntoDiagnostic<'a, FatalError> ) -> FatalError
pub fn create_fatal<'a>( &'a self, fatal: impl IntoDiagnostic<'a, FatalAbort> ) -> DiagnosticBuilder<'a, FatalAbort>
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, FatalAbort>) -> !
pub fn create_bug<'a>( &'a self, bug: impl IntoDiagnostic<'a, BugAbort> ) -> DiagnosticBuilder<'a, BugAbort>
pub fn emit_bug<'a>(&'a self, bug: impl IntoDiagnostic<'a, BugAbort>) -> !
pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, ()>)
pub fn create_note<'a>( &'a self, note: impl IntoDiagnostic<'a, ()> ) -> DiagnosticBuilder<'a, ()>
pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str)
pub fn emit_future_breakage_report(&self, diags: Vec<Diagnostic>)
pub fn emit_unused_externs( &self, lint_level: Level, loud: bool, unused_externs: &[&str] )
pub fn update_unstable_expectation_id( &self, unstable_to_stable: &FxIndexMap<LintExpectationId, LintExpectationId> )
sourcepub fn steal_fulfilled_expectation_ids(&self) -> FxHashSet<LintExpectationId>
pub fn steal_fulfilled_expectation_ids(&self) -> FxHashSet<LintExpectationId>
This methods steals all LintExpectationId
s that are stored inside
DiagCtxtInner
and indicate that the linked expectation has been fulfilled.
pub fn flush_delayed(&self)
Auto Trait Implementations§
impl !RefUnwindSafe for DiagCtxt
impl !Send for DiagCtxt
impl !Sync for DiagCtxt
impl Unpin for DiagCtxt
impl !UnwindSafe for DiagCtxt
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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: 408 bytes