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§
- annotate_
snippet_ emitter_ writer - Emit diagnostics using the
annotate-snippetslibrary - codes
- This module defines the following.
- diagnostic 🔒
- diagnostic_
impls 🔒 - emitter
- The current rustc diagnostics emitter.
- error
- json
- A JSON emitter for errors.
- lock 🔒
- Bindings to acquire a global named lock.
- markdown
- A simple markdown parser that can write formatted text to the terminal
- registry
- snippet 🔒
- styled_
buffer 🔒 - timings
- translation
Macros§
Structs§
- BugAbort
- Marker type which enables implementation of
create_bugandemit_bugfunctions for bug diagnostics. - Code
Suggestion - Color
Spec - A color specification.
- Delayed
BugPanic - Signifies that the compiler died due to a delayed bug rather than a failed assertion, etc.
- Delayed
Diag 🔒Inner - Diag
- Used for emitting structured error messages and other diagnostic information.
Wraps a
DiagInner, adding some useful things. - Diag
ArgFrom Display - Diag
Ctxt - A
DiagCtxtdeals with errors and other compiler output. Certain errors (fatal, bug, unimpl) may cause immediate exit, others log errors for later reporting. - Diag
Ctxt Flags - Diag
Ctxt Handle - Diag
Ctxt 🔒Inner - 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.
- Diag
Inner - The main part of a diagnostic. Note that
Diag, which wraps this type, is used for most operations, and should be used instead whenever possible. This type should only be used whenDiag’s lifetime causes difficulties, e.g. when storing diagnostics withinDiagCtxt. - Diag
Styled String - Diag
Symbol List - Elided
Lifetime InPath Subdiag - Error
Guaranteed - Useful type to use with
Result<>indicate that an error has already been reported to the user, so no need to continue checking. - Expected
Lifetime Parameter - Explicit
Bug - Signifies that the compiler died with an explicit call to
.bugor.span_bugrather than a failed assertion, etc. - Fatal
Abort - Marker type which enables implementation of
create_fatalandemit_fatalfunctions for fatal diagnostics. - Fatal
Error - Used as a return value to signify a fatal error occurred.
- Fatal
Error Marker - This is a marker for a fatal compiler error used with
resume_unwind. - Indicate
Anonymous Lifetime - Language
Identifier LanguageIdentifieris a core struct representing a Unicode Language Identifier.- Multi
Span - A collection of
Spans. - Single
Label Many Spans - Utility struct used to apply a single label while highlighting multiple spans
- Span
Label - A span together with some additional data.
- String
Part - Subdiag
- A “sub”-diagnostic attached to a parent diagnostic. For example, a note attached to an error.
- Substitution
- See the docs on
CodeSuggestion::substitutions - Substitution
Highlight 🔒 - Used to translate between
Spans and byte positions within a single output line in highlighted code of structured suggestions. - Substitution
Part
Enums§
- Applicability
- Indicates the confidence in the correctness of a suggestion.
- Color
- The set of available colors for the terminal foreground/background.
- Diag
ArgValue - Simplified version of
FluentValuethat can implementEncodableandDecodable. Converted to aFluentValueby the emitter to be used in diagnostic translation. - Diag
Message - Abstraction over a message in a diagnostic to support both translatable and non-translatable diagnostic messages.
- Level
- Stash
Key - A key denoting where from a diagnostic was stashed.
- Style
- Subdiag
Message - Abstraction over a message in a subdiagnostic (i.e. label, note, help, etc) to support both translatable and non-translatable diagnostic messages.
- Suggestion
Style - Suggestions
- Represents the help messages seen on a diagnostic.
- Terminal
Url
Statics§
- DEFAULT_
LOCALE_ RESOURCE - Raw content of Fluent resource for this crate, generated by
fluent_messagesmacro, imported byrustc_driverto include all crates’ resources in one bundle. - TRACK_
DIAGNOSTIC - Diagnostics emitted by
DiagCtxtInner::emit_diagnosticare passed through this function. Used for tracking by incremental, to replay diagnostics as necessary.
Traits§
- Diagnostic
- Trait implemented by error types. This is rarely implemented manually. Instead, use
#[derive(Diagnostic)]– see rustc_macros::Diagnostic. - Emission
Guarantee - Trait for types that
Diag::emitcan return as a “guarantee” (or “proof”) token that the emission happened. - Into
Diag Arg - Converts a value of a type into a
DiagArg(typically a field of anDiagstruct). Implemented as a custom trait rather thanFromso that it is implemented on the type being converted rather than onDiagArgValue, which enables types from otherrustc_*crates to implement this. - Lint
Diagnostic - Trait implemented by lint types. This should not be implemented manually. Instead, use
#[derive(LintDiagnostic)]– see rustc_macros::LintDiagnostic. - Lint
Emitter - Used to avoid depending on
rustc_middleinrustc_attr_parsing. Always theTyCtxt. - Subdiagnostic
- Trait implemented by error types. This should not be implemented manually. Instead, use
#[derive(Subdiagnostic)]– see rustc_macros::Subdiagnostic. - Write
Color - This trait describes the behavior of writers that support colored output.
Functions§
- a_or_an
- Grammatical tool for displaying messages to end users in a nice form.
- as_
substr 🔒 - Given an original string like
AACC, and a suggestion likeAABBCC, try to detect the case where a substring of the suggestion is “sandwiched” in the original, likeBBis. Return the length of the prefix, the “trimmed” suggestion, and the length of the suffix. - default_
track_ 🔒diagnostic - elided_
lifetime_ in_ path_ suggestion - fallback_
fluent_ bundle - Return the default
FluentBundlewith standard “en-US” diagnostic messages. - fluent_
bundle - Returns Fluent bundle with the user’s locale resources from
$sysroot/share/locale/$requested_locale/*.ftl. - listify
- Grammatical tool for displaying messages to end users in a nice form.
- report_
ambiguity_ error
Type Aliases§
- DiagArg
- Simplified version of
FluentArgthat can implementEncodableandDecodable. Collection ofDiagArgare converted toFluentArgs(consuming the collection) at the start of diagnostic emission. - Diag
ArgMap - Diag
ArgName - Name of a diagnostic argument.
- Fluent
Bundle - Lazy
Fallback Bundle - Type alias for the result of
fallback_fluent_bundle- a reference-counted pointer to a lazily evaluated fluent bundle. - PResult