From c83467796b6c7365ea4f41900d74444384a9e618 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 18:17:28 +0200 Subject: Finalize Trait grammar --- crates/ra_syntax/src/ast/generated/nodes.rs | 32 +++++++++++----------- crates/ra_syntax/src/ast/node_ext.rs | 2 +- crates/ra_syntax/src/parsing/text_tree_sink.rs | 2 +- .../test_data/parser/err/0022_bad_exprs.rast | 2 +- .../test_data/parser/err/0043_default_const.rast | 2 +- .../parser/inline/err/0014_default_fn_type.rast | 2 +- .../parser/inline/ok/0016_unsafe_trait.rast | 2 +- .../parser/inline/ok/0041_trait_item.rast | 4 +-- .../test_data/parser/inline/ok/0050_fn_decl.rast | 2 +- .../parser/inline/ok/0091_auto_trait.rast | 2 +- .../parser/inline/ok/0094_unsafe_auto_trait.rast | 2 +- .../parser/inline/ok/0151_trait_alias.rast | 6 ++-- .../ra_syntax/test_data/parser/ok/0030_traits.rast | 4 +-- .../test_data/parser/ok/0051_parameter_attrs.rast | 2 +- .../parser/ok/0063_trait_fn_patterns.rast | 2 +- 15 files changed, 34 insertions(+), 34 deletions(-) (limited to 'crates/ra_syntax') 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 { pub fn field_list(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TraitDef { +pub struct Trait { pub(crate) syntax: SyntaxNode, } -impl ast::AttrsOwner for TraitDef {} -impl ast::NameOwner for TraitDef {} -impl ast::VisibilityOwner for TraitDef {} -impl ast::GenericParamsOwner for TraitDef {} -impl ast::TypeBoundsOwner for TraitDef {} -impl TraitDef { +impl ast::AttrsOwner for Trait {} +impl ast::NameOwner for Trait {} +impl ast::VisibilityOwner for Trait {} +impl ast::GenericParamsOwner for Trait {} +impl ast::TypeBoundsOwner for Trait {} +impl Trait { pub fn unsafe_token(&self) -> Option { support::token(&self.syntax, T![unsafe]) } pub fn auto_token(&self) -> Option { support::token(&self.syntax, T![auto]) } pub fn trait_token(&self) -> Option { support::token(&self.syntax, T![trait]) } @@ -1283,7 +1283,7 @@ pub enum Item { Module(Module), Static(Static), Struct(Struct), - TraitDef(TraitDef), + Trait(Trait), TypeAlias(TypeAlias), Union(Union), Use(Use), @@ -1532,8 +1532,8 @@ impl AstNode for Struct { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for TraitDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } +impl AstNode for Trait { + fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2805,8 +2805,8 @@ impl From for Item { impl From for Item { fn from(node: Struct) -> Item { Item::Struct(node) } } -impl From for Item { - fn from(node: TraitDef) -> Item { Item::TraitDef(node) } +impl From for Item { + fn from(node: Trait) -> Item { Item::Trait(node) } } impl From for Item { fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } @@ -2821,7 +2821,7 @@ impl AstNode for Item { fn can_cast(kind: SyntaxKind) -> bool { match kind { CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL | MODULE - | STATIC | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true, + | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, _ => false, } } @@ -2837,7 +2837,7 @@ impl AstNode for Item { MODULE => Item::Module(Module { syntax }), STATIC => Item::Static(Static { syntax }), STRUCT => Item::Struct(Struct { syntax }), - TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), + TRAIT => Item::Trait(Trait { syntax }), TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), UNION => Item::Union(Union { syntax }), USE => Item::Use(Use { syntax }), @@ -2857,7 +2857,7 @@ impl AstNode for Item { Item::Module(it) => &it.syntax, Item::Static(it) => &it.syntax, Item::Struct(it) => &it.syntax, - Item::TraitDef(it) => &it.syntax, + Item::Trait(it) => &it.syntax, Item::TypeAlias(it) => &it.syntax, Item::Union(it) => &it.syntax, Item::Use(it) => &it.syntax, @@ -3516,7 +3516,7 @@ impl std::fmt::Display for Struct { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for TraitDef { +impl std::fmt::Display for Trait { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } 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 {} impl ast::DocCommentsOwner for ast::TupleField {} impl ast::DocCommentsOwner for ast::Enum {} impl ast::DocCommentsOwner for ast::Variant {} -impl ast::DocCommentsOwner for ast::TraitDef {} +impl ast::DocCommentsOwner for ast::Trait {} impl ast::DocCommentsOwner for ast::Module {} impl ast::DocCommentsOwner for ast::Static {} impl 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>( trivias: impl Iterator, ) -> usize { match kind { - MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT_DEF | MODULE + MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT | MODULE | RECORD_FIELD | STATIC => { let mut res = 0; 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 @@ SOURCE_FILE@0..112 ERROR@96..97 COMMA@96..97 "," WHITESPACE@97..98 " " - TRAIT_DEF@98..104 + TRAIT@98..104 TRAIT_KW@98..103 "trait" ERROR@103..104 COMMA@103..104 "," 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 @@ SOURCE_FILE@0..39 - TRAIT_DEF@0..38 + TRAIT@0..38 TRAIT_KW@0..5 "trait" WHITESPACE@5..6 " " NAME@6..7 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 @@ SOURCE_FILE@0..62 - TRAIT_DEF@0..61 + TRAIT@0..61 TRAIT_KW@0..5 "trait" WHITESPACE@5..6 " " NAME@6..7 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 @@ SOURCE_FILE@0..18 - TRAIT_DEF@0..17 + TRAIT@0..17 UNSAFE_KW@0..6 "unsafe" WHITESPACE@6..7 " " TRAIT_KW@7..12 "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 @@ SOURCE_FILE@0..101 - TRAIT_DEF@0..41 + TRAIT@0..41 TRAIT_KW@0..5 "trait" WHITESPACE@5..6 " " NAME@6..7 @@ -52,7 +52,7 @@ SOURCE_FILE@0..101 L_CURLY@39..40 "{" R_CURLY@40..41 "}" WHITESPACE@41..42 "\n" - TRAIT_DEF@42..100 + TRAIT@42..100 TRAIT_KW@42..47 "trait" WHITESPACE@47..48 " " NAME@48..49 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 @@ SOURCE_FILE@0..22 - TRAIT_DEF@0..21 + TRAIT@0..21 TRAIT_KW@0..5 "trait" WHITESPACE@5..6 " " NAME@6..7 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 @@ SOURCE_FILE@0..16 - TRAIT_DEF@0..15 + TRAIT@0..15 AUTO_KW@0..4 "auto" WHITESPACE@4..5 " " TRAIT_KW@5..10 "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 @@ SOURCE_FILE@0..23 - TRAIT_DEF@0..22 + TRAIT@0..22 UNSAFE_KW@0..6 "unsafe" WHITESPACE@6..7 " " AUTO_KW@7..11 "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 @@ SOURCE_FILE@0..83 - TRAIT_DEF@0..18 + TRAIT@0..18 TRAIT_KW@0..5 "trait" WHITESPACE@5..6 " " NAME@6..7 @@ -31,7 +31,7 @@ SOURCE_FILE@0..83 R_ANGLE@16..17 ">" SEMICOLON@17..18 ";" WHITESPACE@18..19 "\n" - TRAIT_DEF@19..51 + TRAIT@19..51 TRAIT_KW@19..24 "trait" WHITESPACE@24..25 " " NAME@25..26 @@ -82,7 +82,7 @@ SOURCE_FILE@0..83 IDENT@46..50 "Copy" SEMICOLON@50..51 ";" WHITESPACE@51..52 "\n" - TRAIT_DEF@52..82 + TRAIT@52..82 TRAIT_KW@52..57 "trait" WHITESPACE@57..58 " " NAME@58..59 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 @@ SOURCE_FILE@0..96 - TRAIT_DEF@0..36 + TRAIT@0..36 TRAIT_KW@0..5 "trait" WHITESPACE@5..6 " " NAME@6..14 @@ -20,7 +20,7 @@ SOURCE_FILE@0..96 WHITESPACE@34..35 "\n" R_CURLY@35..36 "}" WHITESPACE@36..38 "\n\n" - TRAIT_DEF@38..95 + TRAIT@38..95 TRAIT_KW@38..43 "trait" WHITESPACE@43..44 " " NAME@44..57 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 @@ SOURCE_FILE@0..519 L_CURLY@170..171 "{" R_CURLY@171..172 "}" WHITESPACE@172..174 "\n\n" - TRAIT_DEF@174..236 + TRAIT@174..236 TRAIT_KW@174..179 "trait" WHITESPACE@179..180 " " NAME@180..183 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 @@ SOURCE_FILE@0..170 - TRAIT_DEF@0..169 + TRAIT@0..169 TRAIT_KW@0..5 "trait" WHITESPACE@5..6 " " NAME@6..7 -- cgit v1.2.3