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

@ -2,7 +2,7 @@ use crate::fluent_generated as fluent;
use rustc_errors::DiagnosticArgValue;
use rustc_errors::{
codes::*, AddToDiagnostic, Applicability, DiagCtxt, Diagnostic, DiagnosticBuilder,
IntoDiagnostic, Level, MultiSpan, SubdiagnosticMessage,
IntoDiagnostic, Level, MultiSpan, SubdiagnosticMessageOp,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{self, Ty};
@ -420,10 +420,7 @@ pub struct UnsafeNotInheritedLintNote {
}
impl AddToDiagnostic for UnsafeNotInheritedLintNote {
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) {
diag.span_note(self.signature_span, fluent::mir_build_unsafe_fn_safe_body);
let body_start = self.body_span.shrink_to_lo();
let body_end = self.body_span.shrink_to_hi();
@ -866,10 +863,7 @@ pub struct Variant {
}
impl<'tcx> AddToDiagnostic for AdtDefinedHere<'tcx> {
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) {
diag.arg("ty", self.ty);
let mut spans = MultiSpan::from(self.adt_def_span);