From 1142112c70b705f59b7d559d9d72cdc831865158 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 14:51:08 +0200 Subject: Rename FnDef -> Fn --- crates/ra_syntax/src/ast/edit.rs | 4 +- crates/ra_syntax/src/ast/expr_ext.rs | 2 +- crates/ra_syntax/src/ast/generated/nodes.rs | 415 +++++++++++++------------ crates/ra_syntax/src/ast/make.rs | 2 +- crates/ra_syntax/src/ast/node_ext.rs | 2 +- crates/ra_syntax/src/lib.rs | 6 +- crates/ra_syntax/src/parsing/text_tree_sink.rs | 2 +- crates/ra_syntax/src/validation.rs | 4 +- crates/ra_syntax/src/validation/block.rs | 2 +- 9 files changed, 221 insertions(+), 218 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 6ebe10ff6..4a67fd44a 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs @@ -29,9 +29,9 @@ impl ast::BinExpr { } } -impl ast::FnDef { +impl ast::Fn { #[must_use] - pub fn with_body(&self, body: ast::BlockExpr) -> ast::FnDef { + pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn { let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { old_body.syntax().clone().into() diff --git a/crates/ra_syntax/src/ast/expr_ext.rs b/crates/ra_syntax/src/ast/expr_ext.rs index 69c85c809..8692b9bb5 100644 --- a/crates/ra_syntax/src/ast/expr_ext.rs +++ b/crates/ra_syntax/src/ast/expr_ext.rs @@ -401,7 +401,7 @@ impl ast::BlockExpr { Some(it) => it, None => return true, }; - !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) + !matches!(parent.kind(), FN | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) } } diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index be657699f..4fc35585d 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -79,19 +79,19 @@ impl ExternCrate { pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct FnDef { +pub struct Fn { pub(crate) syntax: SyntaxNode, } -impl ast::AttrsOwner for FnDef {} -impl ast::NameOwner for FnDef {} -impl ast::VisibilityOwner for FnDef {} -impl ast::TypeParamsOwner for FnDef {} -impl FnDef { - pub fn abi(&self) -> Option { support::child(&self.syntax) } - pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } +impl ast::AttrsOwner for Fn {} +impl ast::NameOwner for Fn {} +impl ast::VisibilityOwner for Fn {} +impl ast::TypeParamsOwner for Fn {} +impl Fn { pub fn default_token(&self) -> Option { support::token(&self.syntax, T![default]) } pub fn async_token(&self) -> Option { support::token(&self.syntax, T![async]) } + pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } pub fn unsafe_token(&self) -> Option { support::token(&self.syntax, T![unsafe]) } + pub fn abi(&self) -> Option { support::child(&self.syntax) } pub fn fn_token(&self) -> Option { support::token(&self.syntax, T![fn]) } pub fn param_list(&self) -> Option { support::child(&self.syntax) } pub fn ret_type(&self) -> Option { support::child(&self.syntax) } @@ -303,7 +303,9 @@ impl UseTreeList { pub struct Abi { pub(crate) syntax: SyntaxNode, } -impl Abi {} +impl Abi { + pub fn extern_token(&self) -> Option { support::token(&self.syntax, T![extern]) } +} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TypeParamList { pub(crate) syntax: SyntaxNode, @@ -321,8 +323,9 @@ pub struct ParamList { } impl ParamList { pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } - pub fn self_param(&self) -> Option { support::child(&self.syntax) } pub fn params(&self) -> AstChildren { support::children(&self.syntax) } + pub fn self_param(&self) -> Option { support::child(&self.syntax) } + pub fn comma_token(&self) -> Option { support::token(&self.syntax, T![,]) } pub fn r_paren_token(&self) -> Option { support::token(&self.syntax, T![')']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -355,6 +358,32 @@ impl BlockExpr { pub fn r_curly_token(&self) -> Option { support::token(&self.syntax, T!['}']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Param { + pub(crate) syntax: SyntaxNode, +} +impl ast::AttrsOwner for Param {} +impl ast::TypeAscriptionOwner for Param {} +impl Param { + pub fn pat(&self) -> Option { support::child(&self.syntax) } + pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } + pub fn dotdotdot_token(&self) -> Option { support::token(&self.syntax, T![...]) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct SelfParam { + pub(crate) syntax: SyntaxNode, +} +impl ast::AttrsOwner for SelfParam {} +impl ast::TypeAscriptionOwner for SelfParam {} +impl SelfParam { + pub fn amp_token(&self) -> Option { support::token(&self.syntax, T![&]) } + pub fn lifetime_token(&self) -> Option { + support::token(&self.syntax, T![lifetime]) + } + pub fn mut_token(&self) -> Option { support::token(&self.syntax, T![mut]) } + pub fn self_token(&self) -> Option { support::token(&self.syntax, T![self]) } + pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RecordFieldDefList { pub(crate) syntax: SyntaxNode, } @@ -1173,32 +1202,6 @@ impl LetStmt { pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct SelfParam { - pub(crate) syntax: SyntaxNode, -} -impl ast::AttrsOwner for SelfParam {} -impl ast::TypeAscriptionOwner for SelfParam {} -impl SelfParam { - pub fn amp_token(&self) -> Option { support::token(&self.syntax, T![&]) } - pub fn lifetime_token(&self) -> Option { - support::token(&self.syntax, T![lifetime]) - } - pub fn mut_token(&self) -> Option { support::token(&self.syntax, T![mut]) } - pub fn self_token(&self) -> Option { support::token(&self.syntax, T![self]) } - pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct Param { - pub(crate) syntax: SyntaxNode, -} -impl ast::AttrsOwner for Param {} -impl ast::TypeAscriptionOwner for Param {} -impl Param { - pub fn pat(&self) -> Option { support::child(&self.syntax) } - pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } - pub fn dotdotdot_token(&self) -> Option { support::token(&self.syntax, T![...]) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct PathSegment { pub(crate) syntax: SyntaxNode, } @@ -1274,7 +1277,7 @@ pub enum Item { EnumDef(EnumDef), ExternBlock(ExternBlock), ExternCrate(ExternCrate), - FnDef(FnDef), + Fn(Fn), ImplDef(ImplDef), MacroCall(MacroCall), Module(Module), @@ -1303,6 +1306,24 @@ pub enum TypeRef { DynTraitType(DynTraitType), } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum Pat { + OrPat(OrPat), + ParenPat(ParenPat), + RefPat(RefPat), + BoxPat(BoxPat), + BindPat(BindPat), + PlaceholderPat(PlaceholderPat), + DotDotPat(DotDotPat), + PathPat(PathPat), + RecordPat(RecordPat), + TupleStructPat(TupleStructPat), + TuplePat(TuplePat), + SlicePat(SlicePat), + RangePat(RangePat), + LiteralPat(LiteralPat), + MacroPat(MacroPat), +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum FieldDefList { RecordFieldDefList(RecordFieldDefList), TupleFieldDefList(TupleFieldDefList), @@ -1343,7 +1364,7 @@ pub enum Expr { } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AssocItem { - FnDef(FnDef), + Fn(Fn), TypeAliasDef(TypeAliasDef), ConstDef(ConstDef), MacroCall(MacroCall), @@ -1351,24 +1372,6 @@ pub enum AssocItem { impl ast::AttrsOwner for AssocItem {} impl ast::NameOwner for AssocItem {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub enum Pat { - OrPat(OrPat), - ParenPat(ParenPat), - RefPat(RefPat), - BoxPat(BoxPat), - BindPat(BindPat), - PlaceholderPat(PlaceholderPat), - DotDotPat(DotDotPat), - PathPat(PathPat), - RecordPat(RecordPat), - TupleStructPat(TupleStructPat), - TuplePat(TuplePat), - SlicePat(SlicePat), - RangePat(RangePat), - LiteralPat(LiteralPat), - MacroPat(MacroPat), -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Stmt { LetStmt(LetStmt), ExprStmt(ExprStmt), @@ -1381,7 +1384,7 @@ pub enum AttrInput { } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ExternItem { - FnDef(FnDef), + Fn(Fn), StaticDef(StaticDef), } impl ast::AttrsOwner for ExternItem {} @@ -1463,8 +1466,8 @@ impl AstNode for ExternCrate { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for FnDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } +impl AstNode for Fn { + fn can_cast(kind: SyntaxKind) -> bool { kind == FN } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1727,6 +1730,28 @@ impl AstNode for BlockExpr { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl AstNode for Param { + fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} +impl AstNode for SelfParam { + fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} impl AstNode for RecordFieldDefList { fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } fn cast(syntax: SyntaxNode) -> Option { @@ -2673,28 +2698,6 @@ impl AstNode for LetStmt { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for SelfParam { - fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} -impl AstNode for Param { - fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl AstNode for PathSegment { fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } fn cast(syntax: SyntaxNode) -> Option { @@ -2784,8 +2787,8 @@ impl From for Item { impl From for Item { fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } } -impl From for Item { - fn from(node: FnDef) -> Item { Item::FnDef(node) } +impl From for Item { + fn from(node: Fn) -> Item { Item::Fn(node) } } impl From for Item { fn from(node: ImplDef) -> Item { Item::ImplDef(node) } @@ -2817,7 +2820,7 @@ impl From for Item { impl AstNode for Item { fn can_cast(kind: SyntaxKind) -> bool { match kind { - CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL + CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => { true } @@ -2830,7 +2833,7 @@ impl AstNode for Item { ENUM_DEF => Item::EnumDef(EnumDef { syntax }), EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), - FN_DEF => Item::FnDef(FnDef { syntax }), + FN => Item::Fn(Fn { syntax }), IMPL_DEF => Item::ImplDef(ImplDef { syntax }), MACRO_CALL => Item::MacroCall(MacroCall { syntax }), MODULE => Item::Module(Module { syntax }), @@ -2850,7 +2853,7 @@ impl AstNode for Item { Item::EnumDef(it) => &it.syntax, Item::ExternBlock(it) => &it.syntax, Item::ExternCrate(it) => &it.syntax, - Item::FnDef(it) => &it.syntax, + Item::Fn(it) => &it.syntax, Item::ImplDef(it) => &it.syntax, Item::MacroCall(it) => &it.syntax, Item::Module(it) => &it.syntax, @@ -2948,6 +2951,101 @@ impl AstNode for TypeRef { } } } +impl From for Pat { + fn from(node: OrPat) -> Pat { Pat::OrPat(node) } +} +impl From for Pat { + fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } +} +impl From for Pat { + fn from(node: RefPat) -> Pat { Pat::RefPat(node) } +} +impl From for Pat { + fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } +} +impl From for Pat { + fn from(node: BindPat) -> Pat { Pat::BindPat(node) } +} +impl From for Pat { + fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } +} +impl From for Pat { + fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } +} +impl From for Pat { + fn from(node: PathPat) -> Pat { Pat::PathPat(node) } +} +impl From for Pat { + fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } +} +impl From for Pat { + fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } +} +impl From for Pat { + fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } +} +impl From for Pat { + fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } +} +impl From for Pat { + fn from(node: RangePat) -> Pat { Pat::RangePat(node) } +} +impl From for Pat { + fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } +} +impl From for Pat { + fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } +} +impl AstNode for Pat { + fn can_cast(kind: SyntaxKind) -> bool { + match kind { + OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT + | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT + | LITERAL_PAT | MACRO_PAT => true, + _ => false, + } + } + fn cast(syntax: SyntaxNode) -> Option { + let res = match syntax.kind() { + OR_PAT => Pat::OrPat(OrPat { syntax }), + PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), + REF_PAT => Pat::RefPat(RefPat { syntax }), + BOX_PAT => Pat::BoxPat(BoxPat { syntax }), + BIND_PAT => Pat::BindPat(BindPat { syntax }), + PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), + DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), + PATH_PAT => Pat::PathPat(PathPat { syntax }), + RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), + TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), + TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), + SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), + RANGE_PAT => Pat::RangePat(RangePat { syntax }), + LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), + MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), + _ => return None, + }; + Some(res) + } + fn syntax(&self) -> &SyntaxNode { + match self { + Pat::OrPat(it) => &it.syntax, + Pat::ParenPat(it) => &it.syntax, + Pat::RefPat(it) => &it.syntax, + Pat::BoxPat(it) => &it.syntax, + Pat::BindPat(it) => &it.syntax, + Pat::PlaceholderPat(it) => &it.syntax, + Pat::DotDotPat(it) => &it.syntax, + Pat::PathPat(it) => &it.syntax, + Pat::RecordPat(it) => &it.syntax, + Pat::TupleStructPat(it) => &it.syntax, + Pat::TuplePat(it) => &it.syntax, + Pat::SlicePat(it) => &it.syntax, + Pat::RangePat(it) => &it.syntax, + Pat::LiteralPat(it) => &it.syntax, + Pat::MacroPat(it) => &it.syntax, + } + } +} impl From for FieldDefList { fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) } } @@ -3157,8 +3255,8 @@ impl AstNode for Expr { } } } -impl From for AssocItem { - fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) } +impl From for AssocItem { + fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } } impl From for AssocItem { fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) } @@ -3172,13 +3270,13 @@ impl From for AssocItem { impl AstNode for AssocItem { fn can_cast(kind: SyntaxKind) -> bool { match kind { - FN_DEF | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true, + FN | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { - FN_DEF => AssocItem::FnDef(FnDef { syntax }), + FN => AssocItem::Fn(Fn { syntax }), TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }), CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }), MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), @@ -3188,108 +3286,13 @@ impl AstNode for AssocItem { } fn syntax(&self) -> &SyntaxNode { match self { - AssocItem::FnDef(it) => &it.syntax, + AssocItem::Fn(it) => &it.syntax, AssocItem::TypeAliasDef(it) => &it.syntax, AssocItem::ConstDef(it) => &it.syntax, AssocItem::MacroCall(it) => &it.syntax, } } } -impl From for Pat { - fn from(node: OrPat) -> Pat { Pat::OrPat(node) } -} -impl From for Pat { - fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } -} -impl From for Pat { - fn from(node: RefPat) -> Pat { Pat::RefPat(node) } -} -impl From for Pat { - fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } -} -impl From for Pat { - fn from(node: BindPat) -> Pat { Pat::BindPat(node) } -} -impl From for Pat { - fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } -} -impl From for Pat { - fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } -} -impl From for Pat { - fn from(node: PathPat) -> Pat { Pat::PathPat(node) } -} -impl From for Pat { - fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } -} -impl From for Pat { - fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } -} -impl From for Pat { - fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } -} -impl From for Pat { - fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } -} -impl From for Pat { - fn from(node: RangePat) -> Pat { Pat::RangePat(node) } -} -impl From for Pat { - fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } -} -impl From for Pat { - fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } -} -impl AstNode for Pat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT - | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT - | LITERAL_PAT | MACRO_PAT => true, - _ => false, - } - } - fn cast(syntax: SyntaxNode) -> Option { - let res = match syntax.kind() { - OR_PAT => Pat::OrPat(OrPat { syntax }), - PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), - REF_PAT => Pat::RefPat(RefPat { syntax }), - BOX_PAT => Pat::BoxPat(BoxPat { syntax }), - BIND_PAT => Pat::BindPat(BindPat { syntax }), - PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), - DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), - PATH_PAT => Pat::PathPat(PathPat { syntax }), - RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), - TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), - TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), - SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), - RANGE_PAT => Pat::RangePat(RangePat { syntax }), - LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), - MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), - _ => return None, - }; - Some(res) - } - fn syntax(&self) -> &SyntaxNode { - match self { - Pat::OrPat(it) => &it.syntax, - Pat::ParenPat(it) => &it.syntax, - Pat::RefPat(it) => &it.syntax, - Pat::BoxPat(it) => &it.syntax, - Pat::BindPat(it) => &it.syntax, - Pat::PlaceholderPat(it) => &it.syntax, - Pat::DotDotPat(it) => &it.syntax, - Pat::PathPat(it) => &it.syntax, - Pat::RecordPat(it) => &it.syntax, - Pat::TupleStructPat(it) => &it.syntax, - Pat::TuplePat(it) => &it.syntax, - Pat::SlicePat(it) => &it.syntax, - Pat::RangePat(it) => &it.syntax, - Pat::LiteralPat(it) => &it.syntax, - Pat::MacroPat(it) => &it.syntax, - } - } -} impl From for Stmt { fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } } @@ -3346,8 +3349,8 @@ impl AstNode for AttrInput { } } } -impl From for ExternItem { - fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) } +impl From for ExternItem { + fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) } } impl From for ExternItem { fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) } @@ -3355,13 +3358,13 @@ impl From for ExternItem { impl AstNode for ExternItem { fn can_cast(kind: SyntaxKind) -> bool { match kind { - FN_DEF | STATIC_DEF => true, + FN | STATIC_DEF => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { - FN_DEF => ExternItem::FnDef(FnDef { syntax }), + FN => ExternItem::Fn(Fn { syntax }), STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }), _ => return None, }; @@ -3369,7 +3372,7 @@ impl AstNode for ExternItem { } fn syntax(&self) -> &SyntaxNode { match self { - ExternItem::FnDef(it) => &it.syntax, + ExternItem::Fn(it) => &it.syntax, ExternItem::StaticDef(it) => &it.syntax, } } @@ -3417,22 +3420,22 @@ impl std::fmt::Display for TypeRef { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for FieldDefList { +impl std::fmt::Display for Pat { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Expr { +impl std::fmt::Display for FieldDefList { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for AssocItem { +impl std::fmt::Display for Expr { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Pat { +impl std::fmt::Display for AssocItem { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -3487,7 +3490,7 @@ impl std::fmt::Display for ExternCrate { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for FnDef { +impl std::fmt::Display for Fn { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -3607,6 +3610,16 @@ impl std::fmt::Display for BlockExpr { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for Param { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for SelfParam { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for RecordFieldDefList { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -4037,16 +4050,6 @@ impl std::fmt::Display for LetStmt { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for SelfParam { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} -impl std::fmt::Display for Param { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for PathSegment { 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/make.rs b/crates/ra_syntax/src/ast/make.rs index 0ff69bc2d..ef235680f 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs @@ -294,7 +294,7 @@ pub fn fn_def( type_params: Option, params: ast::ParamList, body: ast::BlockExpr, -) -> ast::FnDef { +) -> ast::Fn { let type_params = if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; let visibility = match visibility { diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 242900643..9fb6b7268 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs @@ -474,7 +474,7 @@ impl ast::TokenTree { } impl ast::DocCommentsOwner for ast::SourceFile {} -impl ast::DocCommentsOwner for ast::FnDef {} +impl ast::DocCommentsOwner for ast::Fn {} impl ast::DocCommentsOwner for ast::StructDef {} impl ast::DocCommentsOwner for ast::UnionDef {} impl ast::DocCommentsOwner for ast::RecordFieldDef {} diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 219dd0b07..6203b6206 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs @@ -255,11 +255,11 @@ fn api_walkthrough() { let mut func = None; for item in file.items() { match item { - ast::Item::FnDef(f) => func = Some(f), + ast::Item::Fn(f) => func = Some(f), _ => unreachable!(), } } - let func: ast::FnDef = func.unwrap(); + let func: ast::Fn = func.unwrap(); // Each AST node has a bunch of getters for children. All getters return // `Option`s though, to account for incomplete code. Some getters are common @@ -316,7 +316,7 @@ fn api_walkthrough() { ); // As well as some iterator helpers: - let f = expr_syntax.ancestors().find_map(ast::FnDef::cast); + let f = expr_syntax.ancestors().find_map(ast::Fn::cast); assert_eq!(f, Some(func)); assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}'])); assert_eq!( diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index c6b30a02a..2a0f95d15 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_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF + MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN | TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => { let mut res = 0; let mut trivias = trivias.enumerate().peekable(); diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index fdec48fb0..2714d102a 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs @@ -4,7 +4,7 @@ mod block; use crate::{ ast, match_ast, AstNode, SyntaxError, - SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN_DEF, INT_NUMBER, STRING, TYPE_ALIAS_DEF}, + SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN, INT_NUMBER, STRING, TYPE_ALIAS_DEF}, SyntaxNode, SyntaxToken, TextSize, T, }; use rustc_lexer::unescape::{ @@ -200,7 +200,7 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec) { None => return, }; match parent.kind() { - FN_DEF | CONST_DEF | TYPE_ALIAS_DEF => (), + FN | CONST_DEF | TYPE_ALIAS_DEF => (), _ => return, } diff --git a/crates/ra_syntax/src/validation/block.rs b/crates/ra_syntax/src/validation/block.rs index 2c08f7e6e..ad9901468 100644 --- a/crates/ra_syntax/src/validation/block.rs +++ b/crates/ra_syntax/src/validation/block.rs @@ -9,7 +9,7 @@ use crate::{ pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec) { if let Some(parent) = block.syntax().parent() { match parent.kind() { - FN_DEF | EXPR_STMT | BLOCK_EXPR => return, + FN | EXPR_STMT | BLOCK_EXPR => return, _ => {} } } -- cgit v1.2.3 From eb2f8063444b11257111f4f8ade990ec810e0361 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 15:25:46 +0200 Subject: Rename TypeAliasDef -> TypeAlias --- crates/ra_syntax/src/ast/edit.rs | 4 +- crates/ra_syntax/src/ast/generated/nodes.rs | 92 +++++++++++++------------- crates/ra_syntax/src/ast/node_ext.rs | 2 +- crates/ra_syntax/src/parsing/text_tree_sink.rs | 2 +- crates/ra_syntax/src/validation.rs | 4 +- 5 files changed, 51 insertions(+), 53 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 4a67fd44a..0110300af 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs @@ -192,9 +192,9 @@ impl ast::RecordFieldList { } } -impl ast::TypeAliasDef { +impl ast::TypeAlias { #[must_use] - pub fn remove_bounds(&self) -> ast::TypeAliasDef { + pub fn remove_bounds(&self) -> ast::TypeAlias { let colon = match self.colon_token() { Some(it) => it, None => return self.clone(), diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 4fc35585d..ad8ccf1ce 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -183,15 +183,15 @@ impl TraitDef { pub fn assoc_item_list(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TypeAliasDef { +pub struct TypeAlias { pub(crate) syntax: SyntaxNode, } -impl ast::AttrsOwner for TypeAliasDef {} -impl ast::NameOwner for TypeAliasDef {} -impl ast::VisibilityOwner for TypeAliasDef {} -impl ast::TypeParamsOwner for TypeAliasDef {} -impl ast::TypeBoundsOwner for TypeAliasDef {} -impl TypeAliasDef { +impl ast::AttrsOwner for TypeAlias {} +impl ast::NameOwner for TypeAlias {} +impl ast::VisibilityOwner for TypeAlias {} +impl ast::TypeParamsOwner for TypeAlias {} +impl ast::TypeBoundsOwner for TypeAlias {} +impl TypeAlias { pub fn default_token(&self) -> Option { support::token(&self.syntax, T![default]) } pub fn type_token(&self) -> Option { support::token(&self.syntax, T![type]) } pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } @@ -384,6 +384,13 @@ impl SelfParam { pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct TypeBoundList { + pub(crate) syntax: SyntaxNode, +} +impl TypeBoundList { + pub fn bounds(&self) -> AstChildren { support::children(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RecordFieldDefList { pub(crate) syntax: SyntaxNode, } @@ -444,13 +451,6 @@ impl EnumVariant { pub fn expr(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TypeBoundList { - pub(crate) syntax: SyntaxNode, -} -impl TypeBoundList { - pub fn bounds(&self) -> AstChildren { support::children(&self.syntax) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct AssocItemList { pub(crate) syntax: SyntaxNode, } @@ -1284,7 +1284,7 @@ pub enum Item { StaticDef(StaticDef), StructDef(StructDef), TraitDef(TraitDef), - TypeAliasDef(TypeAliasDef), + TypeAlias(TypeAlias), UnionDef(UnionDef), Use(Use), } @@ -1365,7 +1365,7 @@ pub enum Expr { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AssocItem { Fn(Fn), - TypeAliasDef(TypeAliasDef), + TypeAlias(TypeAlias), ConstDef(ConstDef), MacroCall(MacroCall), } @@ -1543,8 +1543,8 @@ impl AstNode for TraitDef { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for TypeAliasDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } +impl AstNode for TypeAlias { + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1752,6 +1752,17 @@ impl AstNode for SelfParam { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl AstNode for TypeBoundList { + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} impl AstNode for RecordFieldDefList { fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } fn cast(syntax: SyntaxNode) -> Option { @@ -1818,17 +1829,6 @@ impl AstNode for EnumVariant { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for TypeBoundList { - fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl AstNode for AssocItemList { fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_ITEM_LIST } fn cast(syntax: SyntaxNode) -> Option { @@ -2808,8 +2808,8 @@ impl From for Item { impl From for Item { fn from(node: TraitDef) -> Item { Item::TraitDef(node) } } -impl From for Item { - fn from(node: TypeAliasDef) -> Item { Item::TypeAliasDef(node) } +impl From for Item { + fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } } impl From for Item { fn from(node: UnionDef) -> Item { Item::UnionDef(node) } @@ -2821,9 +2821,7 @@ impl AstNode for Item { fn can_cast(kind: SyntaxKind) -> bool { match kind { CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL - | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => { - true - } + | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS | UNION_DEF | USE => true, _ => false, } } @@ -2840,7 +2838,7 @@ impl AstNode for Item { STATIC_DEF => Item::StaticDef(StaticDef { syntax }), STRUCT_DEF => Item::StructDef(StructDef { syntax }), TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), - TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), + TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), UNION_DEF => Item::UnionDef(UnionDef { syntax }), USE => Item::Use(Use { syntax }), _ => return None, @@ -2860,7 +2858,7 @@ impl AstNode for Item { Item::StaticDef(it) => &it.syntax, Item::StructDef(it) => &it.syntax, Item::TraitDef(it) => &it.syntax, - Item::TypeAliasDef(it) => &it.syntax, + Item::TypeAlias(it) => &it.syntax, Item::UnionDef(it) => &it.syntax, Item::Use(it) => &it.syntax, } @@ -3258,8 +3256,8 @@ impl AstNode for Expr { impl From for AssocItem { fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } } -impl From for AssocItem { - fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) } +impl From for AssocItem { + fn from(node: TypeAlias) -> AssocItem { AssocItem::TypeAlias(node) } } impl From for AssocItem { fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) } @@ -3270,14 +3268,14 @@ impl From for AssocItem { impl AstNode for AssocItem { fn can_cast(kind: SyntaxKind) -> bool { match kind { - FN | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true, + FN | TYPE_ALIAS | CONST_DEF | MACRO_CALL => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { FN => AssocItem::Fn(Fn { syntax }), - TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }), + TYPE_ALIAS => AssocItem::TypeAlias(TypeAlias { syntax }), CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }), MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), _ => return None, @@ -3287,7 +3285,7 @@ impl AstNode for AssocItem { fn syntax(&self) -> &SyntaxNode { match self { AssocItem::Fn(it) => &it.syntax, - AssocItem::TypeAliasDef(it) => &it.syntax, + AssocItem::TypeAlias(it) => &it.syntax, AssocItem::ConstDef(it) => &it.syntax, AssocItem::MacroCall(it) => &it.syntax, } @@ -3525,7 +3523,7 @@ impl std::fmt::Display for TraitDef { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for TypeAliasDef { +impl std::fmt::Display for TypeAlias { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -3620,6 +3618,11 @@ impl std::fmt::Display for SelfParam { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for TypeBoundList { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for RecordFieldDefList { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3650,11 +3653,6 @@ impl std::fmt::Display for EnumVariant { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for TypeBoundList { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for AssocItemList { 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 9fb6b7268..a7a301d6b 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs @@ -485,6 +485,6 @@ impl ast::DocCommentsOwner for ast::TraitDef {} impl ast::DocCommentsOwner for ast::Module {} impl ast::DocCommentsOwner for ast::StaticDef {} impl ast::DocCommentsOwner for ast::ConstDef {} -impl ast::DocCommentsOwner for ast::TypeAliasDef {} +impl ast::DocCommentsOwner for ast::TypeAlias {} impl ast::DocCommentsOwner for ast::ImplDef {} impl ast::DocCommentsOwner for ast::MacroCall {} diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index 2a0f95d15..87a7acd09 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_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN + MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN | TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => { let mut res = 0; let mut trivias = trivias.enumerate().peekable(); diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 2714d102a..6a2749381 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs @@ -4,7 +4,7 @@ mod block; use crate::{ ast, match_ast, AstNode, SyntaxError, - SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN, INT_NUMBER, STRING, TYPE_ALIAS_DEF}, + SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN, INT_NUMBER, STRING, TYPE_ALIAS}, SyntaxNode, SyntaxToken, TextSize, T, }; use rustc_lexer::unescape::{ @@ -200,7 +200,7 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec) { None => return, }; match parent.kind() { - FN | CONST_DEF | TYPE_ALIAS_DEF => (), + FN | CONST_DEF | TYPE_ALIAS => (), _ => return, } -- cgit v1.2.3