diff options
| author | David Wood <david.wood@huawei.com> | 2022-10-14 13:25:12 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-10-17 09:54:24 +0100 |
| commit | 21d3bbd8b611725456e5ebefb6704b263bee819e (patch) | |
| tree | 323e935179ec773afa1c99e3b7bc4a840307482b /compiler/rustc_errors/src | |
| parent | ea5d258a7560c0cb5b6080258ccae4a7e4d6277e (diff) | |
| download | rust-21d3bbd8b611725456e5ebefb6704b263bee819e.tar.gz rust-21d3bbd8b611725456e5ebefb6704b263bee819e.zip | |
lint: use derive more
Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic_impls.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index 860f24871bc..571b7dbfd1b 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -1,14 +1,14 @@ use crate::{ fluent, DiagnosticArgValue, DiagnosticBuilder, Handler, IntoDiagnostic, IntoDiagnosticArg, }; -use rustc_target::abi::TargetDataLayoutErrors; -use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple}; - use rustc_ast as ast; use rustc_ast_pretty::pprust; use rustc_hir as hir; +use rustc_lint_defs::Level; use rustc_span::edition::Edition; use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol}; +use rustc_target::abi::TargetDataLayoutErrors; +use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple}; use std::borrow::Cow; use std::fmt; use std::num::ParseIntError; @@ -155,6 +155,21 @@ impl IntoDiagnosticArg for ast::token::TokenKind { } } +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"); + } + })) + } +} + impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> { fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> { let mut diag; |
