@@ -47,12 +47,31 @@ pub enum Applicability {
4747}
4848
4949/// Setting for how to handle a lint.
50+ ///
51+ /// See: https://doc.rust-lang.org/rustc/lints/levels.html
5052#[ derive( Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash ) ]
5153pub enum Level {
54+ /// The `allow` level will not issue any message.
5255 Allow ,
56+ /// The `expect` level will suppress the lint message but intern produce a message
57+ /// if the lint wasn't issued in the expected scope. Expect should not be used as
58+ /// an initial level for a lint.
59+ ///
60+ /// Note that this still means that the lint is enabled in this position and should
61+ /// be passed onwards to the `LintContext` which will fulfill the expectation and
62+ /// suppress the lint.
63+ ///
64+ /// See RFC 2383.
65+ Expect ,
66+ /// The `warn` level will produce a warning if the lint was violated, however the
67+ /// compiler will continue with its execution.
5368 Warn ,
5469 ForceWarn ,
70+ /// The `deny` level will produce an error and stop further execution after the lint
71+ /// pass is complete.
5572 Deny ,
73+ /// `Forbid` is equivalent to the `deny` level but can't be overwritten like the previous
74+ /// levels.
5675 Forbid ,
5776}
5877
@@ -63,6 +82,7 @@ impl Level {
6382 pub fn as_str ( self ) -> & ' static str {
6483 match self {
6584 Level :: Allow => "allow" ,
85+ Level :: Expect => "expect" ,
6686 Level :: Warn => "warn" ,
6787 Level :: ForceWarn => "force-warn" ,
6888 Level :: Deny => "deny" ,
@@ -74,6 +94,7 @@ impl Level {
7494 pub fn from_str ( x : & str ) -> Option < Level > {
7595 match x {
7696 "allow" => Some ( Level :: Allow ) ,
97+ "expect" => Some ( Level :: Expect ) ,
7798 "warn" => Some ( Level :: Warn ) ,
7899 "deny" => Some ( Level :: Deny ) ,
79100 "forbid" => Some ( Level :: Forbid ) ,
@@ -85,6 +106,7 @@ impl Level {
85106 pub fn from_symbol ( x : Symbol ) -> Option < Level > {
86107 match x {
87108 sym:: allow => Some ( Level :: Allow ) ,
109+ sym:: expect => Some ( Level :: Expect ) ,
88110 sym:: warn => Some ( Level :: Warn ) ,
89111 sym:: deny => Some ( Level :: Deny ) ,
90112 sym:: forbid => Some ( Level :: Forbid ) ,
0 commit comments