From c8ae44682d76bb40eb1471eeb42603eaecd0b392 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Sun, 6 Jul 2014 21:19:12 +0200 Subject: `O(n*k)` code-size deriving on enums (better than previous `O(n^k)`). In the above formulas, `n` is the number of variants, and `k` is the number of self-args fed into deriving. In the particular case of interest (namely `PartialOrd` and `Ord`), `k` is always 2, so we are basically comparing `O(n)` versus `O(n^2)`. Also, the stage is set for having *all* enum deriving codes go through `build_enum_match_tuple` and getting rid of `build_enum_match`. Also, seriously attempted to clean up the code itself. Added a bunch of comments attempting to document what I learned as I worked through the original code and adapted it to this new strategy. --- src/libsyntax/ext/deriving/zero.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/libsyntax/ext/deriving/zero.rs') diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index 1d4f4c78fc0..59a0d1ed5ce 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -57,6 +57,10 @@ pub fn expand_deriving_zero(cx: &mut ExtCtxt, "Non-matching enum \ variant in \ deriving(Zero)"), + |cx, span, _, _| cx.span_bug(span, + "Non-matching enum \ + variant in \ + deriving(Zero)"), cx, span, substr) }) } -- cgit 1.4.1-3-g733a5