Skip to content

Commit 85e8d94

Browse files
committed
Change Ty::Tuple to Ty::Unit.
Because that's all that is needed in practice.
1 parent 00307a5 commit 85e8d94

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn expand_deriving_eq(
3333
generics: Bounds::empty(),
3434
explicit_self: true,
3535
args: vec![],
36-
ret_ty: nil_ty(),
36+
ret_ty: Unit,
3737
attributes: attrs,
3838
unify_fieldless_variants: true,
3939
combine_substructure: combine_substructure(Box::new(|a, b, c| {

compiler/rustc_builtin_macros/src/deriving/encodable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub fn expand_deriving_rustc_encodable(
125125
ret_ty: Path(Path::new_(
126126
pathvec_std!(result::Result),
127127
vec![
128-
Box::new(Tuple(Vec::new())),
128+
Box::new(Unit),
129129
Box::new(Path(Path::new_(vec![typaram, sym::Error], vec![], PathKind::Local))),
130130
],
131131
PathKind::Std,

compiler/rustc_builtin_macros/src/deriving/generic/ty.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,14 @@ pub enum Ty {
7878
/// `mod::mod::Type<[lifetime], [Params...]>`, including a plain type
7979
/// parameter, and things like `i32`
8080
Path(Path),
81-
/// includes unit
82-
Tuple(Vec<Ty>),
81+
/// For () return types.
82+
Unit,
8383
}
8484

8585
pub fn self_ref() -> Ty {
8686
Ref(Box::new(Self_), ast::Mutability::Not)
8787
}
8888

89-
pub fn nil_ty() -> Ty {
90-
Tuple(Vec::new())
91-
}
92-
9389
impl Ty {
9490
pub fn to_ty(
9591
&self,
@@ -105,10 +101,8 @@ impl Ty {
105101
}
106102
Path(p) => p.to_ty(cx, span, self_ty, self_generics),
107103
Self_ => cx.ty_path(self.to_path(cx, span, self_ty, self_generics)),
108-
Tuple(fields) => {
109-
let ty = ast::TyKind::Tup(
110-
fields.iter().map(|f| f.to_ty(cx, span, self_ty, self_generics)).collect(),
111-
);
104+
Unit => {
105+
let ty = ast::TyKind::Tup(vec![]);
112106
cx.ty(span, ty)
113107
}
114108
}
@@ -143,7 +137,7 @@ impl Ty {
143137
}
144138
Path(ref p) => p.to_path(cx, span, self_ty, generics),
145139
Ref(..) => cx.span_bug(span, "ref in a path in generic `derive`"),
146-
Tuple(..) => cx.span_bug(span, "tuple in a path in generic `derive`"),
140+
Unit => cx.span_bug(span, "unit in a path in generic `derive`"),
147141
}
148142
}
149143
}

compiler/rustc_builtin_macros/src/deriving/hash.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn expand_deriving_hash(
3232
generics: Bounds { bounds: vec![(typaram, vec![path_std!(hash::Hasher)])] },
3333
explicit_self: true,
3434
args: vec![(Ref(Box::new(Path(arg)), Mutability::Mut), sym::state)],
35-
ret_ty: nil_ty(),
35+
ret_ty: Unit,
3636
attributes: vec![],
3737
unify_fieldless_variants: true,
3838
combine_substructure: combine_substructure(Box::new(|a, b, c| {

0 commit comments

Comments
 (0)