Crate rustc_errors
source ·Expand description
Diagnostics creation and emission for rustc.
This module contains the code for creating and emitting diagnostics.
Re-exports§
pub use emitter::ColorConfig;pub use rustc_error_messages::fluent_bundle;pub use codes::*;
Modules§
- Emit diagnostics using the
annotate-snippetslibrary - This module defines the following.
- The current rustc diagnostics emitter.
- A JSON emitter for errors.
- lock 🔒Bindings to acquire a global named lock.
- A simple markdown parser that can write formatted text to the terminal
- snippet 🔒
Macros§
Structs§
- Marker type which enables implementation of
create_bugandemit_bugfunctions for bug diagnostics. - A color specification.
- A workaround for must_produce_diag ICEs when formatting types in disabled lints.
- Signifies that the compiler died due to a delayed bug rather than a failed assertion, etc.
- A
DiagCtxtdeals with errors and other compiler output. Certain errors (fatal, bug, unimpl) may cause immediate exit, others log errors for later reporting. - This inner struct exists to keep it all behind a single lock; this is done to prevent possible deadlocks in a multi-threaded compiler, as well as inconsistent state observation.
- The main part of a diagnostic. Note that
DiagnosticBuilder, which wraps this type, is used for most operations, and should be used instead whenever possible. This type should only be used whenDiagnosticBuilder’s lifetime causes difficulties, e.g. when storing diagnostics withinDiagCtxt. - Used for emitting structured error messages and other diagnostic information. Wraps a
Diagnostic, adding some useful things. - Useful type to use with
Result<>indicate that an error has already been reported to the user, so no need to continue checking. - Signifies that the compiler died with an explicit call to
.bugor.span_bugrather than a failed assertion, etc. - Marker type which enables implementation of
create_fatalandemit_fatalfunctions for fatal diagnostics. - Used as a return value to signify a fatal error occurred.
- This is a marker for a fatal compiler error used with
resume_unwind. LanguageIdentifieris a core struct representing a Unicode Language Identifier.- A collection of
Spans. - Utility struct used to apply a single label while highlighting multiple spans
- A span together with some additional data.
- A “sub”-diagnostic attached to a parent diagnostic. For example, a note attached to an error.
- See the docs on
CodeSuggestion::substitutions - Used to translate between
Spans and byte positions within a single output line in highlighted code of structured suggestions.
Enums§
- Indicates the confidence in the correctness of a suggestion.
- The set of available colors for the terminal foreground/background.
- Simplified version of
FluentValuethat can implementEncodableandDecodable. Converted to aFluentValueby the emitter to be used in diagnostic translation. - Abstraction over a message in a diagnostic to support both translatable and non-translatable diagnostic messages.
- Level is_error EmissionGuarantee Top-level Sub Used in lints?
- A key denoting where from a diagnostic was stashed.
- Abstraction over a message in a subdiagnostic (i.e. label, note, help, etc) to support both translatable and non-translatable diagnostic messages.
Statics§
- Raw content of Fluent resource for this crate, generated by
fluent_messagesmacro, imported byrustc_driverto include all crates’ resources in one bundle.
Traits§
- Trait implemented by error types. This should not be implemented manually. Instead, use
#[derive(Subdiagnostic)]– see rustc_macros::Subdiagnostic. - Trait implemented by lint types. This should not be implemented manually. Instead, use
#[derive(LintDiagnostic)]– see rustc_macros::LintDiagnostic. - Trait for types that
DiagnosticBuilder::emitcan return as a “guarantee” (or “proof”) token that the emission happened. - Trait implemented by error types. This is rarely implemented manually. Instead, use
#[derive(Diagnostic)]– see rustc_macros::Diagnostic. - Converts a value of a type into a
DiagnosticArg(typically a field of anIntoDiagnosticstruct). Implemented as a custom trait rather thanFromso that it is implemented on the type being converted rather than onDiagnosticArgValue, which enables types from otherrustc_*crates to implement this. - This trait describes the behavior of writers that support colored output.
Functions§
- Return the default
FluentBundlewith standard “en-US” diagnostic messages. - Returns Fluent bundle with the user’s locale resources from
$sysroot/share/locale/$requested_locale/*.ftl.
Type Aliases§
- Simplified version of
FluentArgthat can implementEncodableandDecodable. Collection ofDiagnosticArgare converted toFluentArgs(consuming the collection) at the start of diagnostic emission. - Name of a diagnostic argument.
- Type alias for the result of
fallback_fluent_bundle- a reference-counted pointer to a lazily evaluated fluent bundle.