aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-31 11:18:53 +0100
committerGitHub <[email protected]>2020-07-31 11:18:53 +0100
commit683d0a4d93c29c988c40c001a4b574d8f0dcb9c6 (patch)
tree1d5bb4ce799c6377b49ae73436d50a087db53392 /crates
parent6b7cb8b5ab539fc4333ce34bc29bf77c976f232a (diff)
parent08ea2271e8050165d0aaf4c994ed3dd746aff3ba (diff)
Merge #5618
5618: Rename TypeRef -> Type r=matklad a=matklad 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. bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/ast_transform.rs12
-rw-r--r--crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs2
-rw-r--r--crates/ra_assists/src/handlers/introduce_named_lifetime.rs2
-rw-r--r--crates/ra_hir_def/src/generics.rs2
-rw-r--r--crates/ra_hir_def/src/item_tree/lower.rs4
-rw-r--r--crates/ra_hir_def/src/path/lower.rs4
-rw-r--r--crates/ra_hir_def/src/type_ref.rs30
-rw-r--r--crates/ra_ide/src/display/short_label.rs2
-rw-r--r--crates/ra_ide/src/file_structure.rs2
-rw-r--r--crates/ra_ide/src/references/rename.rs4
-rw-r--r--crates/ra_ssr/src/parsing.rs2
-rw-r--r--crates/ra_syntax/src/ast.rs10
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs254
-rw-r--r--crates/ra_syntax/src/ast/make.rs4
-rw-r--r--crates/ra_syntax/src/ast/node_ext.rs12
-rw-r--r--crates/ra_syntax/src/lib.rs2
-rw-r--r--crates/ra_syntax/src/tests.rs2
17 files changed, 175 insertions, 175 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs
index 5ea4f9f5b..3265bd406 100644
--- a/crates/ra_assists/src/ast_transform.rs
+++ b/crates/ra_assists/src/ast_transform.rs
@@ -32,7 +32,7 @@ impl<'a> AstTransform<'a> for NullTransformer {
32 32
33pub struct SubstituteTypeParams<'a> { 33pub struct SubstituteTypeParams<'a> {
34 source_scope: &'a SemanticsScope<'a>, 34 source_scope: &'a SemanticsScope<'a>,
35 substs: FxHashMap<hir::TypeParam, ast::TypeRef>, 35 substs: FxHashMap<hir::TypeParam, ast::Type>,
36 previous: Box<dyn AstTransform<'a> + 'a>, 36 previous: Box<dyn AstTransform<'a> + 'a>,
37} 37}
38 38
@@ -80,17 +80,17 @@ impl<'a> SubstituteTypeParams<'a> {
80 80
81 // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the 81 // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the
82 // trait ref, and then go from the types in the substs back to the syntax) 82 // trait ref, and then go from the types in the substs back to the syntax)
83 fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::TypeRef>> { 83 fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> {
84 let target_trait = impl_def.target_trait()?; 84 let target_trait = impl_def.target_trait()?;
85 let path_type = match target_trait { 85 let path_type = match target_trait {
86 ast::TypeRef::PathType(path) => path, 86 ast::Type::PathType(path) => path,
87 _ => return None, 87 _ => return None,
88 }; 88 };
89 let type_arg_list = path_type.path()?.segment()?.type_arg_list()?; 89 let type_arg_list = path_type.path()?.segment()?.type_arg_list()?;
90 let mut result = Vec::new(); 90 let mut result = Vec::new();
91 for type_arg in type_arg_list.type_args() { 91 for type_arg in type_arg_list.type_args() {
92 let type_arg: ast::TypeArg = type_arg; 92 let type_arg: ast::TypeArg = type_arg;
93 result.push(type_arg.type_ref()?); 93 result.push(type_arg.ty()?);
94 } 94 }
95 Some(result) 95 Some(result)
96 } 96 }
@@ -99,9 +99,9 @@ impl<'a> SubstituteTypeParams<'a> {
99 &self, 99 &self,
100 node: &ra_syntax::SyntaxNode, 100 node: &ra_syntax::SyntaxNode,
101 ) -> Option<ra_syntax::SyntaxNode> { 101 ) -> Option<ra_syntax::SyntaxNode> {
102 let type_ref = ast::TypeRef::cast(node.clone())?; 102 let type_ref = ast::Type::cast(node.clone())?;
103 let path = match &type_ref { 103 let path = match &type_ref {
104 ast::TypeRef::PathType(path_type) => path_type.path()?, 104 ast::Type::PathType(path_type) => path_type.path()?,
105 _ => return None, 105 _ => return None,
106 }; 106 };
107 // FIXME: use `hir::Path::from_src` instead. 107 // FIXME: use `hir::Path::from_src` instead.
diff --git a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
index 9da23640a..4c1aef8a2 100644
--- a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
+++ b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
@@ -34,7 +34,7 @@ pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext
34 } 34 }
35 let field_type = field_list.fields().next()?.ty()?; 35 let field_type = field_list.fields().next()?.ty()?;
36 let path = match field_type { 36 let path = match field_type {
37 ast::TypeRef::PathType(it) => it, 37 ast::Type::PathType(it) => it,
38 _ => return None, 38 _ => return None,
39 }; 39 };
40 40
diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs
index c3134f64d..4537c73a1 100644
--- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs
+++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs
@@ -68,7 +68,7 @@ fn generate_fn_def_assist(
68 let fn_params_without_lifetime: Vec<_> = param_list 68 let fn_params_without_lifetime: Vec<_> = param_list
69 .params() 69 .params()
70 .filter_map(|param| match param.ty() { 70 .filter_map(|param| match param.ty() {
71 Some(ast::TypeRef::ReferenceType(ascribed_type)) 71 Some(ast::Type::ReferenceType(ascribed_type))
72 if ascribed_type.lifetime_token() == None => 72 if ascribed_type.lifetime_token() == None =>
73 { 73 {
74 Some(ascribed_type.amp_token()?.text_range().end()) 74 Some(ascribed_type.amp_token()?.text_range().end())
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs
index 8ea61fcf2..be0b45af3 100644
--- a/crates/ra_hir_def/src/generics.rs
+++ b/crates/ra_hir_def/src/generics.rs
@@ -253,7 +253,7 @@ impl GenericParams {
253 253
254 fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx, where_clause: ast::WhereClause) { 254 fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx, where_clause: ast::WhereClause) {
255 for pred in where_clause.predicates() { 255 for pred in where_clause.predicates() {
256 let type_ref = match pred.type_ref() { 256 let type_ref = match pred.ty() {
257 Some(type_ref) => type_ref, 257 Some(type_ref) => type_ref,
258 None => continue, 258 None => continue,
259 }; 259 };
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs
index feb31579e..b5d416acb 100644
--- a/crates/ra_hir_def/src/item_tree/lower.rs
+++ b/crates/ra_hir_def/src/item_tree/lower.rs
@@ -648,10 +648,10 @@ impl Ctx {
648 self.data().vis.alloc(vis) 648 self.data().vis.alloc(vis)
649 } 649 }
650 650
651 fn lower_type_ref(&self, type_ref: &ast::TypeRef) -> TypeRef { 651 fn lower_type_ref(&self, type_ref: &ast::Type) -> TypeRef {
652 TypeRef::from_ast(&self.body_ctx, type_ref.clone()) 652 TypeRef::from_ast(&self.body_ctx, type_ref.clone())
653 } 653 }
654 fn lower_type_ref_opt(&self, type_ref: Option<ast::TypeRef>) -> TypeRef { 654 fn lower_type_ref_opt(&self, type_ref: Option<ast::Type>) -> TypeRef {
655 type_ref.map(|ty| self.lower_type_ref(&ty)).unwrap_or(TypeRef::Error) 655 type_ref.map(|ty| self.lower_type_ref(&ty)).unwrap_or(TypeRef::Error)
656 } 656 }
657 657
diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs
index 07d17916a..257f9a033 100644
--- a/crates/ra_hir_def/src/path/lower.rs
+++ b/crates/ra_hir_def/src/path/lower.rs
@@ -152,7 +152,7 @@ pub(super) fn lower_generic_args(
152) -> Option<GenericArgs> { 152) -> Option<GenericArgs> {
153 let mut args = Vec::new(); 153 let mut args = Vec::new();
154 for type_arg in node.type_args() { 154 for type_arg in node.type_args() {
155 let type_ref = TypeRef::from_ast_opt(lower_ctx, type_arg.type_ref()); 155 let type_ref = TypeRef::from_ast_opt(lower_ctx, type_arg.ty());
156 args.push(GenericArg::Type(type_ref)); 156 args.push(GenericArg::Type(type_ref));
157 } 157 }
158 // lifetimes ignored for now 158 // lifetimes ignored for now
@@ -161,7 +161,7 @@ pub(super) fn lower_generic_args(
161 let assoc_type_arg: ast::AssocTypeArg = assoc_type_arg; 161 let assoc_type_arg: ast::AssocTypeArg = assoc_type_arg;
162 if let Some(name_ref) = assoc_type_arg.name_ref() { 162 if let Some(name_ref) = assoc_type_arg.name_ref() {
163 let name = name_ref.as_name(); 163 let name = name_ref.as_name();
164 let type_ref = assoc_type_arg.type_ref().map(|it| TypeRef::from_ast(lower_ctx, it)); 164 let type_ref = assoc_type_arg.ty().map(|it| TypeRef::from_ast(lower_ctx, it));
165 let bounds = if let Some(l) = assoc_type_arg.type_bound_list() { 165 let bounds = if let Some(l) = assoc_type_arg.type_bound_list() {
166 l.bounds().map(|it| TypeBound::from_ast(lower_ctx, it)).collect() 166 l.bounds().map(|it| TypeBound::from_ast(lower_ctx, it)).collect()
167 } else { 167 } else {
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 {
diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs
index bddf1bd47..0fdf8e9a5 100644
--- a/crates/ra_ide/src/display/short_label.rs
+++ b/crates/ra_ide/src/display/short_label.rs
@@ -77,7 +77,7 @@ impl ShortLabel for ast::Variant {
77 } 77 }
78} 78}
79 79
80fn short_label_from_ty<T>(node: &T, ty: Option<ast::TypeRef>, prefix: &str) -> Option<String> 80fn short_label_from_ty<T>(node: &T, ty: Option<ast::Type>, prefix: &str) -> Option<String>
81where 81where
82 T: NameOwner + VisibilityOwner, 82 T: NameOwner + VisibilityOwner,
83{ 83{
diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs
index 91765140a..ef368651a 100644
--- a/crates/ra_ide/src/file_structure.rs
+++ b/crates/ra_ide/src/file_structure.rs
@@ -57,7 +57,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
57 57
58 fn decl_with_type_ref<N: NameOwner + AttrsOwner>( 58 fn decl_with_type_ref<N: NameOwner + AttrsOwner>(
59 node: &N, 59 node: &N,
60 type_ref: Option<ast::TypeRef>, 60 type_ref: Option<ast::Type>,
61 ) -> Option<StructureNode> { 61 ) -> Option<StructureNode> {
62 let detail = type_ref.map(|type_ref| { 62 let detail = type_ref.map(|type_ref| {
63 let mut detail = String::new(); 63 let mut detail = String::new();
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index 31654bf79..96aed7cc7 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -157,7 +157,7 @@ fn rename_to_self(
157 } 157 }
158 let first_param = params.params().next()?; 158 let first_param = params.params().next()?;
159 let mutable = match first_param.ty() { 159 let mutable = match first_param.ty() {
160 Some(ast::TypeRef::ReferenceType(rt)) => rt.mut_token().is_some(), 160 Some(ast::Type::ReferenceType(rt)) => rt.mut_token().is_some(),
161 _ => return None, // not renaming other types 161 _ => return None, // not renaming other types
162 }; 162 };
163 163
@@ -194,7 +194,7 @@ fn text_edit_from_self_param(
194 new_name: &str, 194 new_name: &str,
195) -> Option<TextEdit> { 195) -> Option<TextEdit> {
196 fn target_type_name(impl_def: &ast::Impl) -> Option<String> { 196 fn target_type_name(impl_def: &ast::Impl) -> Option<String> {
197 if let Some(ast::TypeRef::PathType(p)) = impl_def.target_type() { 197 if let Some(ast::Type::PathType(p)) = impl_def.target_type() {
198 return Some(p.path()?.segment()?.name_ref()?.text().to_string()); 198 return Some(p.path()?.segment()?.name_ref()?.text().to_string());
199 } 199 }
200 None 200 None
diff --git a/crates/ra_ssr/src/parsing.rs b/crates/ra_ssr/src/parsing.rs
index 78e03f394..4e046910c 100644
--- a/crates/ra_ssr/src/parsing.rs
+++ b/crates/ra_ssr/src/parsing.rs
@@ -70,7 +70,7 @@ impl ParsedRule {
70 rules: Vec::new(), 70 rules: Vec::new(),
71 }; 71 };
72 builder.try_add(ast::Expr::parse(&raw_pattern), raw_template.map(ast::Expr::parse)); 72 builder.try_add(ast::Expr::parse(&raw_pattern), raw_template.map(ast::Expr::parse));
73 builder.try_add(ast::TypeRef::parse(&raw_pattern), raw_template.map(ast::TypeRef::parse)); 73 builder.try_add(ast::Type::parse(&raw_pattern), raw_template.map(ast::Type::parse));
74 builder.try_add(ast::Item::parse(&raw_pattern), raw_template.map(ast::Item::parse)); 74 builder.try_add(ast::Item::parse(&raw_pattern), raw_template.map(ast::Item::parse));
75 builder.try_add(ast::Path::parse(&raw_pattern), raw_template.map(ast::Path::parse)); 75 builder.try_add(ast::Path::parse(&raw_pattern), raw_template.map(ast::Path::parse));
76 builder.try_add(ast::Pat::parse(&raw_pattern), raw_template.map(ast::Pat::parse)); 76 builder.try_add(ast::Pat::parse(&raw_pattern), raw_template.map(ast::Pat::parse));
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index fd426ece9..8a0e3d27b 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -287,7 +287,7 @@ where
287 287
288 assert!(pred.for_token().is_none()); 288 assert!(pred.for_token().is_none());
289 assert!(pred.generic_param_list().is_none()); 289 assert!(pred.generic_param_list().is_none());
290 assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); 290 assert_eq!("T", pred.ty().unwrap().syntax().text().to_string());
291 assert_bound("Clone", bounds.next()); 291 assert_bound("Clone", bounds.next());
292 assert_bound("Copy", bounds.next()); 292 assert_bound("Copy", bounds.next());
293 assert_bound("Debug", bounds.next()); 293 assert_bound("Debug", bounds.next());
@@ -304,20 +304,20 @@ where
304 let pred = predicates.next().unwrap(); 304 let pred = predicates.next().unwrap();
305 let mut bounds = pred.type_bound_list().unwrap().bounds(); 305 let mut bounds = pred.type_bound_list().unwrap().bounds();
306 306
307 assert_eq!("Iterator::Item", pred.type_ref().unwrap().syntax().text().to_string()); 307 assert_eq!("Iterator::Item", pred.ty().unwrap().syntax().text().to_string());
308 assert_bound("'a", bounds.next()); 308 assert_bound("'a", bounds.next());
309 309
310 let pred = predicates.next().unwrap(); 310 let pred = predicates.next().unwrap();
311 let mut bounds = pred.type_bound_list().unwrap().bounds(); 311 let mut bounds = pred.type_bound_list().unwrap().bounds();
312 312
313 assert_eq!("Iterator::Item", pred.type_ref().unwrap().syntax().text().to_string()); 313 assert_eq!("Iterator::Item", pred.ty().unwrap().syntax().text().to_string());
314 assert_bound("Debug", bounds.next()); 314 assert_bound("Debug", bounds.next());
315 assert_bound("'a", bounds.next()); 315 assert_bound("'a", bounds.next());
316 316
317 let pred = predicates.next().unwrap(); 317 let pred = predicates.next().unwrap();
318 let mut bounds = pred.type_bound_list().unwrap().bounds(); 318 let mut bounds = pred.type_bound_list().unwrap().bounds();
319 319
320 assert_eq!("<T as Iterator>::Item", pred.type_ref().unwrap().syntax().text().to_string()); 320 assert_eq!("<T as Iterator>::Item", pred.ty().unwrap().syntax().text().to_string());
321 assert_bound("Debug", bounds.next()); 321 assert_bound("Debug", bounds.next());
322 assert_bound("'a", bounds.next()); 322 assert_bound("'a", bounds.next());
323 323
@@ -326,6 +326,6 @@ where
326 326
327 assert!(pred.for_token().is_some()); 327 assert!(pred.for_token().is_some());
328 assert_eq!("<'a>", pred.generic_param_list().unwrap().syntax().text().to_string()); 328 assert_eq!("<'a>", pred.generic_param_list().unwrap().syntax().text().to_string());
329 assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string()); 329 assert_eq!("F", pred.ty().unwrap().syntax().text().to_string());
330 assert_bound("Fn(&'a str)", bounds.next()); 330 assert_bound("Fn(&'a str)", bounds.next());
331} 331}
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 {
40 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 40 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
41 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 41 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
42 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 42 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
43 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 43 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
44 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 44 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
45 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 45 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
46 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 46 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
@@ -112,7 +112,7 @@ impl Impl {
112 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 112 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
113 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } 113 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
114 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 114 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
115 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 115 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
116 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } 116 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
117 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 117 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
118 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } 118 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
@@ -152,7 +152,7 @@ impl Static {
152 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } 152 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
153 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 153 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
154 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 154 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
155 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 155 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
156 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 156 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
157 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 157 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
158 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 158 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
@@ -198,7 +198,7 @@ impl TypeAlias {
198 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 198 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
199 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } 199 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
200 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 200 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
201 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 201 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
202 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 202 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
203} 203}
204#[derive(Debug, Clone, PartialEq, Eq, Hash)] 204#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -333,7 +333,7 @@ pub struct RetType {
333} 333}
334impl RetType { 334impl RetType {
335 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } 335 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) }
336 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 336 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
337} 337}
338#[derive(Debug, Clone, PartialEq, Eq, Hash)] 338#[derive(Debug, Clone, PartialEq, Eq, Hash)]
339pub struct WhereClause { 339pub struct WhereClause {
@@ -369,7 +369,7 @@ impl SelfParam {
369 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 369 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
370 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } 370 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
371 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 371 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
372 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 372 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
373} 373}
374#[derive(Debug, Clone, PartialEq, Eq, Hash)] 374#[derive(Debug, Clone, PartialEq, Eq, Hash)]
375pub struct Param { 375pub struct Param {
@@ -379,7 +379,7 @@ impl ast::AttrsOwner for Param {}
379impl Param { 379impl Param {
380 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 380 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
381 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 381 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
382 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 382 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
383 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } 383 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
384} 384}
385#[derive(Debug, Clone, PartialEq, Eq, Hash)] 385#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -416,7 +416,7 @@ impl ast::NameOwner for RecordField {}
416impl ast::VisibilityOwner for RecordField {} 416impl ast::VisibilityOwner for RecordField {}
417impl RecordField { 417impl RecordField {
418 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 418 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
419 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 419 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
420} 420}
421#[derive(Debug, Clone, PartialEq, Eq, Hash)] 421#[derive(Debug, Clone, PartialEq, Eq, Hash)]
422pub struct TupleField { 422pub struct TupleField {
@@ -425,7 +425,7 @@ pub struct TupleField {
425impl ast::AttrsOwner for TupleField {} 425impl ast::AttrsOwner for TupleField {}
426impl ast::VisibilityOwner for TupleField {} 426impl ast::VisibilityOwner for TupleField {}
427impl TupleField { 427impl TupleField {
428 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 428 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
429} 429}
430#[derive(Debug, Clone, PartialEq, Eq, Hash)] 430#[derive(Debug, Clone, PartialEq, Eq, Hash)]
431pub struct VariantList { 431pub struct VariantList {
@@ -487,7 +487,7 @@ impl ast::NameOwner for TypeParam {}
487impl ast::TypeBoundsOwner for TypeParam {} 487impl ast::TypeBoundsOwner for TypeParam {}
488impl TypeParam { 488impl TypeParam {
489 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 489 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
490 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } 490 pub fn default_type(&self) -> Option<Type> { support::child(&self.syntax) }
491} 491}
492#[derive(Debug, Clone, PartialEq, Eq, Hash)] 492#[derive(Debug, Clone, PartialEq, Eq, Hash)]
493pub struct ConstParam { 493pub struct ConstParam {
@@ -498,7 +498,7 @@ impl ast::NameOwner for ConstParam {}
498impl ConstParam { 498impl ConstParam {
499 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 499 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
500 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 500 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
501 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 501 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
502 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 502 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
503 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } 503 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
504} 504}
@@ -525,7 +525,7 @@ pub struct ParenType {
525} 525}
526impl ParenType { 526impl ParenType {
527 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 527 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
528 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 528 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
529 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 529 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
530} 530}
531#[derive(Debug, Clone, PartialEq, Eq, Hash)] 531#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -534,7 +534,7 @@ pub struct TupleType {
534} 534}
535impl TupleType { 535impl TupleType {
536 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 536 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
537 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } 537 pub fn fields(&self) -> AstChildren<Type> { support::children(&self.syntax) }
538 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 538 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
539} 539}
540#[derive(Debug, Clone, PartialEq, Eq, Hash)] 540#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -559,7 +559,7 @@ impl PointerType {
559 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } 559 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
560 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 560 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
561 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 561 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
562 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 562 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
563} 563}
564#[derive(Debug, Clone, PartialEq, Eq, Hash)] 564#[derive(Debug, Clone, PartialEq, Eq, Hash)]
565pub struct ArrayType { 565pub struct ArrayType {
@@ -567,7 +567,7 @@ pub struct ArrayType {
567} 567}
568impl ArrayType { 568impl ArrayType {
569 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 569 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
570 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 570 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
571 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 571 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
572 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 572 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
573 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 573 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
@@ -578,7 +578,7 @@ pub struct SliceType {
578} 578}
579impl SliceType { 579impl SliceType {
580 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 580 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
581 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 581 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
582 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 582 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
583} 583}
584#[derive(Debug, Clone, PartialEq, Eq, Hash)] 584#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -591,7 +591,7 @@ impl ReferenceType {
591 support::token(&self.syntax, T![lifetime]) 591 support::token(&self.syntax, T![lifetime])
592 } 592 }
593 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 593 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
594 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 594 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
595} 595}
596#[derive(Debug, Clone, PartialEq, Eq, Hash)] 596#[derive(Debug, Clone, PartialEq, Eq, Hash)]
597pub struct PlaceholderType { 597pub struct PlaceholderType {
@@ -618,7 +618,7 @@ pub struct ForType {
618impl ForType { 618impl ForType {
619 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 619 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
620 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) } 620 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
621 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 621 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
622} 622}
623#[derive(Debug, Clone, PartialEq, Eq, Hash)] 623#[derive(Debug, Clone, PartialEq, Eq, Hash)]
624pub struct ImplTraitType { 624pub struct ImplTraitType {
@@ -882,7 +882,7 @@ impl ast::AttrsOwner for CastExpr {}
882impl CastExpr { 882impl CastExpr {
883 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 883 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
884 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } 884 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
885 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 885 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
886} 886}
887#[derive(Debug, Clone, PartialEq, Eq, Hash)] 887#[derive(Debug, Clone, PartialEq, Eq, Hash)]
888pub struct RefExpr { 888pub struct RefExpr {
@@ -1174,7 +1174,7 @@ impl TypeBound {
1174 support::token(&self.syntax, T![lifetime]) 1174 support::token(&self.syntax, T![lifetime])
1175 } 1175 }
1176 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 1176 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1177 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1177 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1178} 1178}
1179#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1179#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1180pub struct WherePred { 1180pub struct WherePred {
@@ -1187,7 +1187,7 @@ impl WherePred {
1187 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1187 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1188 support::token(&self.syntax, T![lifetime]) 1188 support::token(&self.syntax, T![lifetime])
1189 } 1189 }
1190 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1190 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1191} 1191}
1192#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1192#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1193pub struct ExprStmt { 1193pub struct ExprStmt {
@@ -1207,7 +1207,7 @@ impl LetStmt {
1207 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } 1207 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
1208 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1208 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1209 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 1209 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1210 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1210 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1211 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1211 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1212 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } 1212 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
1213 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 1213 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
@@ -1234,7 +1234,7 @@ pub struct TypeArg {
1234 pub(crate) syntax: SyntaxNode, 1234 pub(crate) syntax: SyntaxNode,
1235} 1235}
1236impl TypeArg { 1236impl TypeArg {
1237 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1237 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1238} 1238}
1239#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1239#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1240pub struct LifetimeArg { 1240pub struct LifetimeArg {
@@ -1253,7 +1253,7 @@ impl ast::TypeBoundsOwner for AssocTypeArg {}
1253impl AssocTypeArg { 1253impl AssocTypeArg {
1254 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 1254 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1255 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1255 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1256 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1256 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1257} 1257}
1258#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1258#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1259pub struct ConstArg { 1259pub struct ConstArg {
@@ -1282,7 +1282,7 @@ pub enum Item {
1282} 1282}
1283impl ast::AttrsOwner for Item {} 1283impl ast::AttrsOwner for Item {}
1284#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1284#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1285pub enum TypeRef { 1285pub enum Type {
1286 ParenType(ParenType), 1286 ParenType(ParenType),
1287 TupleType(TupleType), 1287 TupleType(TupleType),
1288 NeverType(NeverType), 1288 NeverType(NeverType),
@@ -1355,6 +1355,16 @@ pub enum Expr {
1355 BoxExpr(BoxExpr), 1355 BoxExpr(BoxExpr),
1356} 1356}
1357#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1357#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1358pub enum AdtDef {
1359 Struct(Struct),
1360 Enum(Enum),
1361 Union(Union),
1362}
1363impl ast::AttrsOwner for AdtDef {}
1364impl ast::GenericParamsOwner for AdtDef {}
1365impl ast::NameOwner for AdtDef {}
1366impl ast::VisibilityOwner for AdtDef {}
1367#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1358pub enum AssocItem { 1368pub enum AssocItem {
1359 Fn(Fn), 1369 Fn(Fn),
1360 TypeAlias(TypeAlias), 1370 TypeAlias(TypeAlias),
@@ -1384,16 +1394,6 @@ pub enum Stmt {
1384 ExprStmt(ExprStmt), 1394 ExprStmt(ExprStmt),
1385} 1395}
1386impl ast::AttrsOwner for Stmt {} 1396impl ast::AttrsOwner for Stmt {}
1387#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1388pub enum AdtDef {
1389 Struct(Struct),
1390 Enum(Enum),
1391 Union(Union),
1392}
1393impl ast::AttrsOwner for AdtDef {}
1394impl ast::GenericParamsOwner for AdtDef {}
1395impl ast::NameOwner for AdtDef {}
1396impl ast::VisibilityOwner for AdtDef {}
1397impl AstNode for SourceFile { 1397impl AstNode for SourceFile {
1398 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } 1398 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
1399 fn cast(syntax: SyntaxNode) -> Option<Self> { 1399 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2847,46 +2847,46 @@ impl AstNode for Item {
2847 } 2847 }
2848 } 2848 }
2849} 2849}
2850impl From<ParenType> for TypeRef { 2850impl From<ParenType> for Type {
2851 fn from(node: ParenType) -> TypeRef { TypeRef::ParenType(node) } 2851 fn from(node: ParenType) -> Type { Type::ParenType(node) }
2852} 2852}
2853impl From<TupleType> for TypeRef { 2853impl From<TupleType> for Type {
2854 fn from(node: TupleType) -> TypeRef { TypeRef::TupleType(node) } 2854 fn from(node: TupleType) -> Type { Type::TupleType(node) }
2855} 2855}
2856impl From<NeverType> for TypeRef { 2856impl From<NeverType> for Type {
2857 fn from(node: NeverType) -> TypeRef { TypeRef::NeverType(node) } 2857 fn from(node: NeverType) -> Type { Type::NeverType(node) }
2858} 2858}
2859impl From<PathType> for TypeRef { 2859impl From<PathType> for Type {
2860 fn from(node: PathType) -> TypeRef { TypeRef::PathType(node) } 2860 fn from(node: PathType) -> Type { Type::PathType(node) }
2861} 2861}
2862impl From<PointerType> for TypeRef { 2862impl From<PointerType> for Type {
2863 fn from(node: PointerType) -> TypeRef { TypeRef::PointerType(node) } 2863 fn from(node: PointerType) -> Type { Type::PointerType(node) }
2864} 2864}
2865impl From<ArrayType> for TypeRef { 2865impl From<ArrayType> for Type {
2866 fn from(node: ArrayType) -> TypeRef { TypeRef::ArrayType(node) } 2866 fn from(node: ArrayType) -> Type { Type::ArrayType(node) }
2867} 2867}
2868impl From<SliceType> for TypeRef { 2868impl From<SliceType> for Type {
2869 fn from(node: SliceType) -> TypeRef { TypeRef::SliceType(node) } 2869 fn from(node: SliceType) -> Type { Type::SliceType(node) }
2870} 2870}
2871impl From<ReferenceType> for TypeRef { 2871impl From<ReferenceType> for Type {
2872 fn from(node: ReferenceType) -> TypeRef { TypeRef::ReferenceType(node) } 2872 fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) }
2873} 2873}
2874impl From<PlaceholderType> for TypeRef { 2874impl From<PlaceholderType> for Type {
2875 fn from(node: PlaceholderType) -> TypeRef { TypeRef::PlaceholderType(node) } 2875 fn from(node: PlaceholderType) -> Type { Type::PlaceholderType(node) }
2876} 2876}
2877impl From<FnPointerType> for TypeRef { 2877impl From<FnPointerType> for Type {
2878 fn from(node: FnPointerType) -> TypeRef { TypeRef::FnPointerType(node) } 2878 fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) }
2879} 2879}
2880impl From<ForType> for TypeRef { 2880impl From<ForType> for Type {
2881 fn from(node: ForType) -> TypeRef { TypeRef::ForType(node) } 2881 fn from(node: ForType) -> Type { Type::ForType(node) }
2882} 2882}
2883impl From<ImplTraitType> for TypeRef { 2883impl From<ImplTraitType> for Type {
2884 fn from(node: ImplTraitType) -> TypeRef { TypeRef::ImplTraitType(node) } 2884 fn from(node: ImplTraitType) -> Type { Type::ImplTraitType(node) }
2885} 2885}
2886impl From<DynTraitType> for TypeRef { 2886impl From<DynTraitType> for Type {
2887 fn from(node: DynTraitType) -> TypeRef { TypeRef::DynTraitType(node) } 2887 fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) }
2888} 2888}
2889impl AstNode for TypeRef { 2889impl AstNode for Type {
2890 fn can_cast(kind: SyntaxKind) -> bool { 2890 fn can_cast(kind: SyntaxKind) -> bool {
2891 match kind { 2891 match kind {
2892 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE 2892 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
@@ -2897,38 +2897,38 @@ impl AstNode for TypeRef {
2897 } 2897 }
2898 fn cast(syntax: SyntaxNode) -> Option<Self> { 2898 fn cast(syntax: SyntaxNode) -> Option<Self> {
2899 let res = match syntax.kind() { 2899 let res = match syntax.kind() {
2900 PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }), 2900 PAREN_TYPE => Type::ParenType(ParenType { syntax }),
2901 TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }), 2901 TUPLE_TYPE => Type::TupleType(TupleType { syntax }),
2902 NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }), 2902 NEVER_TYPE => Type::NeverType(NeverType { syntax }),
2903 PATH_TYPE => TypeRef::PathType(PathType { syntax }), 2903 PATH_TYPE => Type::PathType(PathType { syntax }),
2904 POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }), 2904 POINTER_TYPE => Type::PointerType(PointerType { syntax }),
2905 ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }), 2905 ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }),
2906 SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }), 2906 SLICE_TYPE => Type::SliceType(SliceType { syntax }),
2907 REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }), 2907 REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }),
2908 PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }), 2908 PLACEHOLDER_TYPE => Type::PlaceholderType(PlaceholderType { syntax }),
2909 FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }), 2909 FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }),
2910 FOR_TYPE => TypeRef::ForType(ForType { syntax }), 2910 FOR_TYPE => Type::ForType(ForType { syntax }),
2911 IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }), 2911 IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }),
2912 DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }), 2912 DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }),
2913 _ => return None, 2913 _ => return None,
2914 }; 2914 };
2915 Some(res) 2915 Some(res)
2916 } 2916 }
2917 fn syntax(&self) -> &SyntaxNode { 2917 fn syntax(&self) -> &SyntaxNode {
2918 match self { 2918 match self {
2919 TypeRef::ParenType(it) => &it.syntax, 2919 Type::ParenType(it) => &it.syntax,
2920 TypeRef::TupleType(it) => &it.syntax, 2920 Type::TupleType(it) => &it.syntax,
2921 TypeRef::NeverType(it) => &it.syntax, 2921 Type::NeverType(it) => &it.syntax,
2922 TypeRef::PathType(it) => &it.syntax, 2922 Type::PathType(it) => &it.syntax,
2923 TypeRef::PointerType(it) => &it.syntax, 2923 Type::PointerType(it) => &it.syntax,
2924 TypeRef::ArrayType(it) => &it.syntax, 2924 Type::ArrayType(it) => &it.syntax,
2925 TypeRef::SliceType(it) => &it.syntax, 2925 Type::SliceType(it) => &it.syntax,
2926 TypeRef::ReferenceType(it) => &it.syntax, 2926 Type::ReferenceType(it) => &it.syntax,
2927 TypeRef::PlaceholderType(it) => &it.syntax, 2927 Type::PlaceholderType(it) => &it.syntax,
2928 TypeRef::FnPointerType(it) => &it.syntax, 2928 Type::FnPointerType(it) => &it.syntax,
2929 TypeRef::ForType(it) => &it.syntax, 2929 Type::ForType(it) => &it.syntax,
2930 TypeRef::ImplTraitType(it) => &it.syntax, 2930 Type::ImplTraitType(it) => &it.syntax,
2931 TypeRef::DynTraitType(it) => &it.syntax, 2931 Type::DynTraitType(it) => &it.syntax,
2932 } 2932 }
2933 } 2933 }
2934} 2934}
@@ -3234,6 +3234,39 @@ impl AstNode for Expr {
3234 } 3234 }
3235 } 3235 }
3236} 3236}
3237impl From<Struct> for AdtDef {
3238 fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) }
3239}
3240impl From<Enum> for AdtDef {
3241 fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) }
3242}
3243impl From<Union> for AdtDef {
3244 fn from(node: Union) -> AdtDef { AdtDef::Union(node) }
3245}
3246impl AstNode for AdtDef {
3247 fn can_cast(kind: SyntaxKind) -> bool {
3248 match kind {
3249 STRUCT | ENUM | UNION => true,
3250 _ => false,
3251 }
3252 }
3253 fn cast(syntax: SyntaxNode) -> Option<Self> {
3254 let res = match syntax.kind() {
3255 STRUCT => AdtDef::Struct(Struct { syntax }),
3256 ENUM => AdtDef::Enum(Enum { syntax }),
3257 UNION => AdtDef::Union(Union { syntax }),
3258 _ => return None,
3259 };
3260 Some(res)
3261 }
3262 fn syntax(&self) -> &SyntaxNode {
3263 match self {
3264 AdtDef::Struct(it) => &it.syntax,
3265 AdtDef::Enum(it) => &it.syntax,
3266 AdtDef::Union(it) => &it.syntax,
3267 }
3268 }
3269}
3237impl From<Fn> for AssocItem { 3270impl From<Fn> for AssocItem {
3238 fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } 3271 fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) }
3239} 3272}
@@ -3366,45 +3399,12 @@ impl AstNode for Stmt {
3366 } 3399 }
3367 } 3400 }
3368} 3401}
3369impl From<Struct> for AdtDef {
3370 fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) }
3371}
3372impl From<Enum> for AdtDef {
3373 fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) }
3374}
3375impl From<Union> for AdtDef {
3376 fn from(node: Union) -> AdtDef { AdtDef::Union(node) }
3377}
3378impl AstNode for AdtDef {
3379 fn can_cast(kind: SyntaxKind) -> bool {
3380 match kind {
3381 STRUCT | ENUM | UNION => true,
3382 _ => false,
3383 }
3384 }
3385 fn cast(syntax: SyntaxNode) -> Option<Self> {
3386 let res = match syntax.kind() {
3387 STRUCT => AdtDef::Struct(Struct { syntax }),
3388 ENUM => AdtDef::Enum(Enum { syntax }),
3389 UNION => AdtDef::Union(Union { syntax }),
3390 _ => return None,
3391 };
3392 Some(res)
3393 }
3394 fn syntax(&self) -> &SyntaxNode {
3395 match self {
3396 AdtDef::Struct(it) => &it.syntax,
3397 AdtDef::Enum(it) => &it.syntax,
3398 AdtDef::Union(it) => &it.syntax,
3399 }
3400 }
3401}
3402impl std::fmt::Display for Item { 3402impl std::fmt::Display for Item {
3403 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3403 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3404 std::fmt::Display::fmt(self.syntax(), f) 3404 std::fmt::Display::fmt(self.syntax(), f)
3405 } 3405 }
3406} 3406}
3407impl std::fmt::Display for TypeRef { 3407impl std::fmt::Display for Type {
3408 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3408 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3409 std::fmt::Display::fmt(self.syntax(), f) 3409 std::fmt::Display::fmt(self.syntax(), f)
3410 } 3410 }
@@ -3424,27 +3424,27 @@ impl std::fmt::Display for Expr {
3424 std::fmt::Display::fmt(self.syntax(), f) 3424 std::fmt::Display::fmt(self.syntax(), f)
3425 } 3425 }
3426} 3426}
3427impl std::fmt::Display for AssocItem { 3427impl std::fmt::Display for AdtDef {
3428 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3428 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3429 std::fmt::Display::fmt(self.syntax(), f) 3429 std::fmt::Display::fmt(self.syntax(), f)
3430 } 3430 }
3431} 3431}
3432impl std::fmt::Display for ExternItem { 3432impl std::fmt::Display for AssocItem {
3433 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3433 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3434 std::fmt::Display::fmt(self.syntax(), f) 3434 std::fmt::Display::fmt(self.syntax(), f)
3435 } 3435 }
3436} 3436}
3437impl std::fmt::Display for GenericParam { 3437impl std::fmt::Display for ExternItem {
3438 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3438 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3439 std::fmt::Display::fmt(self.syntax(), f) 3439 std::fmt::Display::fmt(self.syntax(), f)
3440 } 3440 }
3441} 3441}
3442impl std::fmt::Display for Stmt { 3442impl std::fmt::Display for GenericParam {
3443 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3443 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3444 std::fmt::Display::fmt(self.syntax(), f) 3444 std::fmt::Display::fmt(self.syntax(), f)
3445 } 3445 }
3446} 3446}
3447impl std::fmt::Display for AdtDef { 3447impl std::fmt::Display for Stmt {
3448 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3448 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3449 std::fmt::Display::fmt(self.syntax(), f) 3449 std::fmt::Display::fmt(self.syntax(), f)
3450 } 3450 }
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 {
17 ast_from_text(&format!("fn f() {{ {}; }}", text)) 17 ast_from_text(&format!("fn f() {{ {}; }}", text))
18} 18}
19 19
20pub fn type_ref(text: &str) -> ast::TypeRef { 20pub fn type_ref(text: &str) -> ast::Type {
21 ast_from_text(&format!("impl {} for D {{}};", text)) 21 ast_from_text(&format!("impl {} for D {{}};", text))
22} 22}
23 23
@@ -75,7 +75,7 @@ pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordE
75 } 75 }
76} 76}
77 77
78pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordField { 78pub fn record_field_def(name: ast::NameRef, ty: ast::Type) -> ast::RecordField {
79 ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) 79 ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty))
80} 80}
81 81
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 {
82#[derive(Debug, Clone, PartialEq, Eq)] 82#[derive(Debug, Clone, PartialEq, Eq)]
83pub enum PathSegmentKind { 83pub enum PathSegmentKind {
84 Name(ast::NameRef), 84 Name(ast::NameRef),
85 Type { type_ref: Option<ast::TypeRef>, trait_ref: Option<ast::PathType> }, 85 Type { type_ref: Option<ast::Type>, trait_ref: Option<ast::PathType> },
86 SelfKw, 86 SelfKw,
87 SuperKw, 87 SuperKw,
88 CrateKw, 88 CrateKw,
@@ -108,8 +108,8 @@ impl ast::PathSegment {
108 // <T> or <T as Trait> 108 // <T> or <T as Trait>
109 // T is any TypeRef, Trait has to be a PathType 109 // T is any TypeRef, Trait has to be a PathType
110 let mut type_refs = 110 let mut type_refs =
111 self.syntax().children().filter(|node| ast::TypeRef::can_cast(node.kind())); 111 self.syntax().children().filter(|node| ast::Type::can_cast(node.kind()));
112 let type_ref = type_refs.next().and_then(ast::TypeRef::cast); 112 let type_ref = type_refs.next().and_then(ast::Type::cast);
113 let trait_ref = type_refs.next().and_then(ast::PathType::cast); 113 let trait_ref = type_refs.next().and_then(ast::PathType::cast);
114 PathSegmentKind::Type { type_ref, trait_ref } 114 PathSegmentKind::Type { type_ref, trait_ref }
115 } 115 }
@@ -136,21 +136,21 @@ impl ast::UseTreeList {
136} 136}
137 137
138impl ast::Impl { 138impl ast::Impl {
139 pub fn target_type(&self) -> Option<ast::TypeRef> { 139 pub fn target_type(&self) -> Option<ast::Type> {
140 match self.target() { 140 match self.target() {
141 (Some(t), None) | (_, Some(t)) => Some(t), 141 (Some(t), None) | (_, Some(t)) => Some(t),
142 _ => None, 142 _ => None,
143 } 143 }
144 } 144 }
145 145
146 pub fn target_trait(&self) -> Option<ast::TypeRef> { 146 pub fn target_trait(&self) -> Option<ast::Type> {
147 match self.target() { 147 match self.target() {
148 (Some(t), Some(_)) => Some(t), 148 (Some(t), Some(_)) => Some(t),
149 _ => None, 149 _ => None,
150 } 150 }
151 } 151 }
152 152
153 fn target(&self) -> (Option<ast::TypeRef>, Option<ast::TypeRef>) { 153 fn target(&self) -> (Option<ast::Type>, Option<ast::Type>) {
154 let mut types = support::children(self.syntax()); 154 let mut types = support::children(self.syntax());
155 let first = types.next(); 155 let first = types.next();
156 let second = types.next(); 156 let second = types.next();
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 6203b6206..8a4d45386 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -194,7 +194,7 @@ impl ast::Item {
194 } 194 }
195} 195}
196 196
197impl ast::TypeRef { 197impl ast::Type {
198 /// Returns `text`, parsed as an type reference, but only if it has no errors. 198 /// Returns `text`, parsed as an type reference, but only if it has no errors.
199 pub fn parse(text: &str) -> Result<Self, ()> { 199 pub fn parse(text: &str) -> Result<Self, ()> {
200 parsing::parse_text_fragment(text, ra_parser::FragmentKind::Type) 200 parsing::parse_text_fragment(text, ra_parser::FragmentKind::Type)
diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs
index 68cee8914..00b957f43 100644
--- a/crates/ra_syntax/src/tests.rs
+++ b/crates/ra_syntax/src/tests.rs
@@ -98,7 +98,7 @@ fn type_parser_tests() {
98 fragment_parser_dir_test( 98 fragment_parser_dir_test(
99 &["parser/fragments/type/ok"], 99 &["parser/fragments/type/ok"],
100 &["parser/fragments/type/err"], 100 &["parser/fragments/type/err"],
101 crate::ast::TypeRef::parse, 101 crate::ast::Type::parse,
102 ); 102 );
103} 103}
104 104