Skip to content

Commit 5a7b8d8

Browse files
ifreundSpexGuy
authored andcommitted
Container doc comments only valid at start of containers
This behavior was changed in ziglang/zig#7920
1 parent 03f03a5 commit 5a7b8d8

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

grammar/grammar.y

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Root <- skip ContainerMembers eof
1+
Root <- skip container_doc_comment? ContainerMembers eof
22

33
# *** Top level ***
44
ContainerMembers
5-
<- container_doc_comment? (
5+
<- (
66
TestDecl ContainerMembers
77
/ TopLevelComptime ContainerMembers
88
/ doc_comment? KEYWORD_pub? TopLevelDecl ContainerMembers
@@ -306,7 +306,7 @@ PtrTypeStart
306306
/ LBRACKET ASTERISK (LETTERC / COLON Expr)? RBRACKET
307307

308308
# ContainerDecl specific
309-
ContainerDeclAuto <- ContainerDeclType LBRACE ContainerMembers RBRACE
309+
ContainerDeclAuto <- ContainerDeclType LBRACE container_doc_comment? ContainerMembers RBRACE
310310

311311
ContainerDeclType
312312
<- KEYWORD_struct

grammar/tests/doc_comments.zig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ const MyStruct = struct {
1010
/// This is another doc comment
1111
b: i32,
1212

13-
//! Resuming container doc comment
14-
1513
/// And one more field
1614
c: f32,
1715
};
@@ -22,12 +20,10 @@ const MyEnum = enum {
2220

2321
/// This is Foo
2422
Foo,
25-
//! It has some other fields
2623
/// This is Bar
2724
Bar,
2825
};
2926

30-
//! This is a container doc comment outside an error block
3127
/// This is a doc comment for the error block
3228
const Errors = error {
3329
/// This documents MyError1
@@ -55,7 +51,6 @@ comptime {
5551
const foo = add(40, 2);
5652
}
5753

58-
//! This is container doc comment
5954
/// This is a doc comment for a test
6055
test "This is my test" {
6156
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! This is a valid container doc comment
2+
3+
const Foo = struct {
4+
//! This is a valid container doc comment
5+
};
6+
7+
//! This is an invalid container doc comment

0 commit comments

Comments
 (0)