mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Give closures types
This commit is contained in:
parent
36fb3f53d7
commit
619a8185a6
5 changed files with 78 additions and 21 deletions
|
@ -551,6 +551,14 @@ impl DefWithBody {
|
|||
DefWithBody::Static(s) => s.resolver(db),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
||||
match self {
|
||||
DefWithBody::Const(c) => c.krate(db),
|
||||
DefWithBody::Function(f) => f.krate(db),
|
||||
DefWithBody::Static(s) => s.krate(db),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait HasBody: Copy {
|
||||
|
@ -671,6 +679,10 @@ impl Function {
|
|||
self.id.module(db)
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &impl DefDatabase) -> Option<Crate> {
|
||||
self.module(db).krate(db)
|
||||
}
|
||||
|
||||
pub fn name(self, db: &impl HirDatabase) -> Name {
|
||||
self.data(db).name.clone()
|
||||
}
|
||||
|
@ -745,6 +757,10 @@ impl Const {
|
|||
self.id.module(db)
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &impl DefDatabase) -> Option<Crate> {
|
||||
self.module(db).krate(db)
|
||||
}
|
||||
|
||||
pub fn data(self, db: &impl HirDatabase) -> Arc<ConstData> {
|
||||
db.const_data(self)
|
||||
}
|
||||
|
@ -824,6 +840,10 @@ impl Static {
|
|||
self.id.module(db)
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &impl DefDatabase) -> Option<Crate> {
|
||||
self.module(db).krate(db)
|
||||
}
|
||||
|
||||
pub fn data(self, db: &impl HirDatabase) -> Arc<ConstData> {
|
||||
db.static_data(self)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue