Skip to content

Commit 5cee578

Browse files
committed
Removed dead structures after changes to PartialOrd/Ord derivings.
Remove the `NonMatchesExplode` variant now that no deriving impl uses it. Removed `EnumNonMatching` entirely. Remove now irrelevant `on_matching` field and `HandleNonMatchingEnums` type. Removed unused `EnumNonMatchFunc` type def. Drive-by: revise `EnumNonMatchCollapsedFunc` doc. Made all calls to `expand_enum_method_body` go directly to `build_enum_match_tuple`. Alpha-rename `enum_nonmatch_g` back to `enum_nonmatch_f` to reduce overall diff noise. Inline sole call of `some_ordering_const`. Inline sole call of `ordering_const`. Removed a bunch of code that became dead after the above changes.
1 parent c8ae446 commit 5cee578

File tree

14 files changed

+29
-352
lines changed

14 files changed

+29
-352
lines changed

src/libsyntax/ext/deriving/clone.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
3939
args: Vec::new(),
4040
ret_ty: Self,
4141
attributes: attrs,
42-
on_nonmatching: NonMatchHandlingIrrelevant,
4342
combine_substructure: combine_substructure(|c, s, sub| {
4443
cs_clone("Clone", c, s, sub)
4544
}),
@@ -69,7 +68,7 @@ fn cs_clone(
6968
ctor_ident = variant.node.name;
7069
all_fields = af;
7170
},
72-
EnumNonMatching(..) | EnumNonMatchingCollapsed (..) => {
71+
EnumNonMatchingCollapsed (..) => {
7372
cx.span_bug(trait_span,
7473
format!("non-matching enum variants in \
7574
`deriving({})`",

src/libsyntax/ext/deriving/cmp/eq.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
2727
// any fields are not equal or if the enum variants are different
2828
fn cs_eq(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> Gc<Expr> {
2929
cs_and(|cx, span, _, _| cx.expr_bool(span, false),
30-
|cx, span, _, _| cx.expr_bool(span, false),
31-
cx, span, substr)
30+
cx, span, substr)
3231
}
3332
fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> Gc<Expr> {
3433
cs_or(|cx, span, _, _| cx.expr_bool(span, true),
35-
|cx, span, _, _| cx.expr_bool(span, true),
3634
cx, span, substr)
3735
}
3836

@@ -47,7 +45,6 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
4745
args: vec!(borrowed_self()),
4846
ret_ty: Literal(Path::new(vec!("bool"))),
4947
attributes: attrs,
50-
on_nonmatching: NonMatchesCollapse,
5148
combine_substructure: combine_substructure(|a, b, c| {
5249
$f(a, b, c)
5350
})

src/libsyntax/ext/deriving/cmp/ord.rs

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
3535
args: vec!(borrowed_self()),
3636
ret_ty: Literal(Path::new(vec!("bool"))),
3737
attributes: attrs,
38-
on_nonmatching: NonMatchesCollapseWithTags,
3938
combine_substructure: combine_substructure(|cx, span, substr| {
4039
cs_op($op, $equal, cx, span, substr)
4140
})
@@ -59,7 +58,6 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
5958
args: vec![borrowed_self()],
6059
ret_ty: ret_ty,
6160
attributes: attrs,
62-
on_nonmatching: NonMatchesCollapseWithTags,
6361
combine_substructure: combine_substructure(|cx, span, substr| {
6462
cs_partial_cmp(cx, span, substr)
6563
})
@@ -82,20 +80,6 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
8280
trait_def.expand(cx, mitem, item, push)
8381
}
8482

85-
pub fn some_ordering_const(cx: &mut ExtCtxt, span: Span, cnst: Ordering) -> Gc<ast::Expr> {
86-
let cnst = match cnst {
87-
Less => "Less",
88-
Equal => "Equal",
89-
Greater => "Greater"
90-
};
91-
let ordering = cx.path_global(span,
92-
vec!(cx.ident_of("std"),
93-
cx.ident_of("cmp"),
94-
cx.ident_of(cnst)));
95-
let ordering = cx.expr_path(ordering);
96-
cx.expr_some(span, ordering)
97-
}
98-
9983
pub enum OrderingOp {
10084
PartialCmpOp, LtOp, LeOp, GtOp, GeOp,
10185
}
@@ -117,7 +101,12 @@ pub fn some_ordering_collapsed(cx: &mut ExtCtxt,
117101
pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
118102
substr: &Substructure) -> Gc<Expr> {
119103
let test_id = cx.ident_of("__test");
120-
let equals_expr = some_ordering_const(cx, span, Equal);
104+
let ordering = cx.path_global(span,
105+
vec!(cx.ident_of("std"),
106+
cx.ident_of("cmp"),
107+
cx.ident_of("Equal")));
108+
let ordering = cx.expr_path(ordering);
109+
let equals_expr = cx.expr_some(span, ordering);
121110

122111
/*
123112
Builds:
@@ -159,15 +148,6 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
159148
cx.expr_block(cx.block(span, vec!(assign), Some(if_)))
160149
},
161150
equals_expr.clone(),
162-
|cx, span, list, _| {
163-
match list {
164-
// an earlier nonmatching variant is Less than a
165-
// later one.
166-
[(self_var, _, _), (other_var, _, _)] =>
167-
some_ordering_const(cx, span, self_var.cmp(&other_var)),
168-
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`"),
169-
}
170-
},
171151
|cx, span, (self_args, tag_tuple), _non_self_args| {
172152
if self_args.len() != 2 {
173153
cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`")
@@ -216,21 +196,6 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, span: Span,
216196
cx.expr_binary(span, ast::BiOr, cmp, and)
217197
},
218198
cx.expr_bool(span, equal),
219-
|cx, span, args, _| {
220-
// nonmatching enums, order by the order the variants are
221-
// written
222-
match args {
223-
[(self_var, _, _),
224-
(other_var, _, _)] =>
225-
cx.expr_bool(span,
226-
if less {
227-
self_var < other_var
228-
} else {
229-
self_var > other_var
230-
}),
231-
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`")
232-
}
233-
},
234199
|cx, span, (self_args, tag_tuple), _non_self_args| {
235200
if self_args.len() != 2 {
236201
cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`")

src/libsyntax/ext/deriving/cmp/totaleq.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
3232
let block = cx.block(span, stmts, None);
3333
cx.expr_block(block)
3434
},
35-
|cx, sp, _, _| cx.span_bug(sp, "non matching enums in deriving(Eq)?"),
3635
|cx, sp, _, _| cx.span_bug(sp, "non matching enums in deriving(Eq)?"),
3736
cx,
3837
span,
@@ -58,7 +57,6 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
5857
args: vec!(),
5958
ret_ty: nil_ty(),
6059
attributes: attrs,
61-
on_nonmatching: NonMatchesCollapse,
6260
combine_substructure: combine_substructure(|a, b, c| {
6361
cs_total_eq_assert(a, b, c)
6462
})

src/libsyntax/ext/deriving/cmp/totalord.rs

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use ext::deriving::generic::*;
1717
use ext::deriving::generic::ty::*;
1818
use parse::token::InternedString;
1919

20-
use std::cmp::{Ordering, Equal, Less, Greater};
2120
use std::gc::Gc;
2221

2322
pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
@@ -41,7 +40,6 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
4140
args: vec!(borrowed_self()),
4241
ret_ty: Literal(Path::new(vec!("std", "cmp", "Ordering"))),
4342
attributes: attrs,
44-
on_nonmatching: NonMatchesCollapseWithTags,
4543
combine_substructure: combine_substructure(|a, b, c| {
4644
cs_cmp(a, b, c)
4745
}),
@@ -53,18 +51,6 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
5351
}
5452

5553

56-
pub fn ordering_const(cx: &mut ExtCtxt, span: Span, cnst: Ordering) -> ast::Path {
57-
let cnst = match cnst {
58-
Less => "Less",
59-
Equal => "Equal",
60-
Greater => "Greater"
61-
};
62-
cx.path_global(span,
63-
vec!(cx.ident_of("std"),
64-
cx.ident_of("cmp"),
65-
cx.ident_of(cnst)))
66-
}
67-
6854
pub fn ordering_collapsed(cx: &mut ExtCtxt,
6955
span: Span,
7056
self_arg_tags: &[ast::Ident]) -> Gc<ast::Expr> {
@@ -76,7 +62,10 @@ pub fn ordering_collapsed(cx: &mut ExtCtxt,
7662
pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
7763
substr: &Substructure) -> Gc<Expr> {
7864
let test_id = cx.ident_of("__test");
79-
let equals_path = ordering_const(cx, span, Equal);
65+
let equals_path = cx.path_global(span,
66+
vec!(cx.ident_of("std"),
67+
cx.ident_of("cmp"),
68+
cx.ident_of("Equal")));
8069

8170
/*
8271
Builds:
@@ -118,18 +107,6 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
118107
cx.expr_block(cx.block(span, vec!(assign), Some(if_)))
119108
},
120109
cx.expr_path(equals_path.clone()),
121-
|cx, span, list, _| {
122-
match list {
123-
// an earlier nonmatching variant is Less than a
124-
// later one.
125-
[(self_var, _, _),
126-
(other_var, _, _)] => {
127-
let order = ordering_const(cx, span, self_var.cmp(&other_var));
128-
cx.expr_path(order)
129-
}
130-
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`")
131-
}
132-
},
133110
|cx, span, (self_args, tag_tuple), _non_self_args| {
134111
if self_args.len() != 2 {
135112
cx.span_bug(span, "not exactly 2 arguments in `deriving(TotalOrd)`")

src/libsyntax/ext/deriving/decodable.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
5454
vec!(box Self,
5555
box Literal(Path::new_local("__E"))), true)),
5656
attributes: Vec::new(),
57-
on_nonmatching: NonMatchHandlingIrrelevant,
5857
combine_substructure: combine_substructure(|a, b, c| {
5958
decodable_substructure(a, b, c)
6059
}),

src/libsyntax/ext/deriving/default.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
3939
args: Vec::new(),
4040
ret_ty: Self,
4141
attributes: attrs,
42-
on_nonmatching: NonMatchHandlingIrrelevant,
4342
combine_substructure: combine_substructure(|a, b, c| {
4443
default_substructure(a, b, c)
4544
})

src/libsyntax/ext/deriving/encodable.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
121121
box Literal(Path::new_local("__E"))),
122122
true)),
123123
attributes: Vec::new(),
124-
on_nonmatching: NonMatchHandlingIrrelevant,
125124
combine_substructure: combine_substructure(|a, b, c| {
126125
encodable_substructure(a, b, c)
127126
}),

0 commit comments

Comments
 (0)