]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_ast_passes/src/errors.rs
Rollup merge of #103543 - ehuss:update-books, r=ehuss
[rust.git] / compiler / rustc_ast_passes / src / errors.rs
index ba2ed24fc08fc08095d240d45d6c90f334c6371c..59f582f10d989be097f5f44eb6ad86827dfd8100 100644 (file)
@@ -7,7 +7,7 @@
 use crate::ast_validation::ForbiddenLetReason;
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::forbidden_let)]
+#[diag(ast_passes_forbidden_let)]
 #[note]
 pub struct ForbiddenLet {
     #[primary_span]
@@ -16,25 +16,8 @@ pub struct ForbiddenLet {
     pub(crate) reason: ForbiddenLetReason,
 }
 
-impl AddToDiagnostic for ForbiddenLetReason {
-    fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
-    where
-        F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
-    {
-        match self {
-            Self::GenericForbidden => {}
-            Self::NotSupportedOr(span) => {
-                diag.span_note(span, fluent::ast_passes::not_supported_or);
-            }
-            Self::NotSupportedParentheses(span) => {
-                diag.span_note(span, fluent::ast_passes::not_supported_parentheses);
-            }
-        }
-    }
-}
-
 #[derive(Diagnostic)]
-#[diag(ast_passes::forbidden_let_stable)]
+#[diag(ast_passes_forbidden_let_stable)]
 #[note]
 pub struct ForbiddenLetStable {
     #[primary_span]
@@ -42,21 +25,21 @@ pub struct ForbiddenLetStable {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::forbidden_assoc_constraint)]
+#[diag(ast_passes_forbidden_assoc_constraint)]
 pub struct ForbiddenAssocConstraint {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::keyword_lifetime)]
+#[diag(ast_passes_keyword_lifetime)]
 pub struct KeywordLifetime {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::invalid_label)]
+#[diag(ast_passes_invalid_label)]
 pub struct InvalidLabel {
     #[primary_span]
     pub span: Span,
@@ -64,11 +47,11 @@ pub struct InvalidLabel {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::invalid_visibility, code = "E0449")]
+#[diag(ast_passes_invalid_visibility, code = "E0449")]
 pub struct InvalidVisibility {
     #[primary_span]
     pub span: Span,
-    #[label(ast_passes::implied)]
+    #[label(implied)]
     pub implied: Option<Span>,
     #[subdiagnostic]
     pub note: Option<InvalidVisibilityNote>,
@@ -76,14 +59,14 @@ pub struct InvalidVisibility {
 
 #[derive(Subdiagnostic)]
 pub enum InvalidVisibilityNote {
-    #[note(ast_passes::individual_impl_items)]
+    #[note(individual_impl_items)]
     IndividualImplItems,
-    #[note(ast_passes::individual_foreign_items)]
+    #[note(individual_foreign_items)]
     IndividualForeignItems,
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::trait_fn_const, code = "E0379")]
+#[diag(ast_passes_trait_fn_const, code = "E0379")]
 pub struct TraitFnConst {
     #[primary_span]
     #[label]
@@ -91,21 +74,21 @@ pub struct TraitFnConst {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::forbidden_lifetime_bound)]
+#[diag(ast_passes_forbidden_lifetime_bound)]
 pub struct ForbiddenLifetimeBound {
     #[primary_span]
     pub spans: Vec<Span>,
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::forbidden_non_lifetime_param)]
+#[diag(ast_passes_forbidden_non_lifetime_param)]
 pub struct ForbiddenNonLifetimeParam {
     #[primary_span]
     pub spans: Vec<Span>,
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::fn_param_too_many)]
+#[diag(ast_passes_fn_param_too_many)]
 pub struct FnParamTooMany {
     #[primary_span]
     pub span: Span,
@@ -113,21 +96,21 @@ pub struct FnParamTooMany {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::fn_param_c_var_args_only)]
+#[diag(ast_passes_fn_param_c_var_args_only)]
 pub struct FnParamCVarArgsOnly {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::fn_param_c_var_args_not_last)]
+#[diag(ast_passes_fn_param_c_var_args_not_last)]
 pub struct FnParamCVarArgsNotLast {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::fn_param_doc_comment)]
+#[diag(ast_passes_fn_param_doc_comment)]
 pub struct FnParamDocComment {
     #[primary_span]
     #[label]
@@ -135,14 +118,14 @@ pub struct FnParamDocComment {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::fn_param_forbidden_attr)]
+#[diag(ast_passes_fn_param_forbidden_attr)]
 pub struct FnParamForbiddenAttr {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::fn_param_forbidden_self)]
+#[diag(ast_passes_fn_param_forbidden_self)]
 #[note]
 pub struct FnParamForbiddenSelf {
     #[primary_span]
@@ -151,7 +134,7 @@ pub struct FnParamForbiddenSelf {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::forbidden_default)]
+#[diag(ast_passes_forbidden_default)]
 pub struct ForbiddenDefault {
     #[primary_span]
     pub span: Span,
@@ -160,7 +143,7 @@ pub struct ForbiddenDefault {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::assoc_const_without_body)]
+#[diag(ast_passes_assoc_const_without_body)]
 pub struct AssocConstWithoutBody {
     #[primary_span]
     pub span: Span,
@@ -169,7 +152,7 @@ pub struct AssocConstWithoutBody {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::assoc_fn_without_body)]
+#[diag(ast_passes_assoc_fn_without_body)]
 pub struct AssocFnWithoutBody {
     #[primary_span]
     pub span: Span,
@@ -178,7 +161,7 @@ pub struct AssocFnWithoutBody {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::assoc_type_without_body)]
+#[diag(ast_passes_assoc_type_without_body)]
 pub struct AssocTypeWithoutBody {
     #[primary_span]
     pub span: Span,
@@ -187,7 +170,7 @@ pub struct AssocTypeWithoutBody {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::const_without_body)]
+#[diag(ast_passes_const_without_body)]
 pub struct ConstWithoutBody {
     #[primary_span]
     pub span: Span,
@@ -196,7 +179,7 @@ pub struct ConstWithoutBody {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::static_without_body)]
+#[diag(ast_passes_static_without_body)]
 pub struct StaticWithoutBody {
     #[primary_span]
     pub span: Span,
@@ -205,7 +188,7 @@ pub struct StaticWithoutBody {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::ty_alias_without_body)]
+#[diag(ast_passes_ty_alias_without_body)]
 pub struct TyAliasWithoutBody {
     #[primary_span]
     pub span: Span,
@@ -214,7 +197,7 @@ pub struct TyAliasWithoutBody {
 }
 
 #[derive(Diagnostic)]
-#[diag(ast_passes::fn_without_body)]
+#[diag(ast_passes_fn_without_body)]
 pub struct FnWithoutBody {
     #[primary_span]
     pub span: Span,
@@ -243,7 +226,7 @@ fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
         let end_suggestion = " }".to_owned();
 
         diag.multipart_suggestion(
-            fluent::ast_passes::extern_block_suggestion,
+            fluent::extern_block_suggestion,
             vec![(self.start_span, start_suggestion), (self.end_span, end_suggestion)],
             Applicability::MaybeIncorrect,
         );