aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r--crates/ra_hir_def/src/lib.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index f085bbe87..4fc3127c4 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -335,6 +335,7 @@ pub enum ContainerId {
335 ModuleId(ModuleId), 335 ModuleId(ModuleId),
336 ImplId(ImplId), 336 ImplId(ImplId),
337 TraitId(TraitId), 337 TraitId(TraitId),
338 DefWithBodyId(DefWithBodyId),
338} 339}
339 340
340/// A Data Type 341/// A Data Type
@@ -478,33 +479,32 @@ pub trait HasModule {
478 fn module(&self, db: &impl db::DefDatabase) -> ModuleId; 479 fn module(&self, db: &impl db::DefDatabase) -> ModuleId;
479} 480}
480 481
481impl HasModule for FunctionLoc { 482impl HasModule for ContainerId {
482 fn module(&self, db: &impl db::DefDatabase) -> ModuleId { 483 fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
483 match self.container { 484 match *self {
484 ContainerId::ModuleId(it) => it, 485 ContainerId::ModuleId(it) => it,
485 ContainerId::ImplId(it) => it.lookup(db).container, 486 ContainerId::ImplId(it) => it.lookup(db).container,
486 ContainerId::TraitId(it) => it.lookup(db).container, 487 ContainerId::TraitId(it) => it.lookup(db).container,
488 ContainerId::DefWithBodyId(it) => it.module(db),
487 } 489 }
488 } 490 }
489} 491}
490 492
493impl HasModule for FunctionLoc {
494 fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
495 self.container.module(db)
496 }
497}
498
491impl HasModule for TypeAliasLoc { 499impl HasModule for TypeAliasLoc {
492 fn module(&self, db: &impl db::DefDatabase) -> ModuleId { 500 fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
493 match self.container { 501 self.container.module(db)
494 ContainerId::ModuleId(it) => it,
495 ContainerId::ImplId(it) => it.lookup(db).container,
496 ContainerId::TraitId(it) => it.lookup(db).container,
497 }
498 } 502 }
499} 503}
500 504
501impl HasModule for ConstLoc { 505impl HasModule for ConstLoc {
502 fn module(&self, db: &impl db::DefDatabase) -> ModuleId { 506 fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
503 match self.container { 507 self.container.module(db)
504 ContainerId::ModuleId(it) => it,
505 ContainerId::ImplId(it) => it.lookup(db).container,
506 ContainerId::TraitId(it) => it.lookup(db).container,
507 }
508 } 508 }
509} 509}
510 510