Skip to content

Commit 02423a5

Browse files
committed
Make some IntoDiagnostic impls generic.
PR #119097 made the decision to make all `IntoDiagnostic` impls generic, because this allowed a bunch of nice cleanups. But four hand-written impls were unintentionally overlooked. This commit makes them generic.
1 parent 326b44e commit 02423a5

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

compiler/rustc_mir_build/src/errors.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,10 @@ pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
461461
pub ty: Ty<'tcx>,
462462
}
463463

464-
impl<'a> IntoDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
465-
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'_> {
464+
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G>
465+
for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_>
466+
{
467+
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> {
466468
let mut diag = DiagnosticBuilder::new(
467469
dcx,
468470
level,

compiler/rustc_parse/src/errors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1073,9 +1073,9 @@ pub(crate) struct ExpectedIdentifier {
10731073
pub help_cannot_start_number: Option<HelpIdentifierStartsWithNumber>,
10741074
}
10751075

1076-
impl<'a> IntoDiagnostic<'a> for ExpectedIdentifier {
1076+
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedIdentifier {
10771077
#[track_caller]
1078-
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a> {
1078+
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
10791079
let token_descr = TokenDescription::from_token(&self.token);
10801080

10811081
let mut diag = DiagnosticBuilder::new(
@@ -1133,9 +1133,9 @@ pub(crate) struct ExpectedSemi {
11331133
pub sugg: ExpectedSemiSugg,
11341134
}
11351135

1136-
impl<'a> IntoDiagnostic<'a> for ExpectedSemi {
1136+
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedSemi {
11371137
#[track_caller]
1138-
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a> {
1138+
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
11391139
let token_descr = TokenDescription::from_token(&self.token);
11401140

11411141
let mut diag = DiagnosticBuilder::new(

compiler/rustc_session/src/errors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::num::NonZero;
33
use rustc_ast::token;
44
use rustc_ast::util::literal::LitError;
55
use rustc_errors::{
6-
codes::*, DiagCtxt, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, IntoDiagnostic,
7-
Level, MultiSpan,
6+
codes::*, DiagCtxt, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed,
7+
IntoDiagnostic, Level, MultiSpan,
88
};
99
use rustc_macros::Diagnostic;
1010
use rustc_span::{Span, Symbol};
@@ -17,9 +17,9 @@ pub struct FeatureGateError {
1717
pub explain: DiagnosticMessage,
1818
}
1919

20-
impl<'a> IntoDiagnostic<'a> for FeatureGateError {
20+
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for FeatureGateError {
2121
#[track_caller]
22-
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a> {
22+
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
2323
DiagnosticBuilder::new(dcx, level, self.explain).with_span(self.span).with_code(E0658)
2424
}
2525
}

0 commit comments

Comments
 (0)