1
Fork 0

Rollup merge of #120734 - nnethercote:SubdiagnosticMessageOp, r=compiler-errors

Add `SubdiagnosticMessageOp` as a trait alias.

It avoids a lot of repetition.

r? matthewjasper
This commit is contained in:
Matthias Krüger 2024-02-08 09:06:36 +01:00 committed by GitHub
commit 87e1e05aa1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 68 additions and 181 deletions

View file

@ -1,7 +1,7 @@
use crate::fluent_generated as fluent;
use rustc_errors::{
codes::*, AddToDiagnostic, Applicability, DiagCtxt, Diagnostic, DiagnosticBuilder,
EmissionGuarantee, IntoDiagnostic, Level, SubdiagnosticMessage,
EmissionGuarantee, IntoDiagnostic, Level, SubdiagnosticMessageOp,
};
use rustc_macros::Diagnostic;
use rustc_middle::ty::{self, ClosureKind, PolyTraitRef, Ty};
@ -102,10 +102,7 @@ pub enum AdjustSignatureBorrow {
}
impl AddToDiagnostic for AdjustSignatureBorrow {
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
where
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
{
fn add_to_diagnostic_with<F: SubdiagnosticMessageOp>(self, diag: &mut Diagnostic, _: F) {
match self {
AdjustSignatureBorrow::Borrow { to_borrow } => {
diag.arg("len", to_borrow.len());