aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/type_ref.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-31 11:06:38 +0100
committerAleksey Kladov <[email protected]>2020-07-31 11:14:37 +0100
commit08ea2271e8050165d0aaf4c994ed3dd746aff3ba (patch)
tree1d5bb4ce799c6377b49ae73436d50a087db53392 /crates/ra_hir_def/src/type_ref.rs
parente0f21133cd03c6160fbc97b70bbd50ccde4fe6d9 (diff)
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.
Diffstat (limited to 'crates/ra_hir_def/src/type_ref.rs')
-rw-r--r--crates/ra_hir_def/src/type_ref.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/ra_hir_def/src/type_ref.rs
index a5dc10eac..9386b91cb 100644
--- a/crates/ra_hir_def/src/type_ref.rs
+++ b/crates/ra_hir_def/src/type_ref.rs
@@ -80,14 +80,14 @@ pub enum TypeBound {
80 80
81impl TypeRef { 81impl TypeRef {
82 /// Converts an `ast::TypeRef` to a `hir::TypeRef`. 82 /// Converts an `ast::TypeRef` to a `hir::TypeRef`.
83 pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::TypeRef) -> Self { 83 pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Self {
84 match node { 84 match node {
85 ast::TypeRef::ParenType(inner) => TypeRef::from_ast_opt(&ctx, inner.ty()), 85 ast::Type::ParenType(inner) => TypeRef::from_ast_opt(&ctx, inner.ty()),
86 ast::TypeRef::TupleType(inner) => { 86 ast::Type::TupleType(inner) => {
87 TypeRef::Tuple(inner.fields().map(|it| TypeRef::from_ast(ctx, it)).collect()) 87 TypeRef::Tuple(inner.fields().map(|it| TypeRef::from_ast(ctx, it)).collect())
88 } 88 }
89 ast::TypeRef::NeverType(..) => TypeRef::Never, 89 ast::Type::NeverType(..) => TypeRef::Never,
90 ast::TypeRef::PathType(inner) => { 90 ast::Type::PathType(inner) => {
91 // FIXME: Use `Path::from_src` 91 // FIXME: Use `Path::from_src`
92 inner 92 inner
93 .path() 93 .path()
@@ -95,24 +95,24 @@ impl TypeRef {
95 .map(TypeRef::Path) 95 .map(TypeRef::Path)
96 .unwrap_or(TypeRef::Error) 96 .unwrap_or(TypeRef::Error)
97 } 97 }
98 ast::TypeRef::PointerType(inner) => { 98 ast::Type::PointerType(inner) => {
99 let inner_ty = TypeRef::from_ast_opt(&ctx, inner.ty()); 99 let inner_ty = TypeRef::from_ast_opt(&ctx, inner.ty());
100 let mutability = Mutability::from_mutable(inner.mut_token().is_some()); 100 let mutability = Mutability::from_mutable(inner.mut_token().is_some());
101 TypeRef::RawPtr(Box::new(inner_ty), mutability) 101 TypeRef::RawPtr(Box::new(inner_ty), mutability)
102 } 102 }
103 ast::TypeRef::ArrayType(inner) => { 103 ast::Type::ArrayType(inner) => {
104 TypeRef::Array(Box::new(TypeRef::from_ast_opt(&ctx, inner.ty()))) 104 TypeRef::Array(Box::new(TypeRef::from_ast_opt(&ctx, inner.ty())))
105 } 105 }
106 ast::TypeRef::SliceType(inner) => { 106 ast::Type::SliceType(inner) => {
107 TypeRef::Slice(Box::new(TypeRef::from_ast_opt(&ctx, inner.ty()))) 107 TypeRef::Slice(Box::new(TypeRef::from_ast_opt(&ctx, inner.ty())))
108 } 108 }
109 ast::TypeRef::ReferenceType(inner) => { 109 ast::Type::ReferenceType(inner) => {
110 let inner_ty = TypeRef::from_ast_opt(&ctx, inner.ty()); 110 let inner_ty = TypeRef::from_ast_opt(&ctx, inner.ty());
111 let mutability = Mutability::from_mutable(inner.mut_token().is_some()); 111 let mutability = Mutability::from_mutable(inner.mut_token().is_some());
112 TypeRef::Reference(Box::new(inner_ty), mutability) 112 TypeRef::Reference(Box::new(inner_ty), mutability)
113 } 113 }
114 ast::TypeRef::PlaceholderType(_inner) => TypeRef::Placeholder, 114 ast::Type::PlaceholderType(_inner) => TypeRef::Placeholder,
115 ast::TypeRef::FnPointerType(inner) => { 115 ast::Type::FnPointerType(inner) => {
116 let ret_ty = inner 116 let ret_ty = inner
117 .ret_type() 117 .ret_type()
118 .and_then(|rt| rt.ty()) 118 .and_then(|rt| rt.ty())
@@ -132,17 +132,17 @@ impl TypeRef {
132 TypeRef::Fn(params, is_varargs) 132 TypeRef::Fn(params, is_varargs)
133 } 133 }
134 // for types are close enough for our purposes to the inner type for now... 134 // for types are close enough for our purposes to the inner type for now...
135 ast::TypeRef::ForType(inner) => TypeRef::from_ast_opt(&ctx, inner.ty()), 135 ast::Type::ForType(inner) => TypeRef::from_ast_opt(&ctx, inner.ty()),
136 ast::TypeRef::ImplTraitType(inner) => { 136 ast::Type::ImplTraitType(inner) => {
137 TypeRef::ImplTrait(type_bounds_from_ast(ctx, inner.type_bound_list())) 137 TypeRef::ImplTrait(type_bounds_from_ast(ctx, inner.type_bound_list()))
138 } 138 }
139 ast::TypeRef::DynTraitType(inner) => { 139 ast::Type::DynTraitType(inner) => {
140 TypeRef::DynTrait(type_bounds_from_ast(ctx, inner.type_bound_list())) 140 TypeRef::DynTrait(type_bounds_from_ast(ctx, inner.type_bound_list()))
141 } 141 }
142 } 142 }
143 } 143 }
144 144
145 pub(crate) fn from_ast_opt(ctx: &LowerCtx, node: Option<ast::TypeRef>) -> Self { 145 pub(crate) fn from_ast_opt(ctx: &LowerCtx, node: Option<ast::Type>) -> Self {
146 if let Some(node) = node { 146 if let Some(node) = node {
147 TypeRef::from_ast(ctx, node) 147 TypeRef::from_ast(ctx, node)
148 } else { 148 } else {