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_assists/src/ast_transform.rs | 12 ++++++------ .../ra_assists/src/handlers/generate_from_impl_for_enum.rs | 2 +- crates/ra_assists/src/handlers/introduce_named_lifetime.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'crates/ra_assists') 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 { pub struct SubstituteTypeParams<'a> { source_scope: &'a SemanticsScope<'a>, - substs: FxHashMap, + substs: FxHashMap, previous: Box + 'a>, } @@ -80,17 +80,17 @@ impl<'a> SubstituteTypeParams<'a> { // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the // trait ref, and then go from the types in the substs back to the syntax) - fn get_syntactic_substs(impl_def: ast::Impl) -> Option> { + fn get_syntactic_substs(impl_def: ast::Impl) -> Option> { let target_trait = impl_def.target_trait()?; let path_type = match target_trait { - ast::TypeRef::PathType(path) => path, + ast::Type::PathType(path) => path, _ => return None, }; let type_arg_list = path_type.path()?.segment()?.type_arg_list()?; let mut result = Vec::new(); for type_arg in type_arg_list.type_args() { let type_arg: ast::TypeArg = type_arg; - result.push(type_arg.type_ref()?); + result.push(type_arg.ty()?); } Some(result) } @@ -99,9 +99,9 @@ impl<'a> SubstituteTypeParams<'a> { &self, node: &ra_syntax::SyntaxNode, ) -> Option { - let type_ref = ast::TypeRef::cast(node.clone())?; + let type_ref = ast::Type::cast(node.clone())?; let path = match &type_ref { - ast::TypeRef::PathType(path_type) => path_type.path()?, + ast::Type::PathType(path_type) => path_type.path()?, _ => return None, }; // 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 } let field_type = field_list.fields().next()?.ty()?; let path = match field_type { - ast::TypeRef::PathType(it) => it, + ast::Type::PathType(it) => it, _ => return None, }; 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( let fn_params_without_lifetime: Vec<_> = param_list .params() .filter_map(|param| match param.ty() { - Some(ast::TypeRef::ReferenceType(ascribed_type)) + Some(ast::Type::ReferenceType(ascribed_type)) if ascribed_type.lifetime_token() == None => { Some(ascribed_type.amp_token()?.text_range().end()) -- cgit v1.2.3