about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorDayo <dayo05@daum.net>2023-07-17 15:00:13 +0900
committerDayo <dayo05@daum.net>2023-07-17 15:00:39 +0900
commit05c856a760ba058ccd45c899c9257f6f7d6f769f (patch)
tree86f55879664427a9f6467d6d9ba75d6c1a2a45a6 /compiler/rustc_errors/src
parentd6c93b33d0af1ede78b6097d04492ab36689dc1d (diff)
downloadrust-05c856a760ba058ccd45c899c9257f6f7d6f769f.tar.gz
rust-05c856a760ba058ccd45c899c9257f6f7d6f769f.zip
Simplify implement diagnostic of errors_indicate_anonymous_lifetime
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/diagnostic_impls.rs22
1 files changed, 5 insertions, 17 deletions
diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs
index 7eca1151a3c..2bc2efbf930 100644
--- a/compiler/rustc_errors/src/diagnostic_impls.rs
+++ b/compiler/rustc_errors/src/diagnostic_impls.rs
@@ -1,11 +1,10 @@
 use crate::diagnostic::DiagnosticLocation;
-use crate::{fluent_generated as fluent, AddToDiagnostic, Diagnostic};
+use crate::{fluent_generated as fluent, AddToDiagnostic};
 use crate::{DiagnosticArgValue, DiagnosticBuilder, Handler, IntoDiagnostic, IntoDiagnosticArg};
 use rustc_ast as ast;
 use rustc_ast_pretty::pprust;
-use rustc_error_messages::SubdiagnosticMessage;
 use rustc_hir as hir;
-use rustc_lint_defs::{Applicability, Level};
+use rustc_lint_defs::Level;
 use rustc_span::edition::Edition;
 use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol};
 use rustc_span::Span;
@@ -365,22 +364,11 @@ impl IntoDiagnosticArg for rustc_errors::Level {
     }
 }
 
+#[derive(Subdiagnostic)]
+#[suggestion(errors_indicate_anonymous_lifetime, code = "{suggestion}", style = "verbose")]
 pub struct IndicateAnonymousLifetime {
+    #[primary_span]
     pub span: Span,
     pub count: usize,
     pub suggestion: String,
 }
-
-impl AddToDiagnostic for IndicateAnonymousLifetime {
-    fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
-    where
-        F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
-    {
-        diag.span_suggestion_verbose(
-            self.span,
-            fluent::errors_indicate_anonymous_lifetime,
-            self.suggestion,
-            Applicability::MachineApplicable,
-        );
-    }
-}