From 3bd4fe96dce17eb2bff380389b24ea325bf54803 Mon Sep 17 00:00:00 2001 From: Zac Pullar-Strecker Date: Thu, 8 Oct 2020 15:44:52 +1300 Subject: Remove methodowner & fix formatting --- crates/hir/src/code_model.rs | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) (limited to 'crates/hir/src/code_model.rs') diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 9989b9b56..650b4fa40 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -35,7 +35,7 @@ use hir_ty::{ traits::SolutionVariables, ApplicationTy, BoundVar, CallableDefId, Canonical, DebruijnIndex, FnSig, GenericPredicate, InEnvironment, Obligation, ProjectionPredicate, ProjectionTy, Substs, TraitEnvironment, Ty, - TyDefId, TyKind, TypeCtor, TyLoweringContext, + TyDefId, TyKind, TypeCtor, }; use rustc_hash::FxHashSet; use stdx::impl_from; @@ -186,15 +186,6 @@ impl_from!( for ModuleDef ); -impl From for ModuleDef { - fn from(mowner: MethodOwner) -> Self { - match mowner { - MethodOwner::Trait(t) => t.into(), - MethodOwner::Adt(t) => t.into(), - } - } -} - impl From for ModuleDef { fn from(var: VariantDef) -> Self { match var { @@ -778,36 +769,8 @@ impl Function { pub fn has_body(self, db: &dyn HirDatabase) -> bool { db.function_data(self.id).has_body } - - /// If this function is a method, the trait or type where it is declared. - pub fn method_owner(self, db: &dyn HirDatabase) -> Option { - match self.as_assoc_item(db).map(|assoc| assoc.container(db)) { - Some(AssocItemContainer::Trait(t)) => Some(t.into()), - Some(AssocItemContainer::ImplDef(imp)) => { - let resolver = ModuleId::from(imp.module(db)).resolver(db.upcast()); - let ctx = TyLoweringContext::new(db, &resolver); - let adt = Ty::from_hir( - &ctx, - &imp.target_trait(db).unwrap_or_else(|| imp.target_type(db)), - ) - .as_adt() - .map(|t| t.0) - .unwrap(); - Some(Adt::from(adt).into()) - } - None => None, - } - } } -#[derive(Debug)] -pub enum MethodOwner { - Trait(Trait), - Adt(Adt), -} - -impl_from!(Trait, Adt for MethodOwner); - // Note: logically, this belongs to `hir_ty`, but we are not using it there yet. pub enum Access { Shared, -- cgit v1.2.3