mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Implement HasModule for AdtId
This commit is contained in:
parent
586acef528
commit
a0e1dbb450
2 changed files with 13 additions and 9 deletions
|
@ -481,6 +481,16 @@ impl HasModule for ConstLoc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl HasModule for AdtId {
|
||||||
|
fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
|
||||||
|
match self {
|
||||||
|
AdtId::StructId(it) => it.0.module(db),
|
||||||
|
AdtId::UnionId(it) => it.0.module(db),
|
||||||
|
AdtId::EnumId(it) => it.module(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl HasModule for StaticLoc {
|
impl HasModule for StaticLoc {
|
||||||
fn module(&self, _db: &impl db::DefDatabase) -> ModuleId {
|
fn module(&self, _db: &impl db::DefDatabase) -> ModuleId {
|
||||||
self.container
|
self.container
|
||||||
|
|
|
@ -18,8 +18,8 @@ use crate::{
|
||||||
path::{Path, PathKind},
|
path::{Path, PathKind},
|
||||||
per_ns::PerNs,
|
per_ns::PerNs,
|
||||||
AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId,
|
AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId,
|
||||||
GenericDefId, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId, StructId,
|
GenericDefId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId,
|
||||||
TraitId, TypeAliasId,
|
StructId, TraitId, TypeAliasId,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
@ -503,13 +503,7 @@ impl HasResolver for TraitId {
|
||||||
impl<T: Into<AdtId>> HasResolver for T {
|
impl<T: Into<AdtId>> HasResolver for T {
|
||||||
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
let def = self.into();
|
let def = self.into();
|
||||||
let module = match def {
|
def.module(db)
|
||||||
AdtId::StructId(it) => it.0.module(db),
|
|
||||||
AdtId::UnionId(it) => it.0.module(db),
|
|
||||||
AdtId::EnumId(it) => it.module(db),
|
|
||||||
};
|
|
||||||
|
|
||||||
module
|
|
||||||
.resolver(db)
|
.resolver(db)
|
||||||
.push_generic_params_scope(db, def.into())
|
.push_generic_params_scope(db, def.into())
|
||||||
.push_scope(Scope::AdtScope(def))
|
.push_scope(Scope::AdtScope(def))
|
||||||
|
|
Loading…
Reference in a new issue