aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/lib.rs30
1 files changed, 9 insertions, 21 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index c6d424c48..4ef38c0f0 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -535,7 +535,7 @@ pub struct Struct {
535 535
536impl Struct { 536impl Struct {
537 pub fn module(self, db: &dyn HirDatabase) -> Module { 537 pub fn module(self, db: &dyn HirDatabase) -> Module {
538 Module { id: self.id.lookup(db.upcast()).container.module(db.upcast()) } 538 Module { id: self.id.lookup(db.upcast()).container }
539 } 539 }
540 540
541 pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> { 541 pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> {
@@ -556,11 +556,7 @@ impl Struct {
556 } 556 }
557 557
558 pub fn ty(self, db: &dyn HirDatabase) -> Type { 558 pub fn ty(self, db: &dyn HirDatabase) -> Type {
559 Type::from_def( 559 Type::from_def(db, self.id.lookup(db.upcast()).container.krate(), self.id)
560 db,
561 self.id.lookup(db.upcast()).container.module(db.upcast()).krate(),
562 self.id,
563 )
564 } 560 }
565 561
566 pub fn repr(self, db: &dyn HirDatabase) -> Option<ReprKind> { 562 pub fn repr(self, db: &dyn HirDatabase) -> Option<ReprKind> {
@@ -587,15 +583,11 @@ impl Union {
587 } 583 }
588 584
589 pub fn module(self, db: &dyn HirDatabase) -> Module { 585 pub fn module(self, db: &dyn HirDatabase) -> Module {
590 Module { id: self.id.lookup(db.upcast()).container.module(db.upcast()) } 586 Module { id: self.id.lookup(db.upcast()).container }
591 } 587 }
592 588
593 pub fn ty(self, db: &dyn HirDatabase) -> Type { 589 pub fn ty(self, db: &dyn HirDatabase) -> Type {
594 Type::from_def( 590 Type::from_def(db, self.id.lookup(db.upcast()).container.krate(), self.id)
595 db,
596 self.id.lookup(db.upcast()).container.module(db.upcast()).krate(),
597 self.id,
598 )
599 } 591 }
600 592
601 pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field> { 593 pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field> {
@@ -619,7 +611,7 @@ pub struct Enum {
619 611
620impl Enum { 612impl Enum {
621 pub fn module(self, db: &dyn HirDatabase) -> Module { 613 pub fn module(self, db: &dyn HirDatabase) -> Module {
622 Module { id: self.id.lookup(db.upcast()).container.module(db.upcast()) } 614 Module { id: self.id.lookup(db.upcast()).container }
623 } 615 }
624 616
625 pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> { 617 pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> {
@@ -635,11 +627,7 @@ impl Enum {
635 } 627 }
636 628
637 pub fn ty(self, db: &dyn HirDatabase) -> Type { 629 pub fn ty(self, db: &dyn HirDatabase) -> Type {
638 Type::from_def( 630 Type::from_def(db, self.id.lookup(db.upcast()).container.krate(), self.id)
639 db,
640 self.id.lookup(db.upcast()).container.module(db.upcast()).krate(),
641 self.id,
642 )
643 } 631 }
644} 632}
645 633
@@ -1001,7 +989,7 @@ pub struct Trait {
1001 989
1002impl Trait { 990impl Trait {
1003 pub fn module(self, db: &dyn HirDatabase) -> Module { 991 pub fn module(self, db: &dyn HirDatabase) -> Module {
1004 Module { id: self.id.lookup(db.upcast()).container.module(db.upcast()) } 992 Module { id: self.id.lookup(db.upcast()).container }
1005 } 993 }
1006 994
1007 pub fn name(self, db: &dyn HirDatabase) -> Name { 995 pub fn name(self, db: &dyn HirDatabase) -> Name {
@@ -1510,7 +1498,7 @@ impl Impl {
1510 pub fn target_ty(self, db: &dyn HirDatabase) -> Type { 1498 pub fn target_ty(self, db: &dyn HirDatabase) -> Type {
1511 let impl_data = db.impl_data(self.id); 1499 let impl_data = db.impl_data(self.id);
1512 let resolver = self.id.resolver(db.upcast()); 1500 let resolver = self.id.resolver(db.upcast());
1513 let krate = self.id.lookup(db.upcast()).container.module(db.upcast()).krate(); 1501 let krate = self.id.lookup(db.upcast()).container.krate();
1514 let ctx = hir_ty::TyLoweringContext::new(db, &resolver); 1502 let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
1515 let ty = Ty::from_hir(&ctx, &impl_data.target_type); 1503 let ty = Ty::from_hir(&ctx, &impl_data.target_type);
1516 Type::new_with_resolver_inner(db, krate, &resolver, ty) 1504 Type::new_with_resolver_inner(db, krate, &resolver, ty)
@@ -1525,7 +1513,7 @@ impl Impl {
1525 } 1513 }
1526 1514
1527 pub fn module(self, db: &dyn HirDatabase) -> Module { 1515 pub fn module(self, db: &dyn HirDatabase) -> Module {
1528 self.id.lookup(db.upcast()).container.module(db.upcast()).into() 1516 self.id.lookup(db.upcast()).container.into()
1529 } 1517 }
1530 1518
1531 pub fn krate(self, db: &dyn HirDatabase) -> Crate { 1519 pub fn krate(self, db: &dyn HirDatabase) -> Crate {