Enum rustc_errors::Level
source · pub enum Level {
Show 14 variants
Bug,
Fatal,
Error,
DelayedBug,
GoodPathDelayedBug,
ForceWarning(Option<LintExpectationId>),
Warning,
Note,
OnceNote,
Help,
OnceHelp,
FailureNote,
Allow,
Expect(LintExpectationId),
}Expand description
Level is_error EmissionGuarantee Top-level Sub Used in lints?
Bug yes BugAbort yes - - Fatal yes FatalAbort/FatalError(*) yes - - Error yes ErrorGuaranteed yes - yes DelayedBug yes ErrorGuaranteed yes - - GoodPathDelayedBug - () yes - - ForceWarning - () yes - lint-only Warning - () yes yes yes Note - () rare yes - OnceNote - () - yes lint-only Help - () rare yes - OnceHelp - () - yes lint-only FailureNote - () rare - - Allow - () yes - lint-only Expect - () yes - lint-only
(*) FatalAbort normally, FatalError in the non-aborting “almost fatal” case that is
occasionally used.
Variants§
Bug
For bugs in the compiler. Manifests as an ICE (internal compiler error) panic.
Fatal
An error that causes an immediate abort. Used for things like configuration errors, internal overflows, some file operation errors.
Error
An error in the code being compiled, which prevents compilation from finishing. This is the most common case.
DelayedBug
This is a strange one: lets you register an error without emitting it. If compilation ends without any other errors occurring, this will be emitted as a bug. Otherwise, it will be silently dropped. I.e. “expect other errors are emitted” semantics. Useful on code paths that should only be reached when compiling erroneous code.
GoodPathDelayedBug
Like DelayedBug, but weaker: lets you register an error without emitting it. If
compilation ends without any other diagnostics being emitted (and without an expected lint
being suppressed), this will be emitted as a bug. Otherwise, it will be silently dropped.
I.e. “expect other diagnostics are emitted (or suppressed)” semantics. Useful on code paths
that should only be reached when emitting diagnostics, e.g. for expensive one-time
diagnostic formatting operations.
FIXME(nnethercote) good path delayed bugs are semantically strange: if printed they produce
an ICE, but they don’t satisfy is_error and they don’t guarantee an error is emitted.
Plus there’s the extra complication with expected (suppressed) lints. They have limited
use, and are used in very few places, and “good path” isn’t a good name. It would be good
to remove them.
ForceWarning(Option<LintExpectationId>)
A force-warn lint warning about the code being compiled. Does not prevent compilation
from finishing.
The LintExpectationId is used for expected lint diagnostics. In all other cases this
should be None.
Warning
A warning about the code being compiled. Does not prevent compilation from finishing.
Will be skipped if can_emit_warnings is false.
Note
A message giving additional context.
OnceNote
A note that is only emitted once.
Help
A message suggesting how to fix something.
OnceHelp
A help that is only emitted once.
FailureNote
Similar to Note, but used in cases where compilation has failed. When printed for human
consumption, it doesn’t have any kind of note: label.
Allow
Only used for lints.
Expect(LintExpectationId)
Only used for lints.
Implementations§
source§impl Level
impl Level
pub(crate) fn color(self) -> ColorSpec
pub fn to_str(self) -> &'static str
pub fn is_failure_note(&self) -> bool
pub fn get_expectation_id(&self) -> Option<LintExpectationId>
pub(crate) fn can_be_top_or_sub(&self) -> (bool, bool)
Trait Implementations§
source§impl IntoDiagnosticArg for Level
impl IntoDiagnosticArg for Level
fn into_diagnostic_arg(self) -> DiagnosticArgValue
source§impl PartialEq for Level
impl PartialEq for Level
impl Copy for Level
impl Eq for Level
impl StructuralPartialEq for Level
Auto Trait Implementations§
impl RefUnwindSafe for Level
impl Send for Level
impl Sync for Level
impl Unpin for Level
impl UnwindSafe for Level
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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: 24 bytes
Size for each variant:
Bug: 0 bytesFatal: 0 bytesError: 0 bytesDelayedBug: 0 bytesGoodPathDelayedBug: 0 bytesForceWarning: 20 bytesWarning: 0 bytesNote: 0 bytesOnceNote: 0 bytesHelp: 0 bytesOnceHelp: 0 bytesFailureNote: 0 bytesAllow: 0 bytesExpect: 20 bytes