aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs30
-rw-r--r--crates/ra_syntax/src/grammar.ron5
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt23
4 files changed, 59 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 8d65e2e08..9f9d6e63c 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -551,6 +551,36 @@ impl ConstDef {
551 } 551 }
552} 552}
553#[derive(Debug, Clone, PartialEq, Eq, Hash)] 553#[derive(Debug, Clone, PartialEq, Eq, Hash)]
554pub struct ConstParam {
555 pub(crate) syntax: SyntaxNode,
556}
557impl AstNode for ConstParam {
558 fn can_cast(kind: SyntaxKind) -> bool {
559 match kind {
560 CONST_PARAM => true,
561 _ => false,
562 }
563 }
564 fn cast(syntax: SyntaxNode) -> Option<Self> {
565 if Self::can_cast(syntax.kind()) {
566 Some(Self { syntax })
567 } else {
568 None
569 }
570 }
571 fn syntax(&self) -> &SyntaxNode {
572 &self.syntax
573 }
574}
575impl ast::NameOwner for ConstParam {}
576impl ast::AttrsOwner for ConstParam {}
577impl ast::TypeAscriptionOwner for ConstParam {}
578impl ConstParam {
579 pub fn default_val(&self) -> Option<Expr> {
580 AstChildren::new(&self.syntax).next()
581 }
582}
583#[derive(Debug, Clone, PartialEq, Eq, Hash)]
554pub struct ContinueExpr { 584pub struct ContinueExpr {
555 pub(crate) syntax: SyntaxNode, 585 pub(crate) syntax: SyntaxNode,
556} 586}
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 3f1cd0b90..08aafb610 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -245,6 +245,7 @@ Grammar(
245 "TYPE_PARAM_LIST", 245 "TYPE_PARAM_LIST",
246 "LIFETIME_PARAM", 246 "LIFETIME_PARAM",
247 "TYPE_PARAM", 247 "TYPE_PARAM",
248 "CONST_PARAM",
248 "TYPE_ARG_LIST", 249 "TYPE_ARG_LIST",
249 "LIFETIME_ARG", 250 "LIFETIME_ARG",
250 "TYPE_ARG", 251 "TYPE_ARG",
@@ -604,6 +605,10 @@ Grammar(
604 options: [("default_type", "TypeRef")], 605 options: [("default_type", "TypeRef")],
605 traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"], 606 traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"],
606 ), 607 ),
608 "ConstParam": (
609 options: [("default_val", "Expr")],
610 traits: ["NameOwner", "AttrsOwner", "TypeAscriptionOwner"],
611 ),
607 "LifetimeParam": ( 612 "LifetimeParam": (
608 traits: ["AttrsOwner"], 613 traits: ["AttrsOwner"],
609 ), 614 ),
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rs b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rs
new file mode 100644
index 000000000..8cdb3b703
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rs
@@ -0,0 +1 @@
struct S<const N: u32>;
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt
new file mode 100644
index 000000000..f81de7bac
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt
@@ -0,0 +1,23 @@
1SOURCE_FILE@[0; 24)
2 STRUCT_DEF@[0; 23)
3 STRUCT_KW@[0; 6) "struct"
4 WHITESPACE@[6; 7) " "
5 NAME@[7; 8)
6 IDENT@[7; 8) "S"
7 TYPE_PARAM_LIST@[8; 22)
8 L_ANGLE@[8; 9) "<"
9 CONST_PARAM@[9; 21)
10 CONST_KW@[9; 14) "const"
11 WHITESPACE@[14; 15) " "
12 NAME@[15; 16)
13 IDENT@[15; 16) "N"
14 COLON@[16; 17) ":"
15 WHITESPACE@[17; 18) " "
16 PATH_TYPE@[18; 21)
17 PATH@[18; 21)
18 PATH_SEGMENT@[18; 21)
19 NAME_REF@[18; 21)
20 IDENT@[18; 21) "u32"
21 R_ANGLE@[21; 22) ">"
22 SEMI@[22; 23) ";"
23 WHITESPACE@[23; 24) "\n"