Simplify
This commit is contained in:
parent
6241cf9a59
commit
1cead41510
@ -432,15 +432,16 @@ pub fn ty(self, db: &impl HirDatabase) -> Ty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn module(self, db: &impl DefDatabase) -> Module {
|
||||||
|
match self {
|
||||||
|
Adt::Struct(s) => s.module(db),
|
||||||
|
Adt::Union(s) => s.module(db),
|
||||||
|
Adt::Enum(e) => e.module(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
pub fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
||||||
Some(
|
Some(self.module(db).krate())
|
||||||
match self {
|
|
||||||
Adt::Struct(s) => s.module(db),
|
|
||||||
Adt::Union(s) => s.module(db),
|
|
||||||
Adt::Enum(e) => e.module(db),
|
|
||||||
}
|
|
||||||
.krate(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
expr::{ExprScopes, PatId, ScopeId},
|
expr::{ExprScopes, PatId, ScopeId},
|
||||||
generics::{GenericParams, HasGenericParams},
|
generics::{GenericParams, HasGenericParams},
|
||||||
Adt, Const, Container, DefWithBody, Enum, EnumVariant, Function, GenericDef, ImplBlock, Local,
|
Adt, Const, Container, DefWithBody, Enum, EnumVariant, Function, GenericDef, ImplBlock, Local,
|
||||||
MacroDef, Module, ModuleDef, PerNs, Static, Struct, Trait, TypeAlias, Union,
|
MacroDef, Module, ModuleDef, PerNs, Static, Struct, Trait, TypeAlias,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
@ -505,40 +505,13 @@ fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for Struct {
|
impl<T: Into<Adt>> HasResolver for T {
|
||||||
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
self.module(db)
|
let def = self.into();
|
||||||
|
def.module(db)
|
||||||
.resolver(db)
|
.resolver(db)
|
||||||
.push_generic_params_scope(db, self.into())
|
.push_generic_params_scope(db, def.into())
|
||||||
.push_scope(Scope::AdtScope(self.into()))
|
.push_scope(Scope::AdtScope(def))
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HasResolver for Union {
|
|
||||||
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
|
||||||
self.module(db)
|
|
||||||
.resolver(db)
|
|
||||||
.push_generic_params_scope(db, self.into())
|
|
||||||
.push_scope(Scope::AdtScope(self.into()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HasResolver for Enum {
|
|
||||||
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
|
||||||
self.module(db)
|
|
||||||
.resolver(db)
|
|
||||||
.push_generic_params_scope(db, self.into())
|
|
||||||
.push_scope(Scope::AdtScope(self.into()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HasResolver for Adt {
|
|
||||||
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
|
||||||
match self {
|
|
||||||
Adt::Struct(it) => it.resolver(db),
|
|
||||||
Adt::Union(it) => it.resolver(db),
|
|
||||||
Adt::Enum(it) => it.resolver(db),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user