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
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.
- 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