From 936c6950e78d073f54c9ba66795f7f6f3abb351b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 26 Nov 2019 21:25:17 +0300 Subject: Remove last traces of adt from Ty --- crates/ra_hir/src/code_model.rs | 2 +- crates/ra_hir/src/expr.rs | 4 ++-- crates/ra_hir/src/ty.rs | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 0edcdb177..a842dfed6 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -1104,7 +1104,7 @@ impl Type { pub fn as_adt(&self) -> Option { let (adt, _subst) = self.ty.value.as_adt()?; - Some(adt) + Some(adt.into()) } fn derived(&self, ty: Ty) -> Type { diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index adb9805ab..5c82c23d6 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -12,7 +12,7 @@ use crate::{ db::HirDatabase, diagnostics::{MissingFields, MissingOkInTailExpr}, ty::{ApplicationTy, InferenceResult, Ty, TypeCtor}, - Adt, Function, Name, Path, + Function, Name, Path, Struct, }; pub use hir_def::{ @@ -69,7 +69,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { } let struct_def = match self.infer[id].as_adt() { - Some((Adt::Struct(s), _)) => s, + Some((AdtId::StructId(s), _)) => Struct::from(s), _ => return, }; diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 680ddc2f9..791b6064a 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs @@ -22,13 +22,14 @@ use hir_def::{ expr::ExprId, generics::GenericParams, type_ref::Mutability, AdtId, ContainerId, DefWithBodyId, GenericDefId, HasModule, Lookup, TraitId, TypeAliasId, }; +use hir_expand::name::Name; use ra_db::{impl_intern_key, salsa}; use crate::{ db::HirDatabase, ty::primitive::{FloatTy, IntTy, Uncertain}, util::make_mut_slice, - Adt, Crate, Name, + Crate, }; use display::{HirDisplay, HirFormatter}; @@ -598,10 +599,10 @@ impl Ty { } } - pub fn as_adt(&self) -> Option<(Adt, &Substs)> { + pub fn as_adt(&self) -> Option<(AdtId, &Substs)> { match self { Ty::Apply(ApplicationTy { ctor: TypeCtor::Adt(adt_def), parameters }) => { - Some(((*adt_def).into(), parameters)) + Some((*adt_def, parameters)) } _ => None, } -- cgit v1.2.3