Expand description
Diagnostics creation and emission for rustc.
This module contains the code for creating and emitting diagnostics.
Re-exportsΒ§
pub use decorate_diag::BufferedEarlyLint;pub use decorate_diag::DecorateDiagCompat;pub use decorate_diag::LintBuffer;pub use diagnostic::Diag;pub use diagnostic::DiagDecorator;pub use diagnostic::DiagInner;pub use diagnostic::DiagLocation;pub use diagnostic::DiagStyledString;pub use diagnostic::Diagnostic;pub use diagnostic::StringPart;pub use diagnostic::Subdiag;pub use diagnostic::Subdiagnostic;pub use diagnostic_impls::DiagSymbolList;pub use diagnostic_impls::ElidedLifetimeInPathSubdiag;pub use diagnostic_impls::ExpectedLifetimeParameter;pub use diagnostic_impls::IndicateAnonymousLifetime;pub use diagnostic_impls::SingleLabelManySpans;pub use emitter::ColorConfig;pub(crate) use emitter::DynEmitter;πpub(crate) use emitter::Emitter;πpub(crate) use crate::emitter::TimingEvent;πpub(crate) use crate::formatting::DiagMessageAddArg;πpub use crate::formatting::format_diag_message;pub(crate) use crate::timings::TimingRecord;πpub(crate) use Backtrace;πpub(crate) use BacktraceStatus;πpub(crate) use std::borrow::Cow;πpub(crate) use std::cell::Cell;πpub(crate) use std::ffi::OsStr;πpub(crate) use std::hash::Hash;πpub(crate) use std::hash::Hash;πpub(crate) use std::io::Write;πpub(crate) use std::num::NonZero;πpub(crate) use std::ops::DerefMut;πpub(crate) use Path;πpub(crate) use PathBuf;πpub(crate) use std::thread::ThreadId;πpub(crate) use assert_matches;πpub(crate) use fmt;πpub(crate) use mem;πpub(crate) use panic;πpub(crate) use panic;πpub(crate) use rustc_ast::attr::version::RustcVersion;πpub(crate) use rustc_data_structures::AtomicRef;πpub(crate) use FxHashSet;πpub(crate) use FxIndexMap;πpub(crate) use FxIndexSet;πpub(crate) use DynSend;πpub(crate) use Lock;πpub use fluent_bundle;pub(crate) use rustc_hashes::Hash128;πpub(crate) use rustc_lint_defs::LintExpectationId;πpub(crate) use Decodable;πpub(crate) use Encodable;πpub(crate) use rustc_span::source_map::SourceMap;πpub(crate) use DUMMY_SP;πpub(crate) use Span;πpub(crate) use tracing::debug;πpub(crate) use Level::*;πpub use codes::*;
ModulesΒ§
- annotate_
snippet_ emitter_ writer - Emit diagnostics using the
annotate-snippetslibrary - codes
- This module defines the following.
- decorate_
diag π - dedup_
hash π - diagnostic π
- diagnostic_
impls π - emitter
- The current rustc diagnostics emitter.
- formatting
- 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
- timings
MacrosΒ§
- into_
diag_ arg_ using_ display - msg
- This macro creates a translatable
DiagMessagefrom a fluent format string. It should be used in places where a translatable message is needed, but struct diagnostics are undesired. - pluralize
- struct_
span_ code_ err
StructsΒ§
- Ansi256
Color - 256 (8-bit) color support
- Anstyle
- ANSI Text styling
- Auto
Stream std::io::Writethat adapts ANSI escape codes to the underlyingWrites capabilities- Code
Suggestion - Delayed
BugPanic - Signifies that the compiler died due to a delayed bug rather than a failed assertion, etc.
- Delayed
Diag πInner - 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.
- Effect
Iter - Enumerate each enabled value in
Effects - Effects
- A set of text effects
- 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. - Explicit
Bug - Signifies that the compiler died with an explicit call to
.bugor.span_bugrather than a failed assertion, etc. - 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. - Language
Identifier LanguageIdentifieris a core struct representing a Unicode Language Identifier.- Multi
Span - A collection of
Spans. - Reset
- Reset terminal formatting
- RgbColor
- 24-bit ANSI RGB color codes
- Span
Label - A span together with some additional data.
- Substitution
- See the docs on
CodeSuggestion::substitutions - Substitution
Part - Trimmed
Substitution Part
EnumsΒ§
- Ansi
Color - Available 4-bit ANSI color palette codes
- Applicability
- Indicates the confidence in the correctness of a suggestion.
- Color
- Any ANSI color code scheme
- Color
Choice - Selection for overriding color output Selection for overriding color output
- 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.
- Emission
Override - Special emission behaviours on warning diagnostics. Combines with
DiagInner::is_lintin the following ways. - Level
- Stash
Key - A key denoting where from a diagnostic was stashed.
- Style
- Sublevel
- The level for a subdiagnostic.
- Suggestion
Style - Suggestions
- Represents the help messages seen on a diagnostic.
- Terminal
Url
StaticsΒ§
- TRACK_
DIAGNOSTIC - Diagnostics emitted by
DiagCtxtInner::emit_diagnosticare passed through this function. Used for tracking by incremental, to replay diagnostics as necessary.
TraitsΒ§
- 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.
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. - catch_
fatal_ errors - Runs a closure and catches unwinds triggered by fatal errors.
- default_
track_ πdiagnostic - elided_
lifetime_ in_ path_ suggestion - listify
- Grammatical tool for displaying messages to end users in a nice form.
Type AliasesΒ§
- DiagArg
- Simplified version of
FluentArgthat can implementEncodableandDecodable. Collection ofDiagArgare converted toFluentArgs(consuming the collection) at the start of diagnostic emission. - Diag
ArgMap - A mapping from diagnostic argument names to their values. This contains all the arguments necessary to format a diagnostic message.
- Diag
ArgName - Name of a diagnostic argument.
- PResult