Skip to content

Commit 05c856a

Browse files
committed
Simplify implement diagnostic of errors_indicate_anonymous_lifetime
1 parent d6c93b3 commit 05c856a

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

Diff for: compiler/rustc_errors/src/diagnostic_impls.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use crate::diagnostic::DiagnosticLocation;
2-
use crate::{fluent_generated as fluent, AddToDiagnostic, Diagnostic};
2+
use crate::{fluent_generated as fluent, AddToDiagnostic};
33
use crate::{DiagnosticArgValue, DiagnosticBuilder, Handler, IntoDiagnostic, IntoDiagnosticArg};
44
use rustc_ast as ast;
55
use rustc_ast_pretty::pprust;
6-
use rustc_error_messages::SubdiagnosticMessage;
76
use rustc_hir as hir;
8-
use rustc_lint_defs::{Applicability, Level};
7+
use rustc_lint_defs::Level;
98
use rustc_span::edition::Edition;
109
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol};
1110
use rustc_span::Span;
@@ -365,22 +364,11 @@ impl IntoDiagnosticArg for rustc_errors::Level {
365364
}
366365
}
367366

367+
#[derive(Subdiagnostic)]
368+
#[suggestion(errors_indicate_anonymous_lifetime, code = "{suggestion}", style = "verbose")]
368369
pub struct IndicateAnonymousLifetime {
370+
#[primary_span]
369371
pub span: Span,
370372
pub count: usize,
371373
pub suggestion: String,
372374
}
373-
374-
impl AddToDiagnostic for IndicateAnonymousLifetime {
375-
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
376-
where
377-
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
378-
{
379-
diag.span_suggestion_verbose(
380-
self.span,
381-
fluent::errors_indicate_anonymous_lifetime,
382-
self.suggestion,
383-
Applicability::MachineApplicable,
384-
);
385-
}
386-
}

0 commit comments

Comments
 (0)