Add SubdiagnosticMessageOp as a trait alias.

It avoids a lot of repetition.
This commit is contained in:
Nicholas Nethercote
2024-02-06 16:35:19 +11:00
parent 0d531351e8
commit 6b175a848d
19 changed files with 68 additions and 181 deletions

View File

@@ -77,11 +77,12 @@ where
/// Add a subdiagnostic to an existing diagnostic where `f` is invoked on every message used
/// (to optionally perform eager translation).
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, f: F)
where
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage;
fn add_to_diagnostic_with<F: SubdiagnosticMessageOp>(self, diag: &mut Diagnostic, f: F);
}
pub trait SubdiagnosticMessageOp =
Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage;
/// Trait implemented by lint types. This should not be implemented manually. Instead, use
/// `#[derive(LintDiagnostic)]` -- see [rustc_macros::LintDiagnostic].
#[rustc_diagnostic_item = "DecorateLint"]