diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-04-21 23:25:18 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-04-23 10:03:43 -0700 |
| commit | 823c7eee6a040862abb5a5309693030394200e62 (patch) | |
| tree | 348049a75e563b2fe9e9478dea3927578accbb9c /src/libsyntax/ext | |
| parent | b4ecbe93401a56181baaffc4ff7e275aeecc5182 (diff) | |
| download | rust-823c7eee6a040862abb5a5309693030394200e62.tar.gz rust-823c7eee6a040862abb5a5309693030394200e62.zip | |
Fix other bugs with new closure borrowing
This fixes various issues throughout the standard distribution and tests.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/deriving/clone.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/eq.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/ord.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/totaleq.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/totalord.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/decodable.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/default.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/encodable.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/hash.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/primitive.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/rand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/show.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/zero.rs | 8 |
14 files changed, 55 insertions, 19 deletions
diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 367accb4b19..e0b493cd8d9 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -34,7 +34,9 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt, ret_ty: Self, inline: true, const_nonmatching: false, - combine_substructure: |c, s, sub| cs_clone("Clone", c, s, sub) + combine_substructure: combine_substructure(|c, s, sub| { + cs_clone("Clone", c, s, sub) + }), } ) }; diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index 975b8885de7..35b7e7c1a66 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -40,7 +40,9 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, ret_ty: Literal(Path::new(vec!("bool"))), inline: true, const_nonmatching: true, - combine_substructure: $f + 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 5605c0b6107..afe2d3dae6a 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -30,7 +30,9 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, ret_ty: Literal(Path::new(vec!("bool"))), inline: true, const_nonmatching: false, - combine_substructure: |cx, span, substr| cs_op($op, $equal, cx, span, substr) + combine_substructure: combine_substructure(|cx, span, substr| { + cs_op($op, $equal, cx, span, substr) + }) } } ); diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index 33512b3df5e..d161f966850 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -48,7 +48,9 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, ret_ty: nil_ty(), inline: true, const_nonmatching: true, - combine_substructure: cs_total_eq_assert + 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 a584f8abe05..69c413890e9 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -37,7 +37,9 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt, ret_ty: Literal(Path::new(vec!("std", "cmp", "Ordering"))), inline: true, const_nonmatching: false, - combine_substructure: cs_cmp + combine_substructure: combine_substructure(|a, b, c| { + cs_cmp(a, b, c) + }), } ) }; diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 579de82c8db..9dc52442d29 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -51,7 +51,9 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt, vec!(~Self, ~Literal(Path::new_local("__E"))), true)), inline: false, const_nonmatching: true, - combine_substructure: decodable_substructure, + combine_substructure: combine_substructure(|a, b, c| { + decodable_substructure(a, b, c) + }), }) }; diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs index 94675f91e9d..633674eff5c 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -34,7 +34,9 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt, ret_ty: Self, inline: true, const_nonmatching: false, - combine_substructure: default_substructure + combine_substructure: combine_substructure(|a, b, c| { + default_substructure(a, b, c) + }) }) }; trait_def.expand(cx, mitem, item, push) diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 1c3edce96fb..0691b39f354 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -122,7 +122,9 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt, true)), inline: false, const_nonmatching: true, - combine_substructure: encodable_substructure, + combine_substructure: combine_substructure(|a, b, c| { + encodable_substructure(a, b, c) + }), }) }; diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 1d4aa08f9e3..449525d9032 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -177,6 +177,8 @@ StaticEnum(<ast::EnumDef of C>, ~[(<ident of C0>, <span of C0>, Unnamed(~[<span */ +use std::cell::RefCell; + use ast; use ast::{P, EnumDef, Expr, Ident, Generics, StructDef}; use ast_util; @@ -234,7 +236,7 @@ pub struct MethodDef<'a> { /// actual enum variants, i.e. can use _ => .. match. pub const_nonmatching: bool, - pub combine_substructure: CombineSubstructureFunc<'a>, + pub combine_substructure: RefCell<CombineSubstructureFunc<'a>>, } /// All the data about the data structure/method being derived upon. @@ -317,6 +319,11 @@ pub type EnumNonMatchFunc<'a> = &[@Expr]|: 'a -> @Expr; +pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>) + -> RefCell<CombineSubstructureFunc<'a>> { + RefCell::new(f) +} + impl<'a> TraitDef<'a> { pub fn expand(&self, @@ -505,8 +512,9 @@ impl<'a> MethodDef<'a> { nonself_args: nonself_args, fields: fields }; - (self.combine_substructure)(cx, trait_.span, - &substructure) + let mut f = self.combine_substructure.borrow_mut(); + let f: &mut CombineSubstructureFunc = &mut *f; + (*f)(cx, trait_.span, &substructure) } fn get_ret_ty(&self, diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs index 23331dc03cb..587c48ef487 100644 --- a/src/libsyntax/ext/deriving/hash.rs +++ b/src/libsyntax/ext/deriving/hash.rs @@ -48,7 +48,9 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, ret_ty: nil_ty(), inline: true, const_nonmatching: false, - combine_substructure: hash_substructure + combine_substructure: combine_substructure(|a, b, c| { + hash_substructure(a, b, c) + }) } ) }; diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index 267a12fdff9..e42a3c67e34 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -41,7 +41,9 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, // liable to cause code-bloat inline: true, const_nonmatching: false, - combine_substructure: |c, s, sub| cs_from("i64", c, s, sub), + combine_substructure: combine_substructure(|c, s, sub| { + cs_from("i64", c, s, sub) + }), }, MethodDef { name: "from_u64", @@ -56,7 +58,9 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, // liable to cause code-bloat inline: true, const_nonmatching: false, - combine_substructure: |c, s, sub| cs_from("u64", c, s, sub), + combine_substructure: combine_substructure(|c, s, sub| { + cs_from("u64", c, s, sub) + }), }) }; diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 6b824e52bb3..83ceef0a39c 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -42,7 +42,9 @@ pub fn expand_deriving_rand(cx: &mut ExtCtxt, ret_ty: Self, inline: false, const_nonmatching: false, - combine_substructure: rand_substructure + combine_substructure: combine_substructure(|a, b, c| { + rand_substructure(a, b, c) + }) } ) }; diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs index 067958e4bde..7098d0dd6ef 100644 --- a/src/libsyntax/ext/deriving/show.rs +++ b/src/libsyntax/ext/deriving/show.rs @@ -44,7 +44,9 @@ pub fn expand_deriving_show(cx: &mut ExtCtxt, ret_ty: Literal(Path::new(vec!("std", "fmt", "Result"))), inline: false, const_nonmatching: false, - combine_substructure: show_substructure + combine_substructure: combine_substructure(|a, b, c| { + show_substructure(a, b, c) + }) } ) }; diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index 10692bd7f93..0aeeabcaeab 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -34,7 +34,9 @@ pub fn expand_deriving_zero(cx: &mut ExtCtxt, ret_ty: Self, inline: true, const_nonmatching: false, - combine_substructure: zero_substructure + combine_substructure: combine_substructure(|a, b, c| { + zero_substructure(a, b, c) + }) }, MethodDef { name: "is_zero", @@ -44,13 +46,13 @@ pub fn expand_deriving_zero(cx: &mut ExtCtxt, ret_ty: Literal(Path::new(vec!("bool"))), inline: true, const_nonmatching: false, - combine_substructure: |cx, span, substr| { + combine_substructure: combine_substructure(|cx, span, substr| { cs_and(|cx, span, _, _| cx.span_bug(span, "Non-matching enum \ variant in \ deriving(Zero)"), cx, span, substr) - } + }) } ) }; |
