diff options
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r-- | crates/hir/src/lib.rs | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index a7c42ca1e..cdf65a044 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -513,9 +513,8 @@ impl Field { | |||
513 | } | 513 | } |
514 | 514 | ||
515 | /// Returns the type as in the signature of the struct (i.e., with | 515 | /// Returns the type as in the signature of the struct (i.e., with |
516 | /// placeholder types for type parameters). This is good for showing | 516 | /// placeholder types for type parameters). Only use this in the context of |
517 | /// signature help, but not so good to actually get the type of the field | 517 | /// the field definition. |
518 | /// when you actually have a variable of the struct. | ||
519 | pub fn ty(&self, db: &dyn HirDatabase) -> Type { | 518 | pub fn ty(&self, db: &dyn HirDatabase) -> Type { |
520 | let var_id = self.parent.into(); | 519 | let var_id = self.parent.into(); |
521 | let generic_def_id: GenericDefId = match self.parent { | 520 | let generic_def_id: GenericDefId = match self.parent { |
@@ -552,10 +551,6 @@ impl Struct { | |||
552 | Module { id: self.id.lookup(db.upcast()).container } | 551 | Module { id: self.id.lookup(db.upcast()).container } |
553 | } | 552 | } |
554 | 553 | ||
555 | pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> { | ||
556 | Some(self.module(db).krate()) | ||
557 | } | ||
558 | |||
559 | pub fn name(self, db: &dyn HirDatabase) -> Name { | 554 | pub fn name(self, db: &dyn HirDatabase) -> Name { |
560 | db.struct_data(self.id).name.clone() | 555 | db.struct_data(self.id).name.clone() |
561 | } | 556 | } |
@@ -640,10 +635,6 @@ impl Enum { | |||
640 | Module { id: self.id.lookup(db.upcast()).container } | 635 | Module { id: self.id.lookup(db.upcast()).container } |
641 | } | 636 | } |
642 | 637 | ||
643 | pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> { | ||
644 | Some(self.module(db).krate()) | ||
645 | } | ||
646 | |||
647 | pub fn name(self, db: &dyn HirDatabase) -> Name { | 638 | pub fn name(self, db: &dyn HirDatabase) -> Name { |
648 | db.enum_data(self.id).name.clone() | 639 | db.enum_data(self.id).name.clone() |
649 | } | 640 | } |
@@ -673,6 +664,7 @@ impl Variant { | |||
673 | pub fn module(self, db: &dyn HirDatabase) -> Module { | 664 | pub fn module(self, db: &dyn HirDatabase) -> Module { |
674 | self.parent.module(db) | 665 | self.parent.module(db) |
675 | } | 666 | } |
667 | |||
676 | pub fn parent_enum(self, _db: &dyn HirDatabase) -> Enum { | 668 | pub fn parent_enum(self, _db: &dyn HirDatabase) -> Enum { |
677 | self.parent | 669 | self.parent |
678 | } | 670 | } |
@@ -729,10 +721,6 @@ impl Adt { | |||
729 | } | 721 | } |
730 | } | 722 | } |
731 | 723 | ||
732 | pub fn krate(self, db: &dyn HirDatabase) -> Crate { | ||
733 | self.module(db).krate() | ||
734 | } | ||
735 | |||
736 | pub fn name(self, db: &dyn HirDatabase) -> Name { | 724 | pub fn name(self, db: &dyn HirDatabase) -> Name { |
737 | match self { | 725 | match self { |
738 | Adt::Struct(s) => s.name(db), | 726 | Adt::Struct(s) => s.name(db), |
@@ -821,10 +809,6 @@ impl Function { | |||
821 | self.id.lookup(db.upcast()).module(db.upcast()).into() | 809 | self.id.lookup(db.upcast()).module(db.upcast()).into() |
822 | } | 810 | } |
823 | 811 | ||
824 | pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> { | ||
825 | Some(self.module(db).krate()) | ||
826 | } | ||
827 | |||
828 | pub fn name(self, db: &dyn HirDatabase) -> Name { | 812 | pub fn name(self, db: &dyn HirDatabase) -> Name { |
829 | db.function_data(self.id).name.clone() | 813 | db.function_data(self.id).name.clone() |
830 | } | 814 | } |
@@ -1014,10 +998,6 @@ impl Const { | |||
1014 | Module { id: self.id.lookup(db.upcast()).module(db.upcast()) } | 998 | Module { id: self.id.lookup(db.upcast()).module(db.upcast()) } |
1015 | } | 999 | } |
1016 | 1000 | ||
1017 | pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> { | ||
1018 | Some(self.module(db).krate()) | ||
1019 | } | ||
1020 | |||
1021 | pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { | 1001 | pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { |
1022 | db.const_data(self.id).name.clone() | 1002 | db.const_data(self.id).name.clone() |
1023 | } | 1003 | } |
@@ -1045,10 +1025,6 @@ impl Static { | |||
1045 | Module { id: self.id.lookup(db.upcast()).module(db.upcast()) } | 1025 | Module { id: self.id.lookup(db.upcast()).module(db.upcast()) } |
1046 | } | 1026 | } |
1047 | 1027 | ||
1048 | pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> { | ||
1049 | Some(self.module(db).krate()) | ||
1050 | } | ||
1051 | |||
1052 | pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { | 1028 | pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { |
1053 | db.static_data(self.id).name.clone() | 1029 | db.static_data(self.id).name.clone() |
1054 | } | 1030 | } |
@@ -1112,10 +1088,6 @@ impl TypeAlias { | |||
1112 | Module { id: self.id.lookup(db.upcast()).module(db.upcast()) } | 1088 | Module { id: self.id.lookup(db.upcast()).module(db.upcast()) } |
1113 | } | 1089 | } |
1114 | 1090 | ||
1115 | pub fn krate(self, db: &dyn HirDatabase) -> Crate { | ||
1116 | self.module(db).krate() | ||
1117 | } | ||
1118 | |||
1119 | pub fn type_ref(self, db: &dyn HirDatabase) -> Option<TypeRef> { | 1091 | pub fn type_ref(self, db: &dyn HirDatabase) -> Option<TypeRef> { |
1120 | db.type_alias_data(self.id).type_ref.as_deref().cloned() | 1092 | db.type_alias_data(self.id).type_ref.as_deref().cloned() |
1121 | } | 1093 | } |
@@ -1667,10 +1639,6 @@ impl Impl { | |||
1667 | self.id.lookup(db.upcast()).container.into() | 1639 | self.id.lookup(db.upcast()).container.into() |
1668 | } | 1640 | } |
1669 | 1641 | ||
1670 | pub fn krate(self, db: &dyn HirDatabase) -> Crate { | ||
1671 | Crate { id: self.module(db).id.krate() } | ||
1672 | } | ||
1673 | |||
1674 | pub fn is_builtin_derive(self, db: &dyn HirDatabase) -> Option<InFile<ast::Attr>> { | 1642 | pub fn is_builtin_derive(self, db: &dyn HirDatabase) -> Option<InFile<ast::Attr>> { |
1675 | let src = self.source(db)?; | 1643 | let src = self.source(db)?; |
1676 | let item = src.file_id.is_builtin_derive(db.upcast())?; | 1644 | let item = src.file_id.is_builtin_derive(db.upcast())?; |