diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2014-07-07 09:13:49 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2014-07-11 17:32:23 +0200 |
| commit | 5cee57869c527ee798c8aeb0e17e82fb36848c4f (patch) | |
| tree | c4dc23e67ff6cd75b9d852ed645b50fb51b4d34b /src/libsyntax/ext/deriving/cmp | |
| parent | c8ae44682d76bb40eb1471eeb42603eaecd0b392 (diff) | |
| download | rust-5cee57869c527ee798c8aeb0e17e82fb36848c4f.tar.gz rust-5cee57869c527ee798c8aeb0e17e82fb36848c4f.zip | |
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.
Diffstat (limited to 'src/libsyntax/ext/deriving/cmp')
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/eq.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/ord.rs | 47 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/totaleq.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/totalord.rs | 31 |
4 files changed, 11 insertions, 74 deletions
diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index 3c7f82a315a..19a979a5655 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -27,12 +27,10 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, // any fields are not equal or if the enum variants are different fn cs_eq(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> Gc<Expr> { cs_and(|cx, span, _, _| cx.expr_bool(span, false), - |cx, span, _, _| cx.expr_bool(span, false), - cx, span, substr) + cx, span, substr) } fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> Gc<Expr> { cs_or(|cx, span, _, _| cx.expr_bool(span, true), - |cx, span, _, _| cx.expr_bool(span, true), cx, span, substr) } @@ -47,7 +45,6 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, args: vec!(borrowed_self()), ret_ty: Literal(Path::new(vec!("bool"))), attributes: attrs, - on_nonmatching: NonMatchesCollapse, combine_substructure: combine_substructure(|a, b, c| { $f(a, b, c) }) diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index 52a180deffb..dcf59ba820e 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -35,7 +35,6 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, args: vec!(borrowed_self()), ret_ty: Literal(Path::new(vec!("bool"))), attributes: attrs, - on_nonmatching: NonMatchesCollapseWithTags, combine_substructure: combine_substructure(|cx, span, substr| { cs_op($op, $equal, cx, span, substr) }) @@ -59,7 +58,6 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, args: vec![borrowed_self()], ret_ty: ret_ty, attributes: attrs, - on_nonmatching: NonMatchesCollapseWithTags, combine_substructure: combine_substructure(|cx, span, substr| { cs_partial_cmp(cx, span, substr) }) @@ -82,20 +80,6 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, trait_def.expand(cx, mitem, item, push) } -pub fn some_ordering_const(cx: &mut ExtCtxt, span: Span, cnst: Ordering) -> Gc<ast::Expr> { - let cnst = match cnst { - Less => "Less", - Equal => "Equal", - Greater => "Greater" - }; - let ordering = cx.path_global(span, - vec!(cx.ident_of("std"), - cx.ident_of("cmp"), - cx.ident_of(cnst))); - let ordering = cx.expr_path(ordering); - cx.expr_some(span, ordering) -} - pub enum OrderingOp { PartialCmpOp, LtOp, LeOp, GtOp, GeOp, } @@ -117,7 +101,12 @@ pub fn some_ordering_collapsed(cx: &mut ExtCtxt, pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> Gc<Expr> { let test_id = cx.ident_of("__test"); - let equals_expr = some_ordering_const(cx, span, Equal); + let ordering = cx.path_global(span, + vec!(cx.ident_of("std"), + cx.ident_of("cmp"), + cx.ident_of("Equal"))); + let ordering = cx.expr_path(ordering); + let equals_expr = cx.expr_some(span, ordering); /* Builds: @@ -159,15 +148,6 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span, cx.expr_block(cx.block(span, vec!(assign), Some(if_))) }, equals_expr.clone(), - |cx, span, list, _| { - match list { - // an earlier nonmatching variant is Less than a - // later one. - [(self_var, _, _), (other_var, _, _)] => - some_ordering_const(cx, span, self_var.cmp(&other_var)), - _ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`"), - } - }, |cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { 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, cx.expr_binary(span, ast::BiOr, cmp, and) }, cx.expr_bool(span, equal), - |cx, span, args, _| { - // nonmatching enums, order by the order the variants are - // written - match args { - [(self_var, _, _), - (other_var, _, _)] => - cx.expr_bool(span, - if less { - self_var < other_var - } else { - self_var > other_var - }), - _ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`") - } - }, |cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`") diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index 3a6b1fa218a..42365936c9d 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -33,7 +33,6 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, cx.expr_block(block) }, |cx, sp, _, _| cx.span_bug(sp, "non matching enums in deriving(Eq)?"), - |cx, sp, _, _| cx.span_bug(sp, "non matching enums in deriving(Eq)?"), cx, span, substr) @@ -58,7 +57,6 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, args: vec!(), ret_ty: nil_ty(), attributes: attrs, - on_nonmatching: NonMatchesCollapse, combine_substructure: combine_substructure(|a, b, c| { cs_total_eq_assert(a, b, c) }) diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index 0e4b786857b..e010b635fe4 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -17,7 +17,6 @@ use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token::InternedString; -use std::cmp::{Ordering, Equal, Less, Greater}; use std::gc::Gc; pub fn expand_deriving_totalord(cx: &mut ExtCtxt, @@ -41,7 +40,6 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt, args: vec!(borrowed_self()), ret_ty: Literal(Path::new(vec!("std", "cmp", "Ordering"))), attributes: attrs, - on_nonmatching: NonMatchesCollapseWithTags, combine_substructure: combine_substructure(|a, b, c| { cs_cmp(a, b, c) }), @@ -53,18 +51,6 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt, } -pub fn ordering_const(cx: &mut ExtCtxt, span: Span, cnst: Ordering) -> ast::Path { - let cnst = match cnst { - Less => "Less", - Equal => "Equal", - Greater => "Greater" - }; - cx.path_global(span, - vec!(cx.ident_of("std"), - cx.ident_of("cmp"), - cx.ident_of(cnst))) -} - pub fn ordering_collapsed(cx: &mut ExtCtxt, span: Span, self_arg_tags: &[ast::Ident]) -> Gc<ast::Expr> { @@ -76,7 +62,10 @@ pub fn ordering_collapsed(cx: &mut ExtCtxt, pub fn cs_cmp(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> Gc<Expr> { let test_id = cx.ident_of("__test"); - let equals_path = ordering_const(cx, span, Equal); + let equals_path = cx.path_global(span, + vec!(cx.ident_of("std"), + cx.ident_of("cmp"), + cx.ident_of("Equal"))); /* Builds: @@ -118,18 +107,6 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span, cx.expr_block(cx.block(span, vec!(assign), Some(if_))) }, cx.expr_path(equals_path.clone()), - |cx, span, list, _| { - match list { - // an earlier nonmatching variant is Less than a - // later one. - [(self_var, _, _), - (other_var, _, _)] => { - let order = ordering_const(cx, span, self_var.cmp(&other_var)); - cx.expr_path(order) - } - _ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`") - } - }, |cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `deriving(TotalOrd)`") |
