about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src/deriving
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-06-30 10:22:41 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-07-01 15:19:49 +1000
commit85e8d94e05959e3ad57738351ce56f95f15a26a6 (patch)
tree318e8265030e7e50a8a64f32a29af3a9f11cbb5e /compiler/rustc_builtin_macros/src/deriving
parent00307a5b6f1d81fb5d19f1ef7235ff235ce75d50 (diff)
downloadrust-85e8d94e05959e3ad57738351ce56f95f15a26a6.tar.gz
rust-85e8d94e05959e3ad57738351ce56f95f15a26a6.zip
Change `Ty::Tuple` to `Ty::Unit`.
Because that's all that is needed in practice.
Diffstat (limited to 'compiler/rustc_builtin_macros/src/deriving')
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs2
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/encodable.rs2
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/generic/ty.rs16
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/hash.rs2
4 files changed, 8 insertions, 14 deletions
diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
index caf4d3a5f77..cb2ad283a19 100644
--- a/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
@@ -33,7 +33,7 @@ pub fn expand_deriving_eq(
             generics: Bounds::empty(),
             explicit_self: true,
             args: vec![],
-            ret_ty: nil_ty(),
+            ret_ty: Unit,
             attributes: attrs,
             unify_fieldless_variants: true,
             combine_substructure: combine_substructure(Box::new(|a, b, c| {
diff --git a/compiler/rustc_builtin_macros/src/deriving/encodable.rs b/compiler/rustc_builtin_macros/src/deriving/encodable.rs
index 7cce1a0c2a2..7dc0584618d 100644
--- a/compiler/rustc_builtin_macros/src/deriving/encodable.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/encodable.rs
@@ -125,7 +125,7 @@ pub fn expand_deriving_rustc_encodable(
             ret_ty: Path(Path::new_(
                 pathvec_std!(result::Result),
                 vec![
-                    Box::new(Tuple(Vec::new())),
+                    Box::new(Unit),
                     Box::new(Path(Path::new_(vec![typaram, sym::Error], vec![], PathKind::Local))),
                 ],
                 PathKind::Std,
diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs b/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs
index c2dcff36c39..4b20d87629d 100644
--- a/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs
@@ -78,18 +78,14 @@ pub enum Ty {
     /// `mod::mod::Type<[lifetime], [Params...]>`, including a plain type
     /// parameter, and things like `i32`
     Path(Path),
-    /// includes unit
-    Tuple(Vec<Ty>),
+    /// For () return types.
+    Unit,
 }
 
 pub fn self_ref() -> Ty {
     Ref(Box::new(Self_), ast::Mutability::Not)
 }
 
-pub fn nil_ty() -> Ty {
-    Tuple(Vec::new())
-}
-
 impl Ty {
     pub fn to_ty(
         &self,
@@ -105,10 +101,8 @@ impl Ty {
             }
             Path(p) => p.to_ty(cx, span, self_ty, self_generics),
             Self_ => cx.ty_path(self.to_path(cx, span, self_ty, self_generics)),
-            Tuple(fields) => {
-                let ty = ast::TyKind::Tup(
-                    fields.iter().map(|f| f.to_ty(cx, span, self_ty, self_generics)).collect(),
-                );
+            Unit => {
+                let ty = ast::TyKind::Tup(vec![]);
                 cx.ty(span, ty)
             }
         }
@@ -143,7 +137,7 @@ impl Ty {
             }
             Path(ref p) => p.to_path(cx, span, self_ty, generics),
             Ref(..) => cx.span_bug(span, "ref in a path in generic `derive`"),
-            Tuple(..) => cx.span_bug(span, "tuple in a path in generic `derive`"),
+            Unit => cx.span_bug(span, "unit in a path in generic `derive`"),
         }
     }
 }
diff --git a/compiler/rustc_builtin_macros/src/deriving/hash.rs b/compiler/rustc_builtin_macros/src/deriving/hash.rs
index 641744c47ce..9790449c4b3 100644
--- a/compiler/rustc_builtin_macros/src/deriving/hash.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/hash.rs
@@ -32,7 +32,7 @@ pub fn expand_deriving_hash(
             generics: Bounds { bounds: vec![(typaram, vec![path_std!(hash::Hasher)])] },
             explicit_self: true,
             args: vec![(Ref(Box::new(Path(arg)), Mutability::Mut), sym::state)],
-            ret_ty: nil_ty(),
+            ret_ty: Unit,
             attributes: vec![],
             unify_fieldless_variants: true,
             combine_substructure: combine_substructure(Box::new(|a, b, c| {