mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Stop using ContainerId
in AssocContainerId
This commit is contained in:
parent
12f6bdcfd9
commit
a430549aa6
7 changed files with 12 additions and 12 deletions
|
@ -1157,7 +1157,7 @@ where
|
||||||
{
|
{
|
||||||
match id.lookup(db.upcast()).container {
|
match id.lookup(db.upcast()).container {
|
||||||
AssocContainerId::TraitId(_) | AssocContainerId::ImplId(_) => Some(ctor(DEF::from(id))),
|
AssocContainerId::TraitId(_) | AssocContainerId::ImplId(_) => Some(ctor(DEF::from(id))),
|
||||||
AssocContainerId::ContainerId(_) => None,
|
AssocContainerId::ModuleId(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1185,7 +1185,7 @@ impl AssocItem {
|
||||||
match container {
|
match container {
|
||||||
AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()),
|
AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()),
|
||||||
AssocContainerId::ImplId(id) => AssocItemContainer::Impl(id.into()),
|
AssocContainerId::ImplId(id) => AssocItemContainer::Impl(id.into()),
|
||||||
AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"),
|
AssocContainerId::ModuleId(_) => panic!("invalid AssocItem"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -286,11 +286,11 @@ pub enum ContainerId {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
pub enum AssocContainerId {
|
pub enum AssocContainerId {
|
||||||
ContainerId(ContainerId),
|
ModuleId(ModuleId),
|
||||||
ImplId(ImplId),
|
ImplId(ImplId),
|
||||||
TraitId(TraitId),
|
TraitId(TraitId),
|
||||||
}
|
}
|
||||||
impl_from!(ContainerId for AssocContainerId);
|
impl_from!(ModuleId for AssocContainerId);
|
||||||
|
|
||||||
/// A Data Type
|
/// A Data Type
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
|
@ -459,7 +459,7 @@ impl HasModule for ContainerId {
|
||||||
impl HasModule for AssocContainerId {
|
impl HasModule for AssocContainerId {
|
||||||
fn module(&self, db: &dyn db::DefDatabase) -> ModuleId {
|
fn module(&self, db: &dyn db::DefDatabase) -> ModuleId {
|
||||||
match *self {
|
match *self {
|
||||||
AssocContainerId::ContainerId(it) => it.module(db),
|
AssocContainerId::ModuleId(it) => it,
|
||||||
AssocContainerId::ImplId(it) => it.lookup(db).container.module(db),
|
AssocContainerId::ImplId(it) => it.lookup(db).container.module(db),
|
||||||
AssocContainerId::TraitId(it) => it.lookup(db).container.module(db),
|
AssocContainerId::TraitId(it) => it.lookup(db).container.module(db),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1121,7 +1121,7 @@ impl ModCollector<'_, '_> {
|
||||||
|
|
||||||
def = Some(DefData {
|
def = Some(DefData {
|
||||||
id: FunctionLoc {
|
id: FunctionLoc {
|
||||||
container: container.into(),
|
container: module.into(),
|
||||||
id: ItemTreeId::new(self.file_id, id),
|
id: ItemTreeId::new(self.file_id, id),
|
||||||
}
|
}
|
||||||
.intern(self.def_collector.db)
|
.intern(self.def_collector.db)
|
||||||
|
@ -1188,7 +1188,7 @@ impl ModCollector<'_, '_> {
|
||||||
if let Some(name) = &it.name {
|
if let Some(name) = &it.name {
|
||||||
def = Some(DefData {
|
def = Some(DefData {
|
||||||
id: ConstLoc {
|
id: ConstLoc {
|
||||||
container: container.into(),
|
container: module.into(),
|
||||||
id: ItemTreeId::new(self.file_id, id),
|
id: ItemTreeId::new(self.file_id, id),
|
||||||
}
|
}
|
||||||
.intern(self.def_collector.db)
|
.intern(self.def_collector.db)
|
||||||
|
@ -1228,7 +1228,7 @@ impl ModCollector<'_, '_> {
|
||||||
|
|
||||||
def = Some(DefData {
|
def = Some(DefData {
|
||||||
id: TypeAliasLoc {
|
id: TypeAliasLoc {
|
||||||
container: container.into(),
|
container: module.into(),
|
||||||
id: ItemTreeId::new(self.file_id, id),
|
id: ItemTreeId::new(self.file_id, id),
|
||||||
}
|
}
|
||||||
.intern(self.def_collector.db)
|
.intern(self.def_collector.db)
|
||||||
|
|
|
@ -700,7 +700,7 @@ impl HasResolver for ContainerId {
|
||||||
impl HasResolver for AssocContainerId {
|
impl HasResolver for AssocContainerId {
|
||||||
fn resolver(self, db: &dyn DefDatabase) -> Resolver {
|
fn resolver(self, db: &dyn DefDatabase) -> Resolver {
|
||||||
match self {
|
match self {
|
||||||
AssocContainerId::ContainerId(it) => it.resolver(db),
|
AssocContainerId::ModuleId(it) => it.resolver(db),
|
||||||
AssocContainerId::TraitId(it) => it.resolver(db),
|
AssocContainerId::TraitId(it) => it.resolver(db),
|
||||||
AssocContainerId::ImplId(it) => it.resolver(db),
|
AssocContainerId::ImplId(it) => it.resolver(db),
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,7 @@ impl<'a> InferenceContext<'a> {
|
||||||
}));
|
}));
|
||||||
Some(trait_substs)
|
Some(trait_substs)
|
||||||
}
|
}
|
||||||
AssocContainerId::ContainerId(_) => None,
|
AssocContainerId::ModuleId(_) => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.write_assoc_resolution(id, item);
|
self.write_assoc_resolution(id, item);
|
||||||
|
|
|
@ -715,7 +715,7 @@ fn transform_receiver_ty(
|
||||||
.fill_with_unknown()
|
.fill_with_unknown()
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
AssocContainerId::ContainerId(_) => unreachable!(),
|
AssocContainerId::ModuleId(_) => unreachable!(),
|
||||||
};
|
};
|
||||||
let sig = db.callable_item_signature(function_id.into());
|
let sig = db.callable_item_signature(function_id.into());
|
||||||
Some(sig.value.params()[0].clone().subst_bound_vars(&substs))
|
Some(sig.value.params()[0].clone().subst_bound_vars(&substs))
|
||||||
|
|
|
@ -259,6 +259,6 @@ fn parent_generic_def(db: &dyn DefDatabase, def: GenericDefId) -> Option<Generic
|
||||||
match container {
|
match container {
|
||||||
AssocContainerId::ImplId(it) => Some(it.into()),
|
AssocContainerId::ImplId(it) => Some(it.into()),
|
||||||
AssocContainerId::TraitId(it) => Some(it.into()),
|
AssocContainerId::TraitId(it) => Some(it.into()),
|
||||||
AssocContainerId::ContainerId(_) => None,
|
AssocContainerId::ModuleId(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue