aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r--crates/hir/src/lib.rs15
1 files changed, 1 insertions, 14 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index edee99356..ca9a7f7fa 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -514,8 +514,7 @@ impl Field {
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). Only use this in the context of 516 /// placeholder types for type parameters). Only use this in the context of
517 /// the field *definition*; if you've already got a variable of the struct 517 /// the field definition.
518 /// type, use `Type::field_type` to get to the field type.
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 {
@@ -1944,18 +1943,6 @@ impl Type {
1944 } 1943 }
1945 } 1944 }
1946 1945
1947 pub fn field_type(&self, db: &dyn HirDatabase, field: Field) -> Option<Type> {
1948 let (adt_id, substs) = self.ty.as_adt()?;
1949 let variant_id: hir_def::VariantId = field.parent.into();
1950 if variant_id.adt_id() != adt_id {
1951 return None;
1952 }
1953
1954 let ty = db.field_types(variant_id).get(field.id)?.clone();
1955 let ty = ty.substitute(&Interner, substs);
1956 Some(self.derived(ty))
1957 }
1958
1959 pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> { 1946 pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> {
1960 let (variant_id, substs) = match self.ty.kind(&Interner) { 1947 let (variant_id, substs) = match self.ty.kind(&Interner) {
1961 &TyKind::Adt(hir_ty::AdtId(AdtId::StructId(s)), ref substs) => (s.into(), substs), 1948 &TyKind::Adt(hir_ty::AdtId(AdtId::StructId(s)), ref substs) => (s.into(), substs),