about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2016-08-26 19:23:42 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2016-09-13 23:33:50 +0300
commit4b6c4c08df7f4685daf0fa2cfe127b06216176d6 (patch)
tree90d6650d2522f2253c86672042b6806bfe5987c4
parentc87ba3f1222ba20d491e8ed76a04977283280742 (diff)
downloadrust-4b6c4c08df7f4685daf0fa2cfe127b06216176d6.tar.gz
rust-4b6c4c08df7f4685daf0fa2cfe127b06216176d6.zip
Remove some ancient code providing special support for newtypes
-rw-r--r--src/librustc/middle/mem_categorization.rs4
-rw-r--r--src/librustc_metadata/encoder.rs28
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs4
-rw-r--r--src/librustc_trans/adt.rs2
-rw-r--r--src/librustdoc/clean/inline.rs11
-rw-r--r--src/librustdoc/doctree.rs21
-rw-r--r--src/librustdoc/html/render.rs2
7 files changed, 16 insertions, 56 deletions
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs
index 39d5487e8be..5594ac413e2 100644
--- a/src/librustc/middle/mem_categorization.rs
+++ b/src/librustc/middle/mem_categorization.rs
@@ -223,10 +223,6 @@ fn deref_kind(t: Ty, context: DerefKindContext) -> McResult<deref_kind> {
             Ok(deref_ptr(UnsafePtr(mt.mutbl)))
         }
 
-        ty::TyAdt(..) => { // newtype
-            Ok(deref_interior(InteriorField(PositionalField(0))))
-        }
-
         ty::TyArray(..) | ty::TySlice(_) => {
             // no deref of indexed content without supplying InteriorOffsetKind
             if let Some(context) = context {
diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs
index 603b7a483b9..e228bf74302 100644
--- a/src/librustc_metadata/encoder.rs
+++ b/src/librustc_metadata/encoder.rs
@@ -252,27 +252,6 @@ impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> {
     }
 }
 
-/// Iterates through "auxiliary node IDs", which are node IDs that describe
-/// top-level items that are sub-items of the given item. Specifically:
-///
-/// * For newtype structs, iterates through the node ID of the constructor.
-fn each_auxiliary_node_id<F>(item: &hir::Item, callback: F) -> bool where
-    F: FnOnce(NodeId) -> bool,
-{
-    let mut continue_ = true;
-    match item.node {
-        hir::ItemStruct(ref struct_def, _) => {
-            // If this is a newtype struct, return the constructor.
-            if struct_def.is_tuple() {
-                continue_ = callback(struct_def.id());
-            }
-        }
-        _ => {}
-    }
-
-    continue_
-}
-
 fn encode_reexports(ecx: &EncodeContext,
                     rbml_w: &mut Encoder,
                     id: NodeId) {
@@ -313,13 +292,6 @@ impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> {
         for item_id in &md.item_ids {
             self.rbml_w.wr_tagged_u64(tag_mod_child,
                                  def_to_u64(ecx.tcx.map.local_def_id(item_id.id)));
-
-            let item = ecx.tcx.map.expect_item(item_id.id);
-            each_auxiliary_node_id(item, |auxiliary_node_id| {
-                self.rbml_w.wr_tagged_u64(tag_mod_child,
-                                     def_to_u64(ecx.tcx.map.local_def_id(auxiliary_node_id)));
-                true
-            });
         }
 
         self.encode_visibility(vis);
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index ad750ccc012..83f03e7cfc5 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -261,8 +261,8 @@ impl<'b> Resolver<'b> {
                 let def = Def::Struct(self.definitions.local_def_id(item.id));
                 self.define(parent, name, TypeNS, (def, sp, vis));
 
-                // If this is a newtype or unit-like struct, define a name
-                // in the value namespace as well
+                // If this is a tuple or unit struct, define a name
+                // in the value namespace as well.
                 if !struct_def.is_struct() {
                     let def = Def::Struct(self.definitions.local_def_id(struct_def.id()));
                     self.define(parent, name, ValueNS, (def, sp, vis));
diff --git a/src/librustc_trans/adt.rs b/src/librustc_trans/adt.rs
index e8498363e45..67e5ec2616d 100644
--- a/src/librustc_trans/adt.rs
+++ b/src/librustc_trans/adt.rs
@@ -231,7 +231,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                 }
 
                 if cases.len() == 1 && hint == attr::ReprAny {
-                    // Equivalent to a struct/tuple/newtype.
+                    // Equivalent to a struct or tuple.
                     return Univariant(mk_struct(cx, &cases[0].tys, false, t));
                 }
 
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index f1b907e70d7..709e3698924 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -19,7 +19,7 @@ use rustc::middle::cstore;
 use rustc::hir::def::Def;
 use rustc::hir::def_id::DefId;
 use rustc::hir::print as pprust;
-use rustc::ty::{self, TyCtxt};
+use rustc::ty::{self, TyCtxt, VariantKind};
 use rustc::util::nodemap::FnvHashSet;
 
 use rustc_const_eval::lookup_const_by_id;
@@ -207,11 +207,10 @@ fn build_struct<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let variant = tcx.lookup_adt_def(did).struct_variant();
 
     clean::Struct {
-        struct_type: match &variant.fields[..] {
-            &[] => doctree::Unit,
-            &[_] if variant.kind == ty::VariantKind::Tuple => doctree::Newtype,
-            &[..] if variant.kind == ty::VariantKind::Tuple => doctree::Tuple,
-            _ => doctree::Plain,
+        struct_type: match variant.kind {
+            VariantKind::Struct => doctree::Plain,
+            VariantKind::Tuple => doctree::Tuple,
+            VariantKind::Unit => doctree::Unit,
         },
         generics: (t.generics, &predicates).clean(cx),
         fields: variant.fields.clean(cx),
diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs
index cc62fcfa0aa..c2404f4294e 100644
--- a/src/librustdoc/doctree.rs
+++ b/src/librustdoc/doctree.rs
@@ -82,14 +82,12 @@ impl Module {
 
 #[derive(Debug, Clone, RustcEncodable, RustcDecodable, Copy)]
 pub enum StructType {
-    /// A normal struct
+    /// A braced struct
     Plain,
     /// A tuple struct
     Tuple,
-    /// A newtype struct (tuple struct with one element)
-    Newtype,
     /// A unit struct
-    Unit
+    Unit,
 }
 
 pub enum TypeBound {
@@ -262,15 +260,10 @@ pub struct Import {
     pub whence: Span,
 }
 
-pub fn struct_type_from_def(sd: &hir::VariantData) -> StructType {
-    if !sd.is_struct() {
-        // We are in a tuple-struct
-        match sd.fields().len() {
-            0 => Unit,
-            1 => Newtype,
-            _ => Tuple
-        }
-    } else {
-        Plain
+pub fn struct_type_from_def(vdata: &hir::VariantData) -> StructType {
+    match *vdata {
+        hir::VariantData::Struct(..) => Plain,
+        hir::VariantData::Tuple(..) => Tuple,
+        hir::VariantData::Unit(..) => Unit,
     }
 }
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 6da7423edb8..df6b3239cd8 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -2537,7 +2537,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
             }
             write!(w, "}}")?;
         }
-        doctree::Tuple | doctree::Newtype => {
+        doctree::Tuple => {
             write!(w, "(")?;
             for (i, field) in fields.iter().enumerate() {
                 if i > 0 {