Struct rustc_errors::Handler [−][src]
pub struct Handler {
flags: HandlerFlags,
inner: Lock<HandlerInner>,
}
Expand description
A handler deals with errors and other compiler output. Certain errors (fatal, bug, unimpl) may cause immediate exit, others log errors for later reporting.
Fields
flags: HandlerFlags
inner: Lock<HandlerInner>
Implementations
pub fn with_tty_emitter(
color_config: ColorConfig,
can_emit_warnings: bool,
treat_err_as_bug: Option<NonZeroUsize>,
sm: Option<Lrc<SourceMap>>
) -> Self
pub fn with_tty_emitter_and_flags(
color_config: ColorConfig,
sm: Option<Lrc<SourceMap>>,
flags: HandlerFlags
) -> Self
pub fn with_emitter(
can_emit_warnings: bool,
treat_err_as_bug: Option<NonZeroUsize>,
emitter: Box<dyn Emitter + Send>
) -> 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.
Stash a given diagnostic with the given Span
and StashKey
as the key for later stealing.
Steal a previously stashed diagnostic with the given Span
and StashKey
as the key.
Emit all stashed diagnostics.
Construct a dummy builder with Level::Cancelled
.
Using this will neither report anything to the user (e.g. a warning), nor will compilation cancel as a result.
pub fn struct_span_warn(
&self,
span: impl Into<MultiSpan>,
msg: &str
) -> DiagnosticBuilder<'_>
pub fn struct_span_warn(
&self,
span: impl Into<MultiSpan>,
msg: &str
) -> DiagnosticBuilder<'_>
Construct a builder at the Warning
level at the given span
and with the msg
.
The builder will be canceled if warnings cannot be emitted.
pub fn struct_span_force_warn(
&self,
span: impl Into<MultiSpan>,
msg: &str
) -> DiagnosticBuilder<'_>
pub fn struct_span_force_warn(
&self,
span: impl Into<MultiSpan>,
msg: &str
) -> DiagnosticBuilder<'_>
Construct a builder at the Warning
level at the given span
and with the msg
.
This will “force” the warning meaning it will not be canceled even if warnings cannot be emitted.
pub fn struct_span_allow(
&self,
span: impl Into<MultiSpan>,
msg: &str
) -> DiagnosticBuilder<'_>
pub fn struct_span_allow(
&self,
span: impl Into<MultiSpan>,
msg: &str
) -> DiagnosticBuilder<'_>
Construct a builder at the Allow
level at the given span
and with the msg
.
pub fn struct_span_warn_with_code(
&self,
span: impl Into<MultiSpan>,
msg: &str,
code: DiagnosticId
) -> DiagnosticBuilder<'_>
pub fn struct_span_warn_with_code(
&self,
span: impl Into<MultiSpan>,
msg: &str,
code: DiagnosticId
) -> DiagnosticBuilder<'_>
Construct a builder at the Warning
level at the given span
and with the msg
.
Also include a code.
Construct a builder at the Warning
level with the msg
.
The builder will be canceled if warnings cannot be emitted.
Construct a builder at the Warning
level with the msg
.
This will “force” a warning meaning it will not be canceled even if warnings cannot be emitted.
Construct a builder at the Allow
level with the msg
.
Construct a builder at the Error
level at the given span
and with the msg
.
pub fn struct_span_err_with_code(
&self,
span: impl Into<MultiSpan>,
msg: &str,
code: DiagnosticId
) -> DiagnosticBuilder<'_>
pub fn struct_span_err_with_code(
&self,
span: impl Into<MultiSpan>,
msg: &str,
code: DiagnosticId
) -> DiagnosticBuilder<'_>
Construct a builder at the Error
level at the given span
, with the msg
, and code
.
Construct a builder at the Error
level with the msg
.
Construct a builder at the Error
level with the msg
and the code
.
pub fn struct_span_fatal(
&self,
span: impl Into<MultiSpan>,
msg: &str
) -> DiagnosticBuilder<'_>
pub fn struct_span_fatal(
&self,
span: impl Into<MultiSpan>,
msg: &str
) -> DiagnosticBuilder<'_>
Construct a builder at the Fatal
level at the given span
and with the msg
.
pub fn struct_span_fatal_with_code(
&self,
span: impl Into<MultiSpan>,
msg: &str,
code: DiagnosticId
) -> DiagnosticBuilder<'_>
pub fn struct_span_fatal_with_code(
&self,
span: impl Into<MultiSpan>,
msg: &str,
code: DiagnosticId
) -> DiagnosticBuilder<'_>
Construct a builder at the Fatal
level at the given span
, with the msg
, and code
.
Construct a builder at the Error
level with the msg
.
Construct a builder at the Help
level with the msg
.
Construct a builder at the Note
level with the msg
.
pub fn span_fatal_with_code(
&self,
span: impl Into<MultiSpan>,
msg: &str,
code: DiagnosticId
) -> !
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
.
Auto Trait Implementations
impl !RefUnwindSafe for Handler
impl !UnwindSafe for Handler
Blanket Implementations
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: 320 bytes