aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorMichael Chesser <[email protected]>2020-01-06 22:59:03 +0000
committerMichael Chesser <[email protected]>2020-01-06 22:59:03 +0000
commitce1b34fd59a6145a4bb5682d672c846e101725d4 (patch)
tree8a9535261dac04f171caa68d4b908cdde0b4a34c /crates/ra_syntax/src
parentc92a090f49cad2fa540562536f07fcb619f16680 (diff)
Improve const generics parsing
- Handle const generics type args - Fix issue with const generic as first parameter in trait impl
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 2eb4b14d2..33d5578e7 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -3114,6 +3114,9 @@ impl TypeArgList {
3114 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { 3114 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
3115 AstChildren::new(&self.syntax) 3115 AstChildren::new(&self.syntax)
3116 } 3116 }
3117 pub fn const_arg(&self) -> AstChildren<ConstArg> {
3118 AstChildren::new(&self.syntax)
3119 }
3117} 3120}
3118#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3121#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3119pub struct TypeArg { 3122pub struct TypeArg {
@@ -3196,6 +3199,36 @@ impl AstNode for LifetimeArg {
3196} 3199}
3197impl LifetimeArg {} 3200impl LifetimeArg {}
3198#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3201#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3202pub struct ConstArg {
3203 pub(crate) syntax: SyntaxNode,
3204}
3205impl AstNode for ConstArg {
3206 fn can_cast(kind: SyntaxKind) -> bool {
3207 match kind {
3208 CONST_ARG => true,
3209 _ => false,
3210 }
3211 }
3212 fn cast(syntax: SyntaxNode) -> Option<Self> {
3213 if Self::can_cast(syntax.kind()) {
3214 Some(Self { syntax })
3215 } else {
3216 None
3217 }
3218 }
3219 fn syntax(&self) -> &SyntaxNode {
3220 &self.syntax
3221 }
3222}
3223impl ConstArg {
3224 pub fn literal(&self) -> Option<Literal> {
3225 AstChildren::new(&self.syntax).next()
3226 }
3227 pub fn block_expr(&self) -> Option<BlockExpr> {
3228 AstChildren::new(&self.syntax).next()
3229 }
3230}
3231#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3199pub struct MacroItems { 3232pub struct MacroItems {
3200 pub(crate) syntax: SyntaxNode, 3233 pub(crate) syntax: SyntaxNode,
3201} 3234}