mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 20:31:59 +00:00
Generate a method for static retrieval of the SyntaxKind of a node, where possible
This will help for the quote macro for `ast::make`.
This commit is contained in:
parent
59bc7b49d0
commit
737500137f
3 changed files with 1093 additions and 0 deletions
|
|
@ -42,6 +42,14 @@ pub use self::{
|
|||
/// the same representation: a pointer to the tree root and a pointer to the
|
||||
/// node itself.
|
||||
pub trait AstNode {
|
||||
/// This panics if the `SyntaxKind` is not statically known.
|
||||
fn kind() -> SyntaxKind
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
panic!("dynamic `SyntaxKind` for `AstNode::kind()`")
|
||||
}
|
||||
|
||||
fn can_cast(kind: SyntaxKind) -> bool
|
||||
where
|
||||
Self: Sized;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue