Skip to content

Commit 0a8139f

Browse files
P-E-PCohenArthur
authored andcommitted
Add doc attribute checking on traits
Doc attribute checking was not performed on traits. gcc/rust/ChangeLog: * util/rust-attributes.cc (check_doc_attribute): Change message. (AttributeChecker::visit): Add doc attribute checking on traits. gcc/testsuite/ChangeLog: * rust/compile/attr_malformed_doc.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
1 parent 6ec1929 commit 0a8139f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

gcc/rust/util/rust-attributes.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ check_doc_attribute (const AST::Attribute &attribute)
240240
{
241241
rust_error_at (
242242
attribute.get_locus (),
243-
// FIXME: Improve error message here. Rustc has a very good one
244-
"%<#[doc]%> cannot be an empty attribute");
243+
"valid forms for the attribute are "
244+
"%<#[doc(hidden|inline|...)]%> and %<#[doc = \" string \"]%>");
245245
return;
246246
}
247247

@@ -826,6 +826,7 @@ void
826826
AttributeChecker::visit (AST::Trait &trait)
827827
{
828828
check_proc_macro_non_function (trait.get_outer_attrs ());
829+
check_attributes (trait.get_outer_attrs ());
829830
}
830831

831832
void
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// { dg-error "valid forms for the attribute are ...doc.hidden.inline....... and ...doc = . string ..." "" { target *-*-* } .+1 }
2+
#[doc]
3+
trait MyTrait {}

0 commit comments

Comments
 (0)