mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
more matches! sites
This commit is contained in:
parent
70255029cf
commit
a3fc4dbb04
1 changed files with 2 additions and 8 deletions
|
@ -169,10 +169,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> String {
|
||||||
quote! {
|
quote! {
|
||||||
impl AstNode for #name {
|
impl AstNode for #name {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
matches!(kind, #(#kinds)|*)
|
||||||
#(#kinds)|* => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
let res = match syntax.kind() {
|
let res = match syntax.kind() {
|
||||||
|
@ -253,10 +250,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> String {
|
||||||
}
|
}
|
||||||
impl AstNode for #name {
|
impl AstNode for #name {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
matches!(kind, #(#kinds)|*)
|
||||||
#(#kinds)|* => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
Self::can_cast(syntax.kind()).then(|| #name { syntax })
|
Self::can_cast(syntax.kind()).then(|| #name { syntax })
|
||||||
|
|
Loading…
Reference in a new issue