1
Fork 0

Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors

Fix `EmissionGuarantee`

There are some problems with the `DiagCtxt` API related to `EmissionGuarantee`. This PR fixes them.

r? `@compiler-errors`
This commit is contained in:
bors 2023-12-22 00:03:57 +00:00
commit cee794ee98
45 changed files with 605 additions and 701 deletions

View file

@ -2,7 +2,7 @@ use crate::fluent_generated as fluent;
use rustc_errors::DiagnosticArgValue;
use rustc_errors::{
error_code, AddToDiagnostic, Applicability, DiagCtxt, Diagnostic, DiagnosticBuilder,
ErrorGuaranteed, IntoDiagnostic, MultiSpan, SubdiagnosticMessage,
ErrorGuaranteed, IntoDiagnostic, Level, MultiSpan, SubdiagnosticMessage,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{self, Ty};
@ -461,13 +461,18 @@ pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
}
impl<'a> IntoDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
fn into_diagnostic(self, dcx: &'a DiagCtxt) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = dcx.struct_span_err_with_code(
self.span,
fn into_diagnostic(
self,
dcx: &'a DiagCtxt,
level: Level,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = DiagnosticBuilder::new(
dcx,
level,
fluent::mir_build_non_exhaustive_patterns_type_not_empty,
error_code!(E0004),
);
diag.set_span(self.span);
diag.code(error_code!(E0004));
let peeled_ty = self.ty.peel_refs();
diag.set_arg("ty", self.ty);
diag.set_arg("peeled_ty", peeled_ty);