aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-30 17:17:28 +0100
committerAleksey Kladov <[email protected]>2020-07-30 17:17:28 +0100
commitc83467796b6c7365ea4f41900d74444384a9e618 (patch)
tree6eb770e4c9751813cc0530e7c645fed8914eed12 /crates/ra_syntax
parentb2cdb0b22631a66a00be25ba4b2e9c0b34ff426a (diff)
Finalize Trait grammar
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs32
-rw-r--r--crates/ra_syntax/src/ast/node_ext.rs2
-rw-r--r--crates/ra_syntax/src/parsing/text_tree_sink.rs2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0043_default_const.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0030_traits.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast2
15 files changed, 34 insertions, 34 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 00a70fce0..3adb6b2d4 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -169,15 +169,15 @@ impl Struct {
169 pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) } 169 pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
170} 170}
171#[derive(Debug, Clone, PartialEq, Eq, Hash)] 171#[derive(Debug, Clone, PartialEq, Eq, Hash)]
172pub struct TraitDef { 172pub struct Trait {
173 pub(crate) syntax: SyntaxNode, 173 pub(crate) syntax: SyntaxNode,
174} 174}
175impl ast::AttrsOwner for TraitDef {} 175impl ast::AttrsOwner for Trait {}
176impl ast::NameOwner for TraitDef {} 176impl ast::NameOwner for Trait {}
177impl ast::VisibilityOwner for TraitDef {} 177impl ast::VisibilityOwner for Trait {}
178impl ast::GenericParamsOwner for TraitDef {} 178impl ast::GenericParamsOwner for Trait {}
179impl ast::TypeBoundsOwner for TraitDef {} 179impl ast::TypeBoundsOwner for Trait {}
180impl TraitDef { 180impl Trait {
181 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 181 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
182 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) } 182 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
183 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) } 183 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
@@ -1283,7 +1283,7 @@ pub enum Item {
1283 Module(Module), 1283 Module(Module),
1284 Static(Static), 1284 Static(Static),
1285 Struct(Struct), 1285 Struct(Struct),
1286 TraitDef(TraitDef), 1286 Trait(Trait),
1287 TypeAlias(TypeAlias), 1287 TypeAlias(TypeAlias),
1288 Union(Union), 1288 Union(Union),
1289 Use(Use), 1289 Use(Use),
@@ -1532,8 +1532,8 @@ impl AstNode for Struct {
1532 } 1532 }
1533 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1533 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1534} 1534}
1535impl AstNode for TraitDef { 1535impl AstNode for Trait {
1536 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } 1536 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT }
1537 fn cast(syntax: SyntaxNode) -> Option<Self> { 1537 fn cast(syntax: SyntaxNode) -> Option<Self> {
1538 if Self::can_cast(syntax.kind()) { 1538 if Self::can_cast(syntax.kind()) {
1539 Some(Self { syntax }) 1539 Some(Self { syntax })
@@ -2805,8 +2805,8 @@ impl From<Static> for Item {
2805impl From<Struct> for Item { 2805impl From<Struct> for Item {
2806 fn from(node: Struct) -> Item { Item::Struct(node) } 2806 fn from(node: Struct) -> Item { Item::Struct(node) }
2807} 2807}
2808impl From<TraitDef> for Item { 2808impl From<Trait> for Item {
2809 fn from(node: TraitDef) -> Item { Item::TraitDef(node) } 2809 fn from(node: Trait) -> Item { Item::Trait(node) }
2810} 2810}
2811impl From<TypeAlias> for Item { 2811impl From<TypeAlias> for Item {
2812 fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } 2812 fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) }
@@ -2821,7 +2821,7 @@ impl AstNode for Item {
2821 fn can_cast(kind: SyntaxKind) -> bool { 2821 fn can_cast(kind: SyntaxKind) -> bool {
2822 match kind { 2822 match kind {
2823 CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL | MODULE 2823 CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL | MODULE
2824 | STATIC | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true, 2824 | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true,
2825 _ => false, 2825 _ => false,
2826 } 2826 }
2827 } 2827 }
@@ -2837,7 +2837,7 @@ impl AstNode for Item {
2837 MODULE => Item::Module(Module { syntax }), 2837 MODULE => Item::Module(Module { syntax }),
2838 STATIC => Item::Static(Static { syntax }), 2838 STATIC => Item::Static(Static { syntax }),
2839 STRUCT => Item::Struct(Struct { syntax }), 2839 STRUCT => Item::Struct(Struct { syntax }),
2840 TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), 2840 TRAIT => Item::Trait(Trait { syntax }),
2841 TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), 2841 TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }),
2842 UNION => Item::Union(Union { syntax }), 2842 UNION => Item::Union(Union { syntax }),
2843 USE => Item::Use(Use { syntax }), 2843 USE => Item::Use(Use { syntax }),
@@ -2857,7 +2857,7 @@ impl AstNode for Item {
2857 Item::Module(it) => &it.syntax, 2857 Item::Module(it) => &it.syntax,
2858 Item::Static(it) => &it.syntax, 2858 Item::Static(it) => &it.syntax,
2859 Item::Struct(it) => &it.syntax, 2859 Item::Struct(it) => &it.syntax,
2860 Item::TraitDef(it) => &it.syntax, 2860 Item::Trait(it) => &it.syntax,
2861 Item::TypeAlias(it) => &it.syntax, 2861 Item::TypeAlias(it) => &it.syntax,
2862 Item::Union(it) => &it.syntax, 2862 Item::Union(it) => &it.syntax,
2863 Item::Use(it) => &it.syntax, 2863 Item::Use(it) => &it.syntax,
@@ -3516,7 +3516,7 @@ impl std::fmt::Display for Struct {
3516 std::fmt::Display::fmt(self.syntax(), f) 3516 std::fmt::Display::fmt(self.syntax(), f)
3517 } 3517 }
3518} 3518}
3519impl std::fmt::Display for TraitDef { 3519impl std::fmt::Display for Trait {
3520 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3520 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3521 std::fmt::Display::fmt(self.syntax(), f) 3521 std::fmt::Display::fmt(self.syntax(), f)
3522 } 3522 }
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs
index 4da1d5c11..a8d8955de 100644
--- a/crates/ra_syntax/src/ast/node_ext.rs
+++ b/crates/ra_syntax/src/ast/node_ext.rs
@@ -481,7 +481,7 @@ impl ast::DocCommentsOwner for ast::RecordField {}
481impl ast::DocCommentsOwner for ast::TupleField {} 481impl ast::DocCommentsOwner for ast::TupleField {}
482impl ast::DocCommentsOwner for ast::Enum {} 482impl ast::DocCommentsOwner for ast::Enum {}
483impl ast::DocCommentsOwner for ast::Variant {} 483impl ast::DocCommentsOwner for ast::Variant {}
484impl ast::DocCommentsOwner for ast::TraitDef {} 484impl ast::DocCommentsOwner for ast::Trait {}
485impl ast::DocCommentsOwner for ast::Module {} 485impl ast::DocCommentsOwner for ast::Module {}
486impl ast::DocCommentsOwner for ast::Static {} 486impl ast::DocCommentsOwner for ast::Static {}
487impl ast::DocCommentsOwner for ast::Const {} 487impl ast::DocCommentsOwner for ast::Const {}
diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs
index 95581a84b..6d1828d20 100644
--- a/crates/ra_syntax/src/parsing/text_tree_sink.rs
+++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs
@@ -146,7 +146,7 @@ fn n_attached_trivias<'a>(
146 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, 146 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
147) -> usize { 147) -> usize {
148 match kind { 148 match kind {
149 MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT_DEF | MODULE 149 MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT | MODULE
150 | RECORD_FIELD | STATIC => { 150 | RECORD_FIELD | STATIC => {
151 let mut res = 0; 151 let mut res = 0;
152 let mut trivias = trivias.enumerate().peekable(); 152 let mut trivias = trivias.enumerate().peekable();
diff --git a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast
index 02339d035..a6e304b78 100644
--- a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast
+++ b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast
@@ -133,7 +133,7 @@ [email protected]
133 [email protected] 133 [email protected]
134 [email protected] "," 134 [email protected] ","
135 [email protected] " " 135 [email protected] " "
136 TRAIT_DEF@98..104 136 [email protected]
137 [email protected] "trait" 137 [email protected] "trait"
138 [email protected] 138 [email protected]
139 [email protected] "," 139 [email protected] ","
diff --git a/crates/ra_syntax/test_data/parser/err/0043_default_const.rast b/crates/ra_syntax/test_data/parser/err/0043_default_const.rast
index f041fa6f7..51ad2a846 100644
--- a/crates/ra_syntax/test_data/parser/err/0043_default_const.rast
+++ b/crates/ra_syntax/test_data/parser/err/0043_default_const.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..38 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast b/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast
index 22c7c5f0d..acd72094b 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..61 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast
index 69b82e33c..625ab4c2d 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..17 2 [email protected]
3 [email protected] "unsafe" 3 [email protected] "unsafe"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "trait" 5 [email protected] "trait"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast b/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast
index 8f20ccaa3..3638462f8 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..41 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -52,7 +52,7 @@ [email protected]
52 [email protected] "{" 52 [email protected] "{"
53 [email protected] "}" 53 [email protected] "}"
54 [email protected] "\n" 54 [email protected] "\n"
55 TRAIT_DEF@42..100 55 [email protected]
56 [email protected] "trait" 56 [email protected] "trait"
57 [email protected] " " 57 [email protected] " "
58 [email protected] 58 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast
index 02c57079f..a5bf55131 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..21 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast
index 7efa4c34d..0cac9ac43 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..15 2 [email protected]
3 [email protected] "auto" 3 [email protected] "auto"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "trait" 5 [email protected] "trait"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast
index fad27be66..0ef11c682 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..22 2 [email protected]
3 [email protected] "unsafe" 3 [email protected] "unsafe"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "auto" 5 [email protected] "auto"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast b/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast
index e2a770a37..cc220e534 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..18 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -31,7 +31,7 @@ [email protected]
31 [email protected] ">" 31 [email protected] ">"
32 [email protected] ";" 32 [email protected] ";"
33 [email protected] "\n" 33 [email protected] "\n"
34 TRAIT_DEF@19..51 34 [email protected]
35 [email protected] "trait" 35 [email protected] "trait"
36 [email protected] " " 36 [email protected] " "
37 [email protected] 37 [email protected]
@@ -82,7 +82,7 @@ [email protected]
82 [email protected] "Copy" 82 [email protected] "Copy"
83 [email protected] ";" 83 [email protected] ";"
84 [email protected] "\n" 84 [email protected] "\n"
85 TRAIT_DEF@52..82 85 [email protected]
86 [email protected] "trait" 86 [email protected] "trait"
87 [email protected] " " 87 [email protected] " "
88 [email protected] 88 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0030_traits.rast b/crates/ra_syntax/test_data/parser/ok/0030_traits.rast
index 4bcf07ffb..280d4cb82 100644
--- a/crates/ra_syntax/test_data/parser/ok/0030_traits.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0030_traits.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..36 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -20,7 +20,7 @@ [email protected]
20 [email protected] "\n" 20 [email protected] "\n"
21 [email protected] "}" 21 [email protected] "}"
22 [email protected] "\n\n" 22 [email protected] "\n\n"
23 TRAIT_DEF@38..95 23 [email protected]
24 [email protected] "trait" 24 [email protected] "trait"
25 [email protected] " " 25 [email protected] " "
26 [email protected] 26 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast
index 8081eefbc..7a574ebb4 100644
--- a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast
@@ -186,7 +186,7 @@ [email protected]
186 [email protected] "{" 186 [email protected] "{"
187 [email protected] "}" 187 [email protected] "}"
188 [email protected] "\n\n" 188 [email protected] "\n\n"
189 TRAIT_DEF@174..236 189 [email protected]
190 [email protected] "trait" 190 [email protected] "trait"
191 [email protected] " " 191 [email protected] " "
192 [email protected] 192 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast b/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast
index a87bbf4eb..facce8167 100644
--- a/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..169 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]