From 2e2642efccd5855e4158b01a006e7884a96982bb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 20:51:43 +0200 Subject: Remove TypeAscriptionOwner --- crates/ra_hir_def/src/adt.rs | 4 ++-- crates/ra_hir_def/src/body/lower.rs | 8 +++----- crates/ra_hir_def/src/item_tree.rs | 2 +- crates/ra_hir_def/src/item_tree/lower.rs | 10 +++++----- crates/ra_hir_def/src/path/lower.rs | 4 ++-- crates/ra_hir_def/src/type_ref.rs | 7 ++----- 6 files changed, 15 insertions(+), 20 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 231c1dfab..f8523d03f 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -8,7 +8,7 @@ use hir_expand::{ InFile, }; use ra_arena::{map::ArenaMap, Arena}; -use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner, VisibilityOwner}; +use ra_syntax::ast::{self, NameOwner, VisibilityOwner}; use crate::{ body::{CfgExpander, LowerCtx}, @@ -251,7 +251,7 @@ fn lower_struct( || Either::Right(fd.clone()), || FieldData { name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), - type_ref: TypeRef::from_ast_opt(&ctx, fd.ascribed_type()), + type_ref: TypeRef::from_ast_opt(&ctx, fd.ty()), visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), }, ); diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 78f6da5b8..288ca76c3 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -11,7 +11,7 @@ use ra_arena::Arena; use ra_syntax::{ ast::{ self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, ModuleItemOwner, NameOwner, - SlicePatComponents, TypeAscriptionOwner, + SlicePatComponents, }, AstNode, AstPtr, }; @@ -466,8 +466,7 @@ impl ExprCollector<'_> { if let Some(pl) = e.param_list() { for param in pl.params() { let pat = self.collect_pat_opt(param.pat()); - let type_ref = - param.ascribed_type().map(|it| TypeRef::from_ast(&self.ctx(), it)); + let type_ref = param.ty().map(|it| TypeRef::from_ast(&self.ctx(), it)); args.push(pat); arg_types.push(type_ref); } @@ -607,8 +606,7 @@ impl ExprCollector<'_> { .map(|s| match s { ast::Stmt::LetStmt(stmt) => { let pat = self.collect_pat_opt(stmt.pat()); - let type_ref = - stmt.ascribed_type().map(|it| TypeRef::from_ast(&self.ctx(), it)); + let type_ref = stmt.ty().map(|it| TypeRef::from_ast(&self.ctx(), it)); let initializer = stmt.initializer().map(|e| self.collect_expr(e)); Statement::Let { pat, type_ref, initializer } } diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index 63b56405c..a67e75dac 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs @@ -13,7 +13,7 @@ use std::{ sync::Arc, }; -use ast::{AstNode, AttrsOwner, NameOwner, StructKind, TypeAscriptionOwner}; +use ast::{AstNode, AttrsOwner, NameOwner, StructKind}; use either::Either; use hir_expand::{ ast_id_map::FileAstId, diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 29f1de547..f0ced1f79 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -209,7 +209,7 @@ impl Ctx { fn lower_record_field(&mut self, field: &ast::RecordField) -> Option { let name = field.name()?.as_name(); let visibility = self.lower_visibility(field); - let type_ref = self.lower_type_ref_opt(field.ascribed_type()); + let type_ref = self.lower_type_ref_opt(field.ty()); let res = Field { name, type_ref, visibility }; Some(res) } @@ -286,7 +286,7 @@ impl Ctx { let mut has_self_param = false; if let Some(param_list) = func.param_list() { if let Some(self_param) = param_list.self_param() { - let self_type = match self_param.ascribed_type() { + let self_type = match self_param.ty() { Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref), None => { let self_type = TypeRef::Path(name![Self].into()); @@ -305,7 +305,7 @@ impl Ctx { has_self_param = true; } for param in param_list.params() { - let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ascribed_type()); + let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty()); params.push(type_ref); } } @@ -370,7 +370,7 @@ impl Ctx { fn lower_static(&mut self, static_: &ast::Static) -> Option> { let name = static_.name()?.as_name(); - let type_ref = self.lower_type_ref_opt(static_.ascribed_type()); + let type_ref = self.lower_type_ref_opt(static_.ty()); let visibility = self.lower_visibility(static_); let mutable = static_.mut_token().is_some(); let ast_id = self.source_ast_id_map.ast_id(static_); @@ -380,7 +380,7 @@ impl Ctx { fn lower_const(&mut self, konst: &ast::Const) -> FileItemTreeId { let name = konst.name().map(|it| it.as_name()); - let type_ref = self.lower_type_ref_opt(konst.ascribed_type()); + let type_ref = self.lower_type_ref_opt(konst.ty()); let visibility = self.lower_visibility(konst); let ast_id = self.source_ast_id_map.ast_id(konst); let res = Const { name, visibility, type_ref, ast_id }; diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs index 6a0c019fd..dfab15948 100644 --- a/crates/ra_hir_def/src/path/lower.rs +++ b/crates/ra_hir_def/src/path/lower.rs @@ -9,7 +9,7 @@ use hir_expand::{ hygiene::Hygiene, name::{name, AsName}, }; -use ra_syntax::ast::{self, AstNode, TypeAscriptionOwner, TypeBoundsOwner}; +use ra_syntax::ast::{self, AstNode, TypeBoundsOwner}; use super::AssociatedTypeBinding; use crate::{ @@ -189,7 +189,7 @@ fn lower_generic_args_from_fn_path( if let Some(params) = params { let mut param_types = Vec::new(); for param in params.params() { - let type_ref = TypeRef::from_ast_opt(&ctx, param.ascribed_type()); + let type_ref = TypeRef::from_ast_opt(&ctx, param.ty()); param_types.push(type_ref); } let arg = GenericArg::Type(TypeRef::Tuple(param_types)); diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/ra_hir_def/src/type_ref.rs index 970fc9af5..4059302df 100644 --- a/crates/ra_hir_def/src/type_ref.rs +++ b/crates/ra_hir_def/src/type_ref.rs @@ -1,7 +1,7 @@ //! HIR for references to types. Paths in these are not yet resolved. They can //! be directly created from an ast::TypeRef, without further queries. -use ra_syntax::ast::{self, TypeAscriptionOwner}; +use ra_syntax::ast::{self}; use crate::{body::LowerCtx, path::Path}; @@ -124,10 +124,7 @@ impl TypeRef { is_varargs = param.dotdotdot_token().is_some(); } - pl.params() - .map(|p| p.ascribed_type()) - .map(|it| TypeRef::from_ast_opt(&ctx, it)) - .collect() + pl.params().map(|p| p.ty()).map(|it| TypeRef::from_ast_opt(&ctx, it)).collect() } else { Vec::new() }; -- cgit v1.2.3