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_lint/src/errors.rs | |
| 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_lint/src/errors.rs')
| -rw-r--r-- | compiler/rustc_lint/src/errors.rs | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/compiler/rustc_lint/src/errors.rs b/compiler/rustc_lint/src/errors.rs index 97d012fb611..34b70030a58 100644 --- a/compiler/rustc_lint/src/errors.rs +++ b/compiler/rustc_lint/src/errors.rs @@ -88,34 +88,13 @@ pub struct BuiltinEllpisisInclusiveRangePatterns { pub replace: String, } +#[derive(Subdiagnostic)] +#[note(lint::requested_level)] pub struct RequestedLevel { pub level: Level, pub lint_name: String, } -impl AddToDiagnostic for RequestedLevel { - fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F) - where - F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, - { - diag.note(fluent::lint::requested_level); - diag.set_arg( - "level", - match self.level { - 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"); - } - }, - ); - diag.set_arg("lint_name", self.lint_name); - } -} - #[derive(Diagnostic)] #[diag(lint::unsupported_group, code = "E0602")] pub struct UnsupportedGroup { |
