about summary refs log tree commit diff
path: root/compiler/rustc_errors
diff options
context:
space:
mode:
authorozkanonur <work@onurozkan.dev>2023-01-10 10:56:17 +0300
committerozkanonur <work@onurozkan.dev>2023-01-10 10:56:17 +0300
commit5fb9ca3c5e34a0ad4e4770ea475d75b26e201b61 (patch)
tree0b726c319c6f66b7f30ef91c092c71b72727ba59 /compiler/rustc_errors
parent89e0576bd3aec2f1acf935b353900bd75742860b (diff)
downloadrust-5fb9ca3c5e34a0ad4e4770ea475d75b26e201b61.tar.gz
rust-5fb9ca3c5e34a0ad4e4770ea475d75b26e201b61.zip
create helper function for `rustc_lint_defs::Level` and remove it's duplicated code r=ozkanonur
Signed-off-by: ozkanonur <work@onurozkan.dev>
Diffstat (limited to 'compiler/rustc_errors')
-rw-r--r--compiler/rustc_errors/src/diagnostic_impls.rs11
1 files changed, 1 insertions, 10 deletions
diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs
index 794b6efcc2b..dad5e98aac0 100644
--- a/compiler/rustc_errors/src/diagnostic_impls.rs
+++ b/compiler/rustc_errors/src/diagnostic_impls.rs
@@ -179,16 +179,7 @@ impl IntoDiagnosticArg for type_ir::FloatTy {
 
 impl IntoDiagnosticArg for Level {
     fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
-        DiagnosticArgValue::Str(Cow::Borrowed(match self {
-            Level::Allow => "-A",
-            Level::Warn => "-W",
-            Level::ForceWarn(_) => "--force-warn",
-            Level::Deny => "-D",
-            Level::Forbid => "-F",
-            Level::Expect(_) => {
-                unreachable!("lints with the level of `expect` should not run this code");
-            }
-        }))
+        DiagnosticArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
     }
 }