about summary refs log tree commit diff
diff options
context:
space:
mode:
authorfinalchild <finalchild2@gmail.com>2022-08-18 17:46:01 +0900
committerfinalchild <finalchild2@gmail.com>2022-08-22 00:57:21 +0900
commitc6903c04b1c95061680aafa9da7e8dbccabb9069 (patch)
treed30f239606e04a5cbf2768216d11a553213a9248
parent269c85390c7eac7e9708a1d5529e54e10bd9631a (diff)
downloadrust-c6903c04b1c95061680aafa9da7e8dbccabb9069.tar.gz
rust-c6903c04b1c95061680aafa9da7e8dbccabb9069.zip
Migrate doc_comment_on_fn_param, forbidden_attr_on_fn_param
-rw-r--r--compiler/rustc_ast_passes/src/ast_validation.rs14
-rw-r--r--compiler/rustc_ast_passes/src/errors.rs15
-rw-r--r--compiler/rustc_error_messages/locales/en-US/ast_passes.ftl7
3 files changed, 24 insertions, 12 deletions
diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs
index 7735d95f71e..e42d716d5ae 100644
--- a/compiler/rustc_ast_passes/src/ast_validation.rs
+++ b/compiler/rustc_ast_passes/src/ast_validation.rs
@@ -372,19 +372,9 @@ impl<'a> AstValidator<'a> {
             })
             .for_each(|attr| {
                 if attr.is_doc_comment() {
-                    self.err_handler()
-                        .struct_span_err(
-                            attr.span,
-                            "documentation comments cannot be applied to function parameters",
-                        )
-                        .span_label(attr.span, "doc comments are not allowed here")
-                        .emit();
+                    self.session.emit_err(DocCommentOnFnParam { span: attr.span });
                 } else {
-                    self.err_handler().span_err(
-                        attr.span,
-                        "allow, cfg, cfg_attr, deny, expect, \
-                forbid, and warn are the only allowed built-in attributes in function parameters",
-                    );
+                    self.session.emit_err(ForbiddenAttrOnFnParam { span: attr.span });
                 }
             });
     }
diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs
index cc92f00714d..2b6d3d2a39a 100644
--- a/compiler/rustc_ast_passes/src/errors.rs
+++ b/compiler/rustc_ast_passes/src/errors.rs
@@ -126,3 +126,18 @@ pub struct CVarArgsNotLast {
     #[primary_span]
     pub span: Span,
 }
+
+#[derive(SessionDiagnostic)]
+#[error(ast_passes::doc_comment_on_fn_param)]
+pub struct DocCommentOnFnParam {
+    #[primary_span]
+    #[label]
+    pub span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(ast_passes::forbidden_attr_on_fn_param)]
+pub struct ForbiddenAttrOnFnParam {
+    #[primary_span]
+    pub span: Span,
+}
diff --git a/compiler/rustc_error_messages/locales/en-US/ast_passes.ftl b/compiler/rustc_error_messages/locales/en-US/ast_passes.ftl
index c0994063fc3..bca73baea00 100644
--- a/compiler/rustc_error_messages/locales/en-US/ast_passes.ftl
+++ b/compiler/rustc_error_messages/locales/en-US/ast_passes.ftl
@@ -46,3 +46,10 @@ ast_passes_c_var_args_without_named_arg =
 
 ast_passes_c_var_args_not_last =
     `...` must be the last argument of a C-variadic function
+
+ast_passes_doc_comment_on_fn_param =
+    documentation comments cannot be applied to function parameters
+    .label = doc comments are not allowed here
+
+ast_passes_forbidden_attr_on_fn_param =
+    allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters