Skip to content

Commit 9c1a7ab

Browse files
committed
Back out "Implement HasResolver and HasModule for FieldId"
This backs out commit ce9da9063097c26006886b3f403a0c50790c285a.
1 parent f22e331 commit 9c1a7ab

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

src/tools/rust-analyzer/crates/hir-def/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,12 +1357,6 @@ impl HasModule for VariantId {
13571357
}
13581358
}
13591359

1360-
impl HasModule for FieldId {
1361-
fn module(&self, db: &dyn DefDatabase) -> ModuleId {
1362-
self.parent.module(db)
1363-
}
1364-
}
1365-
13661360
impl HasModule for MacroId {
13671361
fn module(&self, db: &dyn DefDatabase) -> ModuleId {
13681362
match *self {
@@ -1386,7 +1380,11 @@ impl HasModule for TypeOwnerId {
13861380
TypeOwnerId::ImplId(it) => it.module(db),
13871381
TypeOwnerId::EnumVariantId(it) => it.module(db),
13881382
TypeOwnerId::InTypeConstId(it) => it.lookup(db).owner.module(db),
1389-
TypeOwnerId::FieldId(it) => it.module(db),
1383+
TypeOwnerId::FieldId(it) => match it.parent {
1384+
VariantId::EnumVariantId(it) => it.module(db),
1385+
VariantId::StructId(it) => it.module(db),
1386+
VariantId::UnionId(it) => it.module(db),
1387+
},
13901388
}
13911389
}
13921390
}

src/tools/rust-analyzer/crates/hir-def/src/resolver.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ use crate::{
2727
type_ref::{LifetimeRef, TypesMap},
2828
visibility::{RawVisibility, Visibility},
2929
AdtId, ConstId, ConstParamId, CrateRootModuleId, DefWithBodyId, EnumId, EnumVariantId,
30-
ExternBlockId, ExternCrateId, FieldId, FunctionId, FxIndexMap, GenericDefId, GenericParamId,
31-
HasModule, ImplId, ItemContainerId, ItemTreeLoc, LifetimeParamId, LocalModuleId, Lookup,
32-
Macro2Id, MacroId, MacroRulesId, ModuleDefId, ModuleId, ProcMacroId, StaticId, StructId,
33-
TraitAliasId, TraitId, TypeAliasId, TypeOrConstParamId, TypeOwnerId, TypeParamId, UseId,
34-
VariantId,
30+
ExternBlockId, ExternCrateId, FunctionId, FxIndexMap, GenericDefId, GenericParamId, HasModule,
31+
ImplId, ItemContainerId, ItemTreeLoc, LifetimeParamId, LocalModuleId, Lookup, Macro2Id,
32+
MacroId, MacroRulesId, ModuleDefId, ModuleId, ProcMacroId, StaticId, StructId, TraitAliasId,
33+
TraitId, TypeAliasId, TypeOrConstParamId, TypeOwnerId, TypeParamId, UseId, VariantId,
3534
};
3635

3736
#[derive(Debug, Clone)]
@@ -1228,7 +1227,11 @@ impl HasResolver for TypeOwnerId {
12281227
TypeOwnerId::TypeAliasId(it) => it.resolver(db),
12291228
TypeOwnerId::ImplId(it) => it.resolver(db),
12301229
TypeOwnerId::EnumVariantId(it) => it.resolver(db),
1231-
TypeOwnerId::FieldId(it) => it.resolver(db),
1230+
TypeOwnerId::FieldId(it) => match it.parent {
1231+
VariantId::EnumVariantId(it) => it.resolver(db),
1232+
VariantId::StructId(it) => it.resolver(db),
1233+
VariantId::UnionId(it) => it.resolver(db),
1234+
},
12321235
}
12331236
}
12341237
}
@@ -1241,7 +1244,11 @@ impl HasResolver for DefWithBodyId {
12411244
DefWithBodyId::StaticId(s) => s.resolver(db),
12421245
DefWithBodyId::VariantId(v) => v.resolver(db),
12431246
DefWithBodyId::InTypeConstId(c) => c.lookup(db).owner.resolver(db),
1244-
DefWithBodyId::FieldId(f) => f.resolver(db),
1247+
DefWithBodyId::FieldId(f) => match f.parent {
1248+
VariantId::EnumVariantId(it) => it.resolver(db),
1249+
VariantId::StructId(it) => it.resolver(db),
1250+
VariantId::UnionId(it) => it.resolver(db),
1251+
},
12451252
}
12461253
}
12471254
}
@@ -1288,12 +1295,6 @@ impl HasResolver for VariantId {
12881295
}
12891296
}
12901297

1291-
impl HasResolver for FieldId {
1292-
fn resolver(self, db: &dyn DefDatabase) -> Resolver {
1293-
self.parent.resolver(db)
1294-
}
1295-
}
1296-
12971298
impl HasResolver for MacroId {
12981299
fn resolver(self, db: &dyn DefDatabase) -> Resolver {
12991300
match self {

0 commit comments

Comments
 (0)