Skip to content

Commit ca0c8da

Browse files
Generate a method for static retrieval of the SyntaxKind of a node, where possible
This will help for the quote macro for `ast::make`.
1 parent 259eaf9 commit ca0c8da

File tree

3 files changed

+1093
-0
lines changed

3 files changed

+1093
-0
lines changed

src/tools/rust-analyzer/crates/syntax/src/ast.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ pub use self::{
4242
/// the same representation: a pointer to the tree root and a pointer to the
4343
/// node itself.
4444
pub trait AstNode {
45+
/// This panics if the `SyntaxKind` is not statically known.
46+
fn kind() -> SyntaxKind
47+
where
48+
Self: Sized,
49+
{
50+
panic!("dynamic `SyntaxKind` for `AstNode::kind()`")
51+
}
52+
4553
fn can_cast(kind: SyntaxKind) -> bool
4654
where
4755
Self: Sized;

0 commit comments

Comments
 (0)