about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Regueiro <alexreg@me.com>2018-12-13 15:35:45 +0000
committerAlexander Regueiro <alexreg@me.com>2018-12-15 19:11:45 +0000
commit616885ec2c529bc795995108ac5c87d1c532b17f (patch)
tree5a96c1939c4a2723ac21b1fa7cdecfe9f1bda0eb
parent5656c96c71442b2dfc5aa01519dfe2027c6051b0 (diff)
downloadrust-616885ec2c529bc795995108ac5c87d1c532b17f.tar.gz
rust-616885ec2c529bc795995108ac5c87d1c532b17f.zip
Fixed minor issues raised in review.
-rw-r--r--src/librustc/ty/mod.rs16
-rw-r--r--src/librustc_typeck/check/mod.rs6
2 files changed, 11 insertions, 11 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index dbefa396cda..429b7f03af8 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -1756,7 +1756,7 @@ bitflags! {
         const IS_ENUM             = 1 << 0;
         const IS_UNION            = 1 << 1;
         const IS_STRUCT           = 1 << 2;
-        const IS_TUPLE_STRUCT     = 1 << 3;
+        const HAS_CTOR            = 1 << 3;
         const IS_PHANTOM_DATA     = 1 << 4;
         const IS_FUNDAMENTAL      = 1 << 5;
         const IS_BOX              = 1 << 6;
@@ -2096,7 +2096,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
             let variant_def = &variants[VariantIdx::new(0)];
             let def_key = tcx.def_key(variant_def.did);
             match def_key.disambiguated_data.data {
-                DefPathData::StructCtor => flags |= AdtFlags::IS_TUPLE_STRUCT,
+                DefPathData::StructCtor => flags |= AdtFlags::HAS_CTOR,
                 _ => (),
             }
         }
@@ -2131,12 +2131,6 @@ impl<'a, 'gcx, 'tcx> AdtDef {
         self.flags.contains(AdtFlags::IS_STRUCT)
     }
 
-    /// If this function returns `true`, it implies that `is_struct` must return `true`.
-    #[inline]
-    pub fn is_tuple_struct(&self) -> bool {
-        self.flags.contains(AdtFlags::IS_TUPLE_STRUCT)
-    }
-
     #[inline]
     pub fn is_union(&self) -> bool {
         self.flags.contains(AdtFlags::IS_UNION)
@@ -2181,6 +2175,12 @@ impl<'a, 'gcx, 'tcx> AdtDef {
         }
     }
 
+    /// If this function returns `true`, it implies that `is_struct` must return `true`.
+    #[inline]
+    pub fn has_ctor(&self) -> bool {
+        self.flags.contains(AdtFlags::HAS_CTOR)
+    }
+
     /// Returns whether this type is `#[fundamental]` for the purposes
     /// of coherence checking.
     #[inline]
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index d558558c764..957c8d9f19f 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -5163,7 +5163,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 let adt_def = ty.ty_adt_def();
 
                 match adt_def {
-                    Some(adt_def) if adt_def.is_tuple_struct() => {
+                    Some(adt_def) if adt_def.has_ctor() => {
                         let variant = adt_def.non_enum_variant();
                         new_def = Def::StructCtor(variant.did, variant.ctor_kind);
                         (variant.did, self.tcx.type_of(variant.did))
@@ -5176,8 +5176,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                                 AdtKind::Enum => {
                                     err.note("did you mean to use one of the enum's variants?");
                                 },
-                                AdtKind::Union => {},
-                                AdtKind::Struct => {
+                                AdtKind::Struct |
+                                AdtKind::Union => {
                                     err.span_label(
                                         span,
                                         format!("did you mean `Self {{ /* fields */ }}`?"),