aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradamrk <[email protected]>2020-02-15 21:12:48 +0000
committeradamrk <[email protected]>2020-02-16 15:10:32 +0000
commit68d3743faf51926f0a63207686f860bdffafe0d7 (patch)
tree86221c859db5f543f9e5c91b3176f2103a30d86a
parent04aff742b15ebab39f493ba480d20c61e1f3bdd5 (diff)
replace uses of VariantData::is_unit with VariantData::kind
-rw-r--r--crates/ra_hir_def/src/adt.rs6
-rw-r--r--crates/ra_hir_ty/src/lower.rs11
2 files changed, 7 insertions, 10 deletions
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs
index 4582c7314..985f409e8 100644
--- a/crates/ra_hir_def/src/adt.rs
+++ b/crates/ra_hir_def/src/adt.rs
@@ -147,12 +147,6 @@ impl VariantData {
147 VariantData::Unit => StructKind::Unit, 147 VariantData::Unit => StructKind::Unit,
148 } 148 }
149 } 149 }
150 pub fn is_unit(&self) -> bool {
151 match self {
152 VariantData::Unit => true,
153 _ => false,
154 }
155 }
156} 150}
157 151
158impl HasChildSource for VariantId { 152impl HasChildSource for VariantId {
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index 6a2aded02..a5b2734a0 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -9,6 +9,7 @@ use std::iter;
9use std::sync::Arc; 9use std::sync::Arc;
10 10
11use hir_def::{ 11use hir_def::{
12 adt::StructKind,
12 builtin_type::BuiltinType, 13 builtin_type::BuiltinType,
13 generics::{TypeParamProvenance, WherePredicate, WherePredicateTarget}, 14 generics::{TypeParamProvenance, WherePredicate, WherePredicateTarget},
14 path::{GenericArg, Path, PathSegment, PathSegments}, 15 path::{GenericArg, Path, PathSegment, PathSegments},
@@ -805,8 +806,9 @@ fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> PolyFn
805/// Build the type of a tuple struct constructor. 806/// Build the type of a tuple struct constructor.
806fn type_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> Binders<Ty> { 807fn type_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> Binders<Ty> {
807 let struct_data = db.struct_data(def.into()); 808 let struct_data = db.struct_data(def.into());
808 if struct_data.variant_data.is_unit() { 809 match struct_data.variant_data.kind() {
809 return type_for_adt(db, def.into()); // Unit struct 810 StructKind::Unit => return type_for_adt(db, def.into()),
811 StructKind::Tuple | StructKind::Record => (),
810 } 812 }
811 let generics = generics(db, def.into()); 813 let generics = generics(db, def.into());
812 let substs = Substs::bound_vars(&generics); 814 let substs = Substs::bound_vars(&generics);
@@ -830,8 +832,9 @@ fn fn_sig_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariantId
830fn type_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariantId) -> Binders<Ty> { 832fn type_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariantId) -> Binders<Ty> {
831 let enum_data = db.enum_data(def.parent); 833 let enum_data = db.enum_data(def.parent);
832 let var_data = &enum_data.variants[def.local_id].variant_data; 834 let var_data = &enum_data.variants[def.local_id].variant_data;
833 if var_data.is_unit() { 835 match var_data.kind() {
834 return type_for_adt(db, def.parent.into()); // Unit variant 836 StructKind::Unit => return type_for_adt(db, def.parent.into()),
837 StructKind::Record | StructKind::Tuple => (),
835 } 838 }
836 let generics = generics(db, def.parent.into()); 839 let generics = generics(db, def.parent.into());
837 let substs = Substs::bound_vars(&generics); 840 let substs = Substs::bound_vars(&generics);