From a430549aa6cb78e3a6c9258305b348743c4d7449 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Mar 2021 18:27:16 +0100 Subject: Stop using `ContainerId` in `AssocContainerId` --- crates/hir/src/lib.rs | 4 ++-- crates/hir_def/src/lib.rs | 6 +++--- crates/hir_def/src/nameres/collector.rs | 6 +++--- crates/hir_def/src/resolver.rs | 2 +- crates/hir_ty/src/infer/path.rs | 2 +- crates/hir_ty/src/method_resolution.rs | 2 +- crates/hir_ty/src/utils.rs | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 638398e29..c6d424c48 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1157,7 +1157,7 @@ where { match id.lookup(db.upcast()).container { AssocContainerId::TraitId(_) | AssocContainerId::ImplId(_) => Some(ctor(DEF::from(id))), - AssocContainerId::ContainerId(_) => None, + AssocContainerId::ModuleId(_) => None, } } @@ -1185,7 +1185,7 @@ impl AssocItem { match container { AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()), AssocContainerId::ImplId(id) => AssocItemContainer::Impl(id.into()), - AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"), + AssocContainerId::ModuleId(_) => panic!("invalid AssocItem"), } } diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs index 4498d94bb..ab3b17f6c 100644 --- a/crates/hir_def/src/lib.rs +++ b/crates/hir_def/src/lib.rs @@ -286,11 +286,11 @@ pub enum ContainerId { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum AssocContainerId { - ContainerId(ContainerId), + ModuleId(ModuleId), ImplId(ImplId), TraitId(TraitId), } -impl_from!(ContainerId for AssocContainerId); +impl_from!(ModuleId for AssocContainerId); /// A Data Type #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] @@ -459,7 +459,7 @@ impl HasModule for ContainerId { impl HasModule for AssocContainerId { fn module(&self, db: &dyn db::DefDatabase) -> ModuleId { match *self { - AssocContainerId::ContainerId(it) => it.module(db), + AssocContainerId::ModuleId(it) => it, AssocContainerId::ImplId(it) => it.lookup(db).container.module(db), AssocContainerId::TraitId(it) => it.lookup(db).container.module(db), } diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 3bb69d935..5bf2ba721 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs @@ -1121,7 +1121,7 @@ impl ModCollector<'_, '_> { def = Some(DefData { id: FunctionLoc { - container: container.into(), + container: module.into(), id: ItemTreeId::new(self.file_id, id), } .intern(self.def_collector.db) @@ -1188,7 +1188,7 @@ impl ModCollector<'_, '_> { if let Some(name) = &it.name { def = Some(DefData { id: ConstLoc { - container: container.into(), + container: module.into(), id: ItemTreeId::new(self.file_id, id), } .intern(self.def_collector.db) @@ -1228,7 +1228,7 @@ impl ModCollector<'_, '_> { def = Some(DefData { id: TypeAliasLoc { - container: container.into(), + container: module.into(), id: ItemTreeId::new(self.file_id, id), } .intern(self.def_collector.db) diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index 28b184f7c..6f036c8c4 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs @@ -700,7 +700,7 @@ impl HasResolver for ContainerId { impl HasResolver for AssocContainerId { fn resolver(self, db: &dyn DefDatabase) -> Resolver { match self { - AssocContainerId::ContainerId(it) => it.resolver(db), + AssocContainerId::ModuleId(it) => it.resolver(db), AssocContainerId::TraitId(it) => it.resolver(db), AssocContainerId::ImplId(it) => it.resolver(db), } diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index 5d541104e..ae3554bac 100644 --- a/crates/hir_ty/src/infer/path.rs +++ b/crates/hir_ty/src/infer/path.rs @@ -260,7 +260,7 @@ impl<'a> InferenceContext<'a> { })); Some(trait_substs) } - AssocContainerId::ContainerId(_) => None, + AssocContainerId::ModuleId(_) => None, }; self.write_assoc_resolution(id, item); diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 24db33c49..248367267 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -715,7 +715,7 @@ fn transform_receiver_ty( .fill_with_unknown() .build() } - AssocContainerId::ContainerId(_) => unreachable!(), + AssocContainerId::ModuleId(_) => unreachable!(), }; let sig = db.callable_item_signature(function_id.into()); Some(sig.value.params()[0].clone().subst_bound_vars(&substs)) diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs index 65b79df0d..7351e4e54 100644 --- a/crates/hir_ty/src/utils.rs +++ b/crates/hir_ty/src/utils.rs @@ -259,6 +259,6 @@ fn parent_generic_def(db: &dyn DefDatabase, def: GenericDefId) -> Option Some(it.into()), AssocContainerId::TraitId(it) => Some(it.into()), - AssocContainerId::ContainerId(_) => None, + AssocContainerId::ModuleId(_) => None, } } -- cgit v1.2.3