@@ -1731,25 +1731,80 @@ impl DelayedDiagnostic {
1731
1731
1732
1732
#[ derive( Copy , PartialEq , Eq , Clone , Hash , Debug , Encodable , Decodable ) ]
1733
1733
pub enum Level {
1734
+ /// For bugs in the compiler. Manifests as an ICE (internal compiler error) panic.
1735
+ ///
1736
+ /// Its `EmissionGuarantee` is `BugAbort`.
1734
1737
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`.
1735
1745
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`.
1736
1752
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`.
1737
1758
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.
1739
1761
lint : bool ,
1740
1762
} ,
1763
+
1764
+ /// A warning about the code being compiled. Does not prevent compilation from finishing.
1765
+ ///
1741
1766
/// This [`LintExpectationId`] is used for expected lint diagnostics, which should
1742
1767
/// also emit a warning due to the `force-warn` flag. In all other cases this should
1743
1768
/// be `None`.
1769
+ ///
1770
+ /// Its `EmissionGuarantee` is `()`.
1744
1771
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 `()`.
1745
1777
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 `()`.
1747
1782
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 `()`.
1748
1788
Help ,
1749
- /// A help that is only emitted once.
1789
+
1790
+ /// A help that is only emitted once. Rare.
1791
+ ///
1792
+ /// Its `EmissionGuarantee` is `()`.
1750
1793
OnceHelp ,
1794
+
1795
+ /// Similar to `Note`, but used in cases where compilation has failed. Rare.
1796
+ ///
1797
+ /// Its `EmissionGuarantee` is `()`.
1751
1798
FailureNote ,
1799
+
1800
+ /// Only used for lints.
1801
+ ///
1802
+ /// Its `EmissionGuarantee` is `()`.
1752
1803
Allow ,
1804
+
1805
+ /// Only used for lints.
1806
+ ///
1807
+ /// Its `EmissionGuarantee` is `()`.
1753
1808
Expect ( LintExpectationId ) ,
1754
1809
}
1755
1810
@@ -1789,8 +1844,7 @@ impl Level {
1789
1844
Note | OnceNote => "note" ,
1790
1845
Help | OnceHelp => "help" ,
1791
1846
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 ! ( ) ,
1794
1848
}
1795
1849
}
1796
1850
0 commit comments