Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c8c1615

Browse files
committed
Add comments to Level.
There is room for improvement on some of these, but something is better than nothing.
1 parent 467d1d9 commit c8c1615

File tree

1 file changed

+59
-5
lines changed
  • compiler/rustc_errors/src

1 file changed

+59
-5
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,25 +1731,80 @@ impl DelayedDiagnostic {
17311731

17321732
#[derive(Copy, PartialEq, Eq, Clone, Hash, Debug, Encodable, Decodable)]
17331733
pub enum Level {
1734+
/// For bugs in the compiler. Manifests as an ICE (internal compiler error) panic.
1735+
///
1736+
/// Its `EmissionGuarantee` is `BugAbort`.
17341737
Bug,
1738+
1739+
/// This is a strange one: lets you register an error without emitting it. If compilation ends
1740+
/// without any other errors occurring, this will be emitted as a bug. Otherwise, it will be
1741+
/// silently dropped. I.e. "expect other errors are emitted" semantics. Useful on code paths
1742+
/// that should only be reached when compiling erroneous code.
1743+
///
1744+
/// Its `EmissionGuarantee` is `ErrorGuaranteed`.
17351745
DelayedBug,
1746+
1747+
/// An error that causes an immediate abort. Used for things like configuration errors,
1748+
/// internal overflows, some file operation errors.
1749+
///
1750+
/// Its `EmissionGuarantee` is `FatalAbort`, except in the non-aborting "almost fatal" case
1751+
/// that is occasionaly used, where it is `FatalError`.
17361752
Fatal,
1753+
1754+
/// An error in the code being compiled, which prevents compilation from finishing. This is the
1755+
/// most common case.
1756+
///
1757+
/// Its `EmissionGuarantee` is `ErrorGuaranteed`.
17371758
Error {
1738-
/// If this error comes from a lint, don't abort compilation even when abort_if_errors() is called.
1759+
/// If this error comes from a lint, don't abort compilation even when abort_if_errors() is
1760+
/// called.
17391761
lint: bool,
17401762
},
1763+
1764+
/// A warning about the code being compiled. Does not prevent compilation from finishing.
1765+
///
17411766
/// This [`LintExpectationId`] is used for expected lint diagnostics, which should
17421767
/// also emit a warning due to the `force-warn` flag. In all other cases this should
17431768
/// be `None`.
1769+
///
1770+
/// Its `EmissionGuarantee` is `()`.
17441771
Warning(Option<LintExpectationId>),
1772+
1773+
/// A message giving additional context. Rare, because notes are more commonly attached to other
1774+
/// diagnostics such as errors.
1775+
///
1776+
/// Its `EmissionGuarantee` is `()`.
17451777
Note,
1746-
/// A note that is only emitted once.
1778+
1779+
/// A note that is only emitted once. Rare, mostly used in circumstances relating to lints.
1780+
///
1781+
/// Its `EmissionGuarantee` is `()`.
17471782
OnceNote,
1783+
1784+
/// A message suggesting how to fix something. Rare, because help messages are more commonly
1785+
/// attached to other diagnostics such as errors.
1786+
///
1787+
/// Its `EmissionGuarantee` is `()`.
17481788
Help,
1749-
/// A help that is only emitted once.
1789+
1790+
/// A help that is only emitted once. Rare.
1791+
///
1792+
/// Its `EmissionGuarantee` is `()`.
17501793
OnceHelp,
1794+
1795+
/// Similar to `Note`, but used in cases where compilation has failed. Rare.
1796+
///
1797+
/// Its `EmissionGuarantee` is `()`.
17511798
FailureNote,
1799+
1800+
/// Only used for lints.
1801+
///
1802+
/// Its `EmissionGuarantee` is `()`.
17521803
Allow,
1804+
1805+
/// Only used for lints.
1806+
///
1807+
/// Its `EmissionGuarantee` is `()`.
17531808
Expect(LintExpectationId),
17541809
}
17551810

@@ -1789,8 +1844,7 @@ impl Level {
17891844
Note | OnceNote => "note",
17901845
Help | OnceHelp => "help",
17911846
FailureNote => "failure-note",
1792-
Allow => panic!("Shouldn't call on allowed error"),
1793-
Expect(_) => panic!("Shouldn't call on expected error"),
1847+
Allow | Expect(_) => unreachable!(),
17941848
}
17951849
}
17961850

0 commit comments

Comments
 (0)