Skip to content

Commit 67f548d

Browse files
author
Jonas Schievink
committed
Allow doc comments on all Items
1 parent ca8bd3e commit 67f548d

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

crates/syntax/src/ast/generated/nodes.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub struct MacroCall {
162162
pub(crate) syntax: SyntaxNode,
163163
}
164164
impl ast::HasAttrs for MacroCall {}
165+
impl ast::HasDocComments for MacroCall {}
165166
impl MacroCall {
166167
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
167168
pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
@@ -259,6 +260,7 @@ pub struct ExternBlock {
259260
pub(crate) syntax: SyntaxNode,
260261
}
261262
impl ast::HasAttrs for ExternBlock {}
263+
impl ast::HasDocComments for ExternBlock {}
262264
impl ExternBlock {
263265
pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
264266
pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
@@ -270,6 +272,7 @@ pub struct ExternCrate {
270272
}
271273
impl ast::HasAttrs for ExternCrate {}
272274
impl ast::HasVisibility for ExternCrate {}
275+
impl ast::HasDocComments for ExternCrate {}
273276
impl ExternCrate {
274277
pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
275278
pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
@@ -1543,6 +1546,7 @@ pub enum Item {
15431546
Use(Use),
15441547
}
15451548
impl ast::HasAttrs for Item {}
1549+
impl ast::HasDocComments for Item {}
15461550

15471551
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
15481552
pub enum Stmt {
@@ -1597,6 +1601,7 @@ pub enum AssocItem {
15971601
TypeAlias(TypeAlias),
15981602
}
15991603
impl ast::HasAttrs for AssocItem {}
1604+
impl ast::HasDocComments for AssocItem {}
16001605

16011606
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
16021607
pub enum ExternItem {
@@ -1606,6 +1611,7 @@ pub enum ExternItem {
16061611
TypeAlias(TypeAlias),
16071612
}
16081613
impl ast::HasAttrs for ExternItem {}
1614+
impl ast::HasDocComments for ExternItem {}
16091615

16101616
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
16111617
pub enum GenericParam {
@@ -3902,10 +3908,9 @@ impl AnyHasDocComments {
39023908
impl AstNode for AnyHasDocComments {
39033909
fn can_cast(kind: SyntaxKind) -> bool {
39043910
match kind {
3905-
SOURCE_FILE | CONST | ENUM | FN | IMPL | MACRO_RULES | MACRO_DEF | MODULE | STATIC
3906-
| STRUCT | TRAIT | TYPE_ALIAS | UNION | USE | RECORD_FIELD | TUPLE_FIELD | VARIANT => {
3907-
true
3908-
}
3911+
MACRO_CALL | SOURCE_FILE | CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL
3912+
| MACRO_RULES | MACRO_DEF | MODULE | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION
3913+
| USE | RECORD_FIELD | TUPLE_FIELD | VARIANT => true,
39093914
_ => false,
39103915
}
39113916
}

crates/syntax/src/tests/sourcegen_ast.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,9 +793,11 @@ fn extract_struct_traits(ast: &mut AstSrc) {
793793
"Const",
794794
"TypeAlias",
795795
"Impl",
796+
"ExternBlock",
797+
"ExternCrate",
798+
"MacroCall",
796799
"MacroRules",
797800
"MacroDef",
798-
"Macro",
799801
"Use",
800802
];
801803

0 commit comments

Comments
 (0)