From 08ea2271e8050165d0aaf4c994ed3dd746aff3ba Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 12:06:38 +0200 Subject: Rename TypeRef -> Type The TypeRef name comes from IntelliJ days, where you often have both type *syntax* as well as *semantical* representation of types in scope. And naming both Type is confusing. In rust-analyzer however, we use ast types as `ast::Type`, and have many more semantic counterparts to ast types, so avoiding name clash here is just confusing. --- crates/ra_syntax/src/ast/generated/nodes.rs | 254 ++++++++++++++-------------- crates/ra_syntax/src/ast/make.rs | 4 +- crates/ra_syntax/src/ast/node_ext.rs | 12 +- 3 files changed, 135 insertions(+), 135 deletions(-) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 4306efe13..9cfd5d017 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -40,7 +40,7 @@ impl Const { pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } pub fn underscore_token(&self) -> Option { support::token(&self.syntax, T![_]) } pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } pub fn body(&self) -> Option { support::child(&self.syntax) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } @@ -112,7 +112,7 @@ impl Impl { pub fn unsafe_token(&self) -> Option { support::token(&self.syntax, T![unsafe]) } pub fn impl_token(&self) -> Option { support::token(&self.syntax, T![impl]) } pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } - pub fn type_ref(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } pub fn excl_token(&self) -> Option { support::token(&self.syntax, T![!]) } pub fn for_token(&self) -> Option { support::token(&self.syntax, T![for]) } pub fn assoc_item_list(&self) -> Option { support::child(&self.syntax) } @@ -152,7 +152,7 @@ impl Static { pub fn static_token(&self) -> Option { support::token(&self.syntax, T![static]) } pub fn mut_token(&self) -> Option { support::token(&self.syntax, T![mut]) } pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } pub fn body(&self) -> Option { support::child(&self.syntax) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } @@ -198,7 +198,7 @@ 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![=]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -333,7 +333,7 @@ pub struct RetType { } impl RetType { pub fn thin_arrow_token(&self) -> Option { support::token(&self.syntax, T![->]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct WhereClause { @@ -369,7 +369,7 @@ impl SelfParam { 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![:]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Param { @@ -379,7 +379,7 @@ impl ast::AttrsOwner 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 ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } pub fn dotdotdot_token(&self) -> Option { support::token(&self.syntax, T![...]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -416,7 +416,7 @@ impl ast::NameOwner for RecordField {} impl ast::VisibilityOwner for RecordField {} impl RecordField { pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TupleField { @@ -425,7 +425,7 @@ pub struct TupleField { impl ast::AttrsOwner for TupleField {} impl ast::VisibilityOwner for TupleField {} impl TupleField { - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct VariantList { @@ -487,7 +487,7 @@ impl ast::NameOwner for TypeParam {} impl ast::TypeBoundsOwner for TypeParam {} impl TypeParam { pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } - pub fn default_type(&self) -> Option { support::child(&self.syntax) } + pub fn default_type(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ConstParam { @@ -498,7 +498,7 @@ impl ast::NameOwner for ConstParam {} impl ConstParam { pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } pub fn default_val(&self) -> Option { support::child(&self.syntax) } } @@ -525,7 +525,7 @@ pub struct ParenType { } impl ParenType { pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } pub fn r_paren_token(&self) -> Option { support::token(&self.syntax, T![')']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -534,7 +534,7 @@ pub struct TupleType { } impl TupleType { pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } - pub fn fields(&self) -> AstChildren { support::children(&self.syntax) } + pub fn fields(&self) -> AstChildren { support::children(&self.syntax) } pub fn r_paren_token(&self) -> Option { support::token(&self.syntax, T![')']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -559,7 +559,7 @@ impl PointerType { pub fn star_token(&self) -> Option { support::token(&self.syntax, T![*]) } pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } pub fn mut_token(&self) -> Option { support::token(&self.syntax, T![mut]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ArrayType { @@ -567,7 +567,7 @@ pub struct ArrayType { } impl ArrayType { pub fn l_brack_token(&self) -> Option { support::token(&self.syntax, T!['[']) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } pub fn expr(&self) -> Option { support::child(&self.syntax) } pub fn r_brack_token(&self) -> Option { support::token(&self.syntax, T![']']) } @@ -578,7 +578,7 @@ pub struct SliceType { } impl SliceType { pub fn l_brack_token(&self) -> Option { support::token(&self.syntax, T!['[']) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } pub fn r_brack_token(&self) -> Option { support::token(&self.syntax, T![']']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -591,7 +591,7 @@ impl ReferenceType { support::token(&self.syntax, T![lifetime]) } pub fn mut_token(&self) -> Option { support::token(&self.syntax, T![mut]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct PlaceholderType { @@ -618,7 +618,7 @@ pub struct ForType { impl ForType { pub fn for_token(&self) -> Option { support::token(&self.syntax, T![for]) } pub fn generic_param_list(&self) -> Option { support::child(&self.syntax) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ImplTraitType { @@ -882,7 +882,7 @@ impl ast::AttrsOwner for CastExpr {} impl CastExpr { pub fn expr(&self) -> Option { support::child(&self.syntax) } pub fn as_token(&self) -> Option { support::token(&self.syntax, T![as]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RefExpr { @@ -1174,7 +1174,7 @@ impl TypeBound { support::token(&self.syntax, T![lifetime]) } pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } - pub fn type_ref(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct WherePred { @@ -1187,7 +1187,7 @@ impl WherePred { pub fn lifetime_token(&self) -> Option { support::token(&self.syntax, T![lifetime]) } - pub fn type_ref(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ExprStmt { @@ -1207,7 +1207,7 @@ impl LetStmt { pub fn let_token(&self) -> Option { support::token(&self.syntax, T![let]) } pub fn pat(&self) -> Option { support::child(&self.syntax) } pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } pub fn initializer(&self) -> Option { support::child(&self.syntax) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } @@ -1234,7 +1234,7 @@ pub struct TypeArg { pub(crate) syntax: SyntaxNode, } impl TypeArg { - pub fn type_ref(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct LifetimeArg { @@ -1253,7 +1253,7 @@ impl ast::TypeBoundsOwner for AssocTypeArg {} impl AssocTypeArg { pub fn name_ref(&self) -> Option { support::child(&self.syntax) } pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } - pub fn type_ref(&self) -> Option { support::child(&self.syntax) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ConstArg { @@ -1282,7 +1282,7 @@ pub enum Item { } impl ast::AttrsOwner for Item {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub enum TypeRef { +pub enum Type { ParenType(ParenType), TupleType(TupleType), NeverType(NeverType), @@ -1355,6 +1355,16 @@ pub enum Expr { BoxExpr(BoxExpr), } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum AdtDef { + Struct(Struct), + Enum(Enum), + Union(Union), +} +impl ast::AttrsOwner for AdtDef {} +impl ast::GenericParamsOwner for AdtDef {} +impl ast::NameOwner for AdtDef {} +impl ast::VisibilityOwner for AdtDef {} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AssocItem { Fn(Fn), TypeAlias(TypeAlias), @@ -1384,16 +1394,6 @@ pub enum Stmt { ExprStmt(ExprStmt), } impl ast::AttrsOwner for Stmt {} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub enum AdtDef { - Struct(Struct), - Enum(Enum), - Union(Union), -} -impl ast::AttrsOwner for AdtDef {} -impl ast::GenericParamsOwner for AdtDef {} -impl ast::NameOwner for AdtDef {} -impl ast::VisibilityOwner for AdtDef {} impl AstNode for SourceFile { fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } fn cast(syntax: SyntaxNode) -> Option { @@ -2847,46 +2847,46 @@ impl AstNode for Item { } } } -impl From for TypeRef { - fn from(node: ParenType) -> TypeRef { TypeRef::ParenType(node) } +impl From for Type { + fn from(node: ParenType) -> Type { Type::ParenType(node) } } -impl From for TypeRef { - fn from(node: TupleType) -> TypeRef { TypeRef::TupleType(node) } +impl From for Type { + fn from(node: TupleType) -> Type { Type::TupleType(node) } } -impl From for TypeRef { - fn from(node: NeverType) -> TypeRef { TypeRef::NeverType(node) } +impl From for Type { + fn from(node: NeverType) -> Type { Type::NeverType(node) } } -impl From for TypeRef { - fn from(node: PathType) -> TypeRef { TypeRef::PathType(node) } +impl From for Type { + fn from(node: PathType) -> Type { Type::PathType(node) } } -impl From for TypeRef { - fn from(node: PointerType) -> TypeRef { TypeRef::PointerType(node) } +impl From for Type { + fn from(node: PointerType) -> Type { Type::PointerType(node) } } -impl From for TypeRef { - fn from(node: ArrayType) -> TypeRef { TypeRef::ArrayType(node) } +impl From for Type { + fn from(node: ArrayType) -> Type { Type::ArrayType(node) } } -impl From for TypeRef { - fn from(node: SliceType) -> TypeRef { TypeRef::SliceType(node) } +impl From for Type { + fn from(node: SliceType) -> Type { Type::SliceType(node) } } -impl From for TypeRef { - fn from(node: ReferenceType) -> TypeRef { TypeRef::ReferenceType(node) } +impl From for Type { + fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) } } -impl From for TypeRef { - fn from(node: PlaceholderType) -> TypeRef { TypeRef::PlaceholderType(node) } +impl From for Type { + fn from(node: PlaceholderType) -> Type { Type::PlaceholderType(node) } } -impl From for TypeRef { - fn from(node: FnPointerType) -> TypeRef { TypeRef::FnPointerType(node) } +impl From for Type { + fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) } } -impl From for TypeRef { - fn from(node: ForType) -> TypeRef { TypeRef::ForType(node) } +impl From for Type { + fn from(node: ForType) -> Type { Type::ForType(node) } } -impl From for TypeRef { - fn from(node: ImplTraitType) -> TypeRef { TypeRef::ImplTraitType(node) } +impl From for Type { + fn from(node: ImplTraitType) -> Type { Type::ImplTraitType(node) } } -impl From for TypeRef { - fn from(node: DynTraitType) -> TypeRef { TypeRef::DynTraitType(node) } +impl From for Type { + fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) } } -impl AstNode for TypeRef { +impl AstNode for Type { fn can_cast(kind: SyntaxKind) -> bool { match kind { PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE @@ -2897,38 +2897,38 @@ impl AstNode for TypeRef { } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { - PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }), - TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }), - NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }), - PATH_TYPE => TypeRef::PathType(PathType { syntax }), - POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }), - ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }), - SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }), - REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }), - PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }), - FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }), - FOR_TYPE => TypeRef::ForType(ForType { syntax }), - IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }), - DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }), + PAREN_TYPE => Type::ParenType(ParenType { syntax }), + TUPLE_TYPE => Type::TupleType(TupleType { syntax }), + NEVER_TYPE => Type::NeverType(NeverType { syntax }), + PATH_TYPE => Type::PathType(PathType { syntax }), + POINTER_TYPE => Type::PointerType(PointerType { syntax }), + ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }), + SLICE_TYPE => Type::SliceType(SliceType { syntax }), + REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }), + PLACEHOLDER_TYPE => Type::PlaceholderType(PlaceholderType { syntax }), + FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }), + FOR_TYPE => Type::ForType(ForType { syntax }), + IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }), + DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }), _ => return None, }; Some(res) } fn syntax(&self) -> &SyntaxNode { match self { - TypeRef::ParenType(it) => &it.syntax, - TypeRef::TupleType(it) => &it.syntax, - TypeRef::NeverType(it) => &it.syntax, - TypeRef::PathType(it) => &it.syntax, - TypeRef::PointerType(it) => &it.syntax, - TypeRef::ArrayType(it) => &it.syntax, - TypeRef::SliceType(it) => &it.syntax, - TypeRef::ReferenceType(it) => &it.syntax, - TypeRef::PlaceholderType(it) => &it.syntax, - TypeRef::FnPointerType(it) => &it.syntax, - TypeRef::ForType(it) => &it.syntax, - TypeRef::ImplTraitType(it) => &it.syntax, - TypeRef::DynTraitType(it) => &it.syntax, + Type::ParenType(it) => &it.syntax, + Type::TupleType(it) => &it.syntax, + Type::NeverType(it) => &it.syntax, + Type::PathType(it) => &it.syntax, + Type::PointerType(it) => &it.syntax, + Type::ArrayType(it) => &it.syntax, + Type::SliceType(it) => &it.syntax, + Type::ReferenceType(it) => &it.syntax, + Type::PlaceholderType(it) => &it.syntax, + Type::FnPointerType(it) => &it.syntax, + Type::ForType(it) => &it.syntax, + Type::ImplTraitType(it) => &it.syntax, + Type::DynTraitType(it) => &it.syntax, } } } @@ -3234,6 +3234,39 @@ impl AstNode for Expr { } } } +impl From for AdtDef { + fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } +} +impl From for AdtDef { + fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } +} +impl From for AdtDef { + fn from(node: Union) -> AdtDef { AdtDef::Union(node) } +} +impl AstNode for AdtDef { + fn can_cast(kind: SyntaxKind) -> bool { + match kind { + STRUCT | ENUM | UNION => true, + _ => false, + } + } + fn cast(syntax: SyntaxNode) -> Option { + let res = match syntax.kind() { + STRUCT => AdtDef::Struct(Struct { syntax }), + ENUM => AdtDef::Enum(Enum { syntax }), + UNION => AdtDef::Union(Union { syntax }), + _ => return None, + }; + Some(res) + } + fn syntax(&self) -> &SyntaxNode { + match self { + AdtDef::Struct(it) => &it.syntax, + AdtDef::Enum(it) => &it.syntax, + AdtDef::Union(it) => &it.syntax, + } + } +} impl From for AssocItem { fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } } @@ -3366,45 +3399,12 @@ impl AstNode for Stmt { } } } -impl From for AdtDef { - fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } -} -impl From for AdtDef { - fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } -} -impl From for AdtDef { - fn from(node: Union) -> AdtDef { AdtDef::Union(node) } -} -impl AstNode for AdtDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - STRUCT | ENUM | UNION => true, - _ => false, - } - } - fn cast(syntax: SyntaxNode) -> Option { - let res = match syntax.kind() { - STRUCT => AdtDef::Struct(Struct { syntax }), - ENUM => AdtDef::Enum(Enum { syntax }), - UNION => AdtDef::Union(Union { syntax }), - _ => return None, - }; - Some(res) - } - fn syntax(&self) -> &SyntaxNode { - match self { - AdtDef::Struct(it) => &it.syntax, - AdtDef::Enum(it) => &it.syntax, - AdtDef::Union(it) => &it.syntax, - } - } -} impl std::fmt::Display for Item { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for TypeRef { +impl std::fmt::Display for Type { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -3424,27 +3424,27 @@ impl std::fmt::Display for Expr { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for AssocItem { +impl std::fmt::Display for AdtDef { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for ExternItem { +impl std::fmt::Display for AssocItem { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for GenericParam { +impl std::fmt::Display for ExternItem { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Stmt { +impl std::fmt::Display for GenericParam { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for AdtDef { +impl std::fmt::Display for Stmt { 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 509e8ae7a..3d4fed64c 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs @@ -17,7 +17,7 @@ pub fn name_ref(text: &str) -> ast::NameRef { ast_from_text(&format!("fn f() {{ {}; }}", text)) } -pub fn type_ref(text: &str) -> ast::TypeRef { +pub fn type_ref(text: &str) -> ast::Type { ast_from_text(&format!("impl {} for D {{}};", text)) } @@ -75,7 +75,7 @@ pub fn record_field(name: ast::NameRef, expr: Option) -> ast::RecordE } } -pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordField { +pub fn record_field_def(name: ast::NameRef, ty: ast::Type) -> ast::RecordField { ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) } diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index bba7310ad..30c2db56b 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs @@ -82,7 +82,7 @@ impl ast::Attr { #[derive(Debug, Clone, PartialEq, Eq)] pub enum PathSegmentKind { Name(ast::NameRef), - Type { type_ref: Option, trait_ref: Option }, + Type { type_ref: Option, trait_ref: Option }, SelfKw, SuperKw, CrateKw, @@ -108,8 +108,8 @@ impl ast::PathSegment { // or // T is any TypeRef, Trait has to be a PathType let mut type_refs = - self.syntax().children().filter(|node| ast::TypeRef::can_cast(node.kind())); - let type_ref = type_refs.next().and_then(ast::TypeRef::cast); + self.syntax().children().filter(|node| ast::Type::can_cast(node.kind())); + let type_ref = type_refs.next().and_then(ast::Type::cast); let trait_ref = type_refs.next().and_then(ast::PathType::cast); PathSegmentKind::Type { type_ref, trait_ref } } @@ -136,21 +136,21 @@ impl ast::UseTreeList { } impl ast::Impl { - pub fn target_type(&self) -> Option { + pub fn target_type(&self) -> Option { match self.target() { (Some(t), None) | (_, Some(t)) => Some(t), _ => None, } } - pub fn target_trait(&self) -> Option { + pub fn target_trait(&self) -> Option { match self.target() { (Some(t), Some(_)) => Some(t), _ => None, } } - fn target(&self) -> (Option, Option) { + fn target(&self) -> (Option, Option) { let mut types = support::children(self.syntax()); let first = types.next(); let second = types.next(); -- cgit v1.2.3