]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_lint_defs/src/lib.rs
Rollup merge of #106671 - tmiasko:opt-bool, r=wesleywiser
[rust.git] / compiler / rustc_lint_defs / src / lib.rs
index aa54b3d8ac2bc058cc91b773f86db57130000014..f4b4c5168bfd6c392b2c6c0b4cf3f53fcf2e9d09 100644 (file)
@@ -253,6 +253,19 @@ pub fn from_attr(attr: &Attribute) -> Option<Level> {
         }
     }
 
+    pub fn to_cmd_flag(self) -> &'static str {
+        match self {
+            Level::Warn => "-W",
+            Level::Deny => "-D",
+            Level::Forbid => "-F",
+            Level::Allow => "-A",
+            Level::ForceWarn(_) => "--force-warn",
+            Level::Expect(_) => {
+                unreachable!("the expect level does not have a commandline flag")
+            }
+        }
+    }
+
     pub fn is_error(self) -> bool {
         match self {
             Level::Allow | Level::Expect(_) | Level::Warn | Level::ForceWarn(_) => false,