Skip to content

Commit 55a2998

Browse files
committed
Revert "Remove MacroStmts as per edwin0cheng" (cc @edwin0cheng) and add a fixme to document it.
This reverts commit 7a49165. MacroStmts ast node is not used by itself, but it pertains to SyntaxNodeKind MACRO_STMTS that is used by ra_paser, so even tho the node itself is not used, it is better to keep it with a FIXME to actually add a doc comment when it becomes useful.
1 parent 24b27ab commit 55a2998

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,6 +2491,22 @@ pub struct MacroItems {
24912491
}
24922492
impl ast::ModuleItemOwner for MacroItems {}
24932493
impl MacroItems {}
2494+
/// FIXME: (@edwin0cheng) add some documentation here. As per the writing
2495+
/// of this comment this ast node is not used.
2496+
///
2497+
/// ```
2498+
/// // FIXME: example here
2499+
/// ```
2500+
///
2501+
/// [Reference](https://doc.rust-lang.org/reference/macros.html)
2502+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2503+
pub struct MacroStmts {
2504+
pub(crate) syntax: SyntaxNode,
2505+
}
2506+
impl MacroStmts {
2507+
pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
2508+
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2509+
}
24942510
/// List of items in an extern block.
24952511
///
24962512
/// ```
@@ -4047,6 +4063,17 @@ impl AstNode for MacroItems {
40474063
}
40484064
fn syntax(&self) -> &SyntaxNode { &self.syntax }
40494065
}
4066+
impl AstNode for MacroStmts {
4067+
fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS }
4068+
fn cast(syntax: SyntaxNode) -> Option<Self> {
4069+
if Self::can_cast(syntax.kind()) {
4070+
Some(Self { syntax })
4071+
} else {
4072+
None
4073+
}
4074+
}
4075+
fn syntax(&self) -> &SyntaxNode { &self.syntax }
4076+
}
40504077
impl AstNode for ExternItemList {
40514078
fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST }
40524079
fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -5479,6 +5506,11 @@ impl std::fmt::Display for MacroItems {
54795506
std::fmt::Display::fmt(self.syntax(), f)
54805507
}
54815508
}
5509+
impl std::fmt::Display for MacroStmts {
5510+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5511+
std::fmt::Display::fmt(self.syntax(), f)
5512+
}
5513+
}
54825514
impl std::fmt::Display for ExternItemList {
54835515
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
54845516
std::fmt::Display::fmt(self.syntax(), f)

xtask/src/ast_src.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,6 +2016,19 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
20162016
/// [Reference](https://doc.rust-lang.org/reference/macros.html)
20172017
struct MacroItems: ModuleItemOwner { }
20182018

2019+
/// FIXME: (@edwin0cheng) add some documentation here. As per the writing
2020+
/// of this comment this ast node is not used.
2021+
///
2022+
/// ```
2023+
/// // FIXME: example here
2024+
/// ```
2025+
///
2026+
/// [Reference](https://doc.rust-lang.org/reference/macros.html)
2027+
struct MacroStmts {
2028+
statements: [Stmt],
2029+
Expr,
2030+
}
2031+
20192032
/// List of items in an extern block.
20202033
///
20212034
/// ```

0 commit comments

Comments
 (0)