]> git.lizzy.rs Git - rust.git/commitdiff
syntax: convert deriving to take &mut ExtCtxt.
authorHuon Wilson <dbau.pp+github@gmail.com>
Wed, 5 Feb 2014 21:50:21 +0000 (08:50 +1100)
committerHuon Wilson <dbau.pp+github@gmail.com>
Sat, 8 Feb 2014 02:53:21 +0000 (13:53 +1100)
16 files changed:
src/libsyntax/ext/base.rs
src/libsyntax/ext/deriving/clone.rs
src/libsyntax/ext/deriving/cmp/eq.rs
src/libsyntax/ext/deriving/cmp/ord.rs
src/libsyntax/ext/deriving/cmp/totaleq.rs
src/libsyntax/ext/deriving/cmp/totalord.rs
src/libsyntax/ext/deriving/decodable.rs
src/libsyntax/ext/deriving/default.rs
src/libsyntax/ext/deriving/encodable.rs
src/libsyntax/ext/deriving/generic.rs
src/libsyntax/ext/deriving/iter_bytes.rs
src/libsyntax/ext/deriving/mod.rs
src/libsyntax/ext/deriving/primitive.rs
src/libsyntax/ext/deriving/rand.rs
src/libsyntax/ext/deriving/to_str.rs
src/libsyntax/ext/deriving/zero.rs

index 800eda64d5198d717309d40163ca093a002285e3..848f4ba3871d293f964f6cd99a247352e09ded1b 100644 (file)
@@ -36,7 +36,7 @@ pub struct MacroDef {
 }
 
 pub type ItemDecorator =
-    fn(&ExtCtxt, Span, @ast::MetaItem, ~[@ast::Item]) -> ~[@ast::Item];
+    fn(&mut ExtCtxt, Span, @ast::MetaItem, ~[@ast::Item]) -> ~[@ast::Item];
 
 pub struct BasicMacroExpander {
     expander: MacroExpanderFn,
index 567b89d3453f7e640f5201e499896c1d25a52429..1736124062862d3c705e68e615253a08bb030856 100644 (file)
@@ -14,7 +14,7 @@
 use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 
-pub fn expand_deriving_clone(cx: &ExtCtxt,
+pub fn expand_deriving_clone(cx: &mut ExtCtxt,
                              span: Span,
                              mitem: @MetaItem,
                              in_items: ~[@Item])
@@ -42,7 +42,7 @@ pub fn expand_deriving_clone(cx: &ExtCtxt,
     trait_def.expand(mitem, in_items)
 }
 
-pub fn expand_deriving_deep_clone(cx: &ExtCtxt,
+pub fn expand_deriving_deep_clone(cx: &mut ExtCtxt,
                                   span: Span,
                                   mitem: @MetaItem,
                                   in_items: ~[@Item])
@@ -74,7 +74,7 @@ pub fn expand_deriving_deep_clone(cx: &ExtCtxt,
 
 fn cs_clone(
     name: &str,
-    cx: &ExtCtxt, trait_span: Span,
+    cx: &mut ExtCtxt, trait_span: Span,
     substr: &Substructure) -> @Expr {
     let clone_ident = substr.method_ident;
     let ctor_ident;
index 99b5163214a5e90093dee33c50d0a77f742627a8..a469c4a960b4013bb41f7f5fe094c5ffdf08c014 100644 (file)
 use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 
-pub fn expand_deriving_eq(cx: &ExtCtxt,
+pub fn expand_deriving_eq(cx: &mut ExtCtxt,
                           span: Span,
                           mitem: @MetaItem,
                           in_items: ~[@Item]) -> ~[@Item] {
     // structures are equal if all fields are equal, and non equal, if
     // any fields are not equal or if the enum variants are different
-    fn cs_eq(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
+    fn cs_eq(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
         cs_and(|cx, span, _, _| cx.expr_bool(span, false),
                                  cx, span, substr)
     }
-    fn cs_ne(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
+    fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
         cs_or(|cx, span, _, _| cx.expr_bool(span, true),
               cx, span, substr)
     }
index 5a02d8eead85c9b847a13998a39d3fd1a4955e07..83f623e30666d0797bb1220b54400010ff1747c2 100644 (file)
@@ -15,7 +15,7 @@
 use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 
-pub fn expand_deriving_ord(cx: &ExtCtxt,
+pub fn expand_deriving_ord(cx: &mut ExtCtxt,
                            span: Span,
                            mitem: @MetaItem,
                            in_items: ~[@Item]) -> ~[@Item] {
@@ -51,7 +51,7 @@ macro_rules! md (
 }
 
 /// Strict inequality.
-fn cs_op(less: bool, equal: bool, cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
+fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
     let op = if less {ast::BiLt} else {ast::BiGt};
     cs_fold(
         false, // need foldr,
index 6a1aaeb2f9eaaddcd79da6e90a2c3eb2f4e64df1..0a38a2ce30dc877cb4d6f3876d67c6cce8dbb367 100644 (file)
 use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 
-pub fn expand_deriving_totaleq(cx: &ExtCtxt,
+pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
                                span: Span,
                                mitem: @MetaItem,
                                in_items: ~[@Item]) -> ~[@Item] {
-    fn cs_equals(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
+    fn cs_equals(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
         cs_and(|cx, span, _, _| cx.expr_bool(span, false),
                cx, span, substr)
     }
index f1e360f20ba0c918d9d8935449cc552ba4f886b8..27a766c0e7562f759364364ea08541dea1a8af77 100644 (file)
@@ -16,7 +16,7 @@
 use ext::deriving::generic::*;
 use std::cmp::{Ordering, Equal, Less, Greater};
 
-pub fn expand_deriving_totalord(cx: &ExtCtxt,
+pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
                                 span: Span,
                                 mitem: @MetaItem,
                                 in_items: ~[@Item]) -> ~[@Item] {
@@ -44,7 +44,7 @@ pub fn expand_deriving_totalord(cx: &ExtCtxt,
 }
 
 
-pub fn ordering_const(cx: &ExtCtxt, span: Span, cnst: Ordering) -> ast::Path {
+pub fn ordering_const(cx: &mut ExtCtxt, span: Span, cnst: Ordering) -> ast::Path {
     let cnst = match cnst {
         Less => "Less",
         Equal => "Equal",
@@ -56,7 +56,7 @@ pub fn ordering_const(cx: &ExtCtxt, span: Span, cnst: Ordering) -> ast::Path {
                      cx.ident_of(cnst)])
 }
 
-pub fn cs_cmp(cx: &ExtCtxt, span: Span,
+pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
               substr: &Substructure) -> @Expr {
     let test_id = cx.ident_of("__test");
     let equals_path = ordering_const(cx, span, Equal);
@@ -106,8 +106,10 @@ pub fn cs_cmp(cx: &ExtCtxt, span: Span,
                 // an earlier nonmatching variant is Less than a
                 // later one.
                 [(self_var, _, _),
-                 (other_var, _, _)] => cx.expr_path(ordering_const(cx, span,
-                                                                   self_var.cmp(&other_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(TotalOrd)`")
             }
         },
index ad7b3a2e950ae0c815abfdc5ea87852686294d01..7324500a8a0eb91fc72540b57f6accbd4192cdd6 100644 (file)
@@ -21,7 +21,7 @@
 use parse::token::InternedString;
 use parse::token;
 
-pub fn expand_deriving_decodable(cx: &ExtCtxt,
+pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
                                  span: Span,
                                  mitem: @MetaItem,
                                  in_items: ~[@Item]) -> ~[@Item] {
@@ -53,7 +53,7 @@ pub fn expand_deriving_decodable(cx: &ExtCtxt,
     trait_def.expand(mitem, in_items)
 }
 
-fn decodable_substructure(cx: &ExtCtxt, trait_span: Span,
+fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
                           substr: &Substructure) -> @Expr {
     let decoder = substr.nonself_args[0];
     let recurse = ~[cx.ident_of("serialize"),
@@ -77,7 +77,7 @@ fn decodable_substructure(cx: &ExtCtxt, trait_span: Span,
                                               trait_span,
                                               substr.type_ident,
                                               summary,
-                                              |span, name, field| {
+                                              |cx, span, name, field| {
                 cx.expr_method_call(span, blkdecoder, read_struct_field,
                                     ~[cx.expr_str(span, name),
                                       cx.expr_uint(span, field),
@@ -108,10 +108,10 @@ fn decodable_substructure(cx: &ExtCtxt, trait_span: Span,
                                                    v_span,
                                                    name,
                                                    parts,
-                                                   |span, _, field| {
+                                                   |cx, span, _, field| {
+                    let idx = cx.expr_uint(span, field);
                     cx.expr_method_call(span, blkdecoder, rvariant_arg,
-                                        ~[cx.expr_uint(span, field),
-                                          lambdadecode])
+                                        ~[idx, lambdadecode])
                 });
 
                 arms.push(cx.arm(v_span,
@@ -143,11 +143,11 @@ fn decodable_substructure(cx: &ExtCtxt, trait_span: Span,
 /// Create a decoder for a single enum variant/struct:
 /// - `outer_pat_ident` is the name of this enum variant/struct
 /// - `getarg` should retrieve the `uint`-th field with name `@str`.
-fn decode_static_fields(cx: &ExtCtxt,
+fn decode_static_fields(cx: &mut ExtCtxt,
                         trait_span: Span,
                         outer_pat_ident: Ident,
                         fields: &StaticFields,
-                        getarg: |Span, InternedString, uint| -> @Expr)
+                        getarg: |&mut ExtCtxt, Span, InternedString, uint| -> @Expr)
                         -> @Expr {
     match *fields {
         Unnamed(ref fields) => {
@@ -155,7 +155,7 @@ fn decode_static_fields(cx: &ExtCtxt,
                 cx.expr_ident(trait_span, outer_pat_ident)
             } else {
                 let fields = fields.iter().enumerate().map(|(i, &span)| {
-                    getarg(span,
+                    getarg(cx, span,
                            token::intern_and_get_ident(format!("_field{}",
                                                                i)),
                            i)
@@ -167,9 +167,8 @@ fn decode_static_fields(cx: &ExtCtxt,
         Named(ref fields) => {
             // use the field's span to get nicer error messages.
             let fields = fields.iter().enumerate().map(|(i, &(name, span))| {
-                cx.field_imm(span,
-                             name,
-                             getarg(span, token::get_ident(name.name), i))
+                let arg = getarg(cx, span, token::get_ident(name.name), i);
+                cx.field_imm(span, name, arg)
             }).collect();
             cx.expr_struct_ident(trait_span, outer_pat_ident, fields)
         }
index 22f850d56090e845abc57488836a51dfe723f5ea..922ee164353208a96634824df8e2f7dd078bab7f 100644 (file)
@@ -14,7 +14,7 @@
 use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 
-pub fn expand_deriving_default(cx: &ExtCtxt,
+pub fn expand_deriving_default(cx: &mut ExtCtxt,
                             span: Span,
                             mitem: @MetaItem,
                             in_items: ~[@Item])
@@ -41,7 +41,7 @@ pub fn expand_deriving_default(cx: &ExtCtxt,
     trait_def.expand(mitem, in_items)
 }
 
-fn default_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
+fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
     let default_ident = ~[
         cx.ident_of("std"),
         cx.ident_of("default"),
index a44e4af5b6b4fd36333b012c249efcb6aa133eb7..4de31adc7f2c7cf76320600ef46434f5e93261ac 100644 (file)
@@ -82,7 +82,7 @@ fn decode(d: &D) -> spanned<T> {
 use ext::deriving::generic::*;
 use parse::token;
 
-pub fn expand_deriving_encodable(cx: &ExtCtxt,
+pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
                                  span: Span,
                                  mitem: @MetaItem,
                                  in_items: ~[@Item]) -> ~[@Item] {
@@ -114,7 +114,7 @@ pub fn expand_deriving_encodable(cx: &ExtCtxt,
     trait_def.expand(mitem, in_items)
 }
 
-fn encodable_substructure(cx: &ExtCtxt, trait_span: Span,
+fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
                           substr: &Substructure) -> @Expr {
     let encoder = substr.nonself_args[0];
     // throw an underscore in front to suppress unused variable warnings
index 992ee3175edd9f9685d2ec21d038bba748d29fce..8c06f0b8c8a0ec182164f7f6d10647fe145b4d97 100644 (file)
@@ -194,7 +194,7 @@ fn eq(&self, other: &int) -> bool {
 
 pub struct TraitDef<'a> {
     /// The extension context
-    cx: &'a ExtCtxt<'a>,
+    cx: &'a mut ExtCtxt<'a>,
     /// The span for the current #[deriving(Foo)] header.
     span: Span,
 
@@ -304,7 +304,7 @@ pub enum SubstructureFields<'a> {
 all the fields of all the structures, see above for details.
 */
 pub type CombineSubstructureFunc<'a> =
-    'a |&ExtCtxt, Span, &Substructure| -> @Expr;
+    'a |&mut ExtCtxt, Span, &Substructure| -> @Expr;
 
 /**
 Deal with non-matching enum variants, the arguments are a list
@@ -312,7 +312,7 @@ pub enum SubstructureFields<'a> {
 [variant fields]), and a list of the nonself args of the type
 */
 pub type EnumNonMatchFunc<'a> =
-    'a |&ExtCtxt,
+    'a |&mut ExtCtxt,
            Span,
            &[(uint, P<ast::Variant>, ~[(Span, Option<Ident>, @Expr)])],
            &[@Expr]|
@@ -356,7 +356,7 @@ pub fn expand(&self,
     fn create_derived_impl(&self,
                            type_ident: Ident, generics: &Generics,
                            methods: ~[@ast::Method]) -> @ast::Item {
-        let cx = self.cx;
+        let cx = &*self.cx;
         let trait_path = self.path.to_path(cx, self.span, type_ident, generics);
 
         let mut trait_generics = self.generics.to_generics(cx, self.span,
@@ -764,7 +764,7 @@ fn build_enum_match(&self,
                         matches_so_far: &mut ~[(uint, P<ast::Variant>,
                                               ~[(Span, Option<Ident>, @Expr)])],
                         match_count: uint) -> @Expr {
-        let cx = trait_.cx;
+        let cx = &trait_.cx;
         if match_count == self_args.len() {
             // we've matched against all arguments, so make the final
             // expression at the bottom of the match tree
@@ -990,7 +990,7 @@ fn create_struct_pattern(&self,
                              prefix: &str,
                              mutbl: ast::Mutability)
         -> (@ast::Pat, ~[(Span, Option<Ident>, @Expr)]) {
-        let cx = self.cx;
+        let cx = &self.cx;
 
         if struct_def.fields.is_empty() {
             return (
@@ -1050,7 +1050,7 @@ fn create_enum_variant_pattern(&self,
                                    prefix: &str,
                                    mutbl: ast::Mutability)
         -> (@ast::Pat, ~[(Span, Option<Ident>, @Expr)]) {
-        let cx = self.cx;
+        let cx = &*self.cx;
         let variant_ident = variant.node.name;
         match variant.node.kind {
             ast::TupleVariantKind(ref variant_args) => {
@@ -1093,10 +1093,10 @@ fn create_enum_variant_pattern(&self,
 left-to-right (`true`) or right-to-left (`false`).
 */
 pub fn cs_fold(use_foldl: bool,
-               f: |&ExtCtxt, Span, @Expr, @Expr, &[@Expr]| -> @Expr,
+               f: |&mut ExtCtxt, Span, @Expr, @Expr, &[@Expr]| -> @Expr,
                base: @Expr,
                enum_nonmatch_f: EnumNonMatchFunc,
-               cx: &ExtCtxt,
+               cx: &mut ExtCtxt,
                trait_span: Span,
                substructure: &Substructure)
                -> @Expr {
@@ -1132,9 +1132,9 @@ pub fn cs_fold(use_foldl: bool,
 ~~~
 */
 #[inline]
-pub fn cs_same_method(f: |&ExtCtxt, Span, ~[@Expr]| -> @Expr,
+pub fn cs_same_method(f: |&mut ExtCtxt, Span, ~[@Expr]| -> @Expr,
                       enum_nonmatch_f: EnumNonMatchFunc,
-                      cx: &ExtCtxt,
+                      cx: &mut ExtCtxt,
                       trait_span: Span,
                       substructure: &Substructure)
                       -> @Expr {
@@ -1166,10 +1166,10 @@ pub fn cs_same_method(f: |&ExtCtxt, Span, ~[@Expr]| -> @Expr,
 */
 #[inline]
 pub fn cs_same_method_fold(use_foldl: bool,
-                           f: |&ExtCtxt, Span, @Expr, @Expr| -> @Expr,
+                           f: |&mut ExtCtxt, Span, @Expr, @Expr| -> @Expr,
                            base: @Expr,
                            enum_nonmatch_f: EnumNonMatchFunc,
-                           cx: &ExtCtxt,
+                           cx: &mut ExtCtxt,
                            trait_span: Span,
                            substructure: &Substructure)
                            -> @Expr {
@@ -1196,7 +1196,7 @@ pub fn cs_same_method_fold(use_foldl: bool,
 #[inline]
 pub fn cs_binop(binop: ast::BinOp, base: @Expr,
                 enum_nonmatch_f: EnumNonMatchFunc,
-                cx: &ExtCtxt, trait_span: Span,
+                cx: &mut ExtCtxt, trait_span: Span,
                 substructure: &Substructure) -> @Expr {
     cs_same_method_fold(
         true, // foldl is good enough
@@ -1214,7 +1214,7 @@ pub fn cs_binop(binop: ast::BinOp, base: @Expr,
 /// cs_binop with binop == or
 #[inline]
 pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
-             cx: &ExtCtxt, span: Span,
+             cx: &mut ExtCtxt, span: Span,
              substructure: &Substructure) -> @Expr {
     cs_binop(ast::BiOr, cx.expr_bool(span, false),
              enum_nonmatch_f,
@@ -1224,7 +1224,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
 /// cs_binop with binop == and
 #[inline]
 pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc,
-              cx: &ExtCtxt, span: Span,
+              cx: &mut ExtCtxt, span: Span,
               substructure: &Substructure) -> @Expr {
     cs_binop(ast::BiAnd, cx.expr_bool(span, true),
              enum_nonmatch_f,
index d82e1ef1842614de0f044ff8a1df86af12691aa7..5380569472582b6ae2dc012df1e1f28c933ee442 100644 (file)
@@ -15,7 +15,7 @@
 use ext::deriving::generic::*;
 
 
-pub fn expand_deriving_iter_bytes(cx: &ExtCtxt,
+pub fn expand_deriving_iter_bytes(cx: &mut ExtCtxt,
                                   span: Span,
                                   mitem: @MetaItem,
                                   in_items: ~[@Item]) -> ~[@Item] {
@@ -45,7 +45,7 @@ pub fn expand_deriving_iter_bytes(cx: &ExtCtxt,
     trait_def.expand(mitem, in_items)
 }
 
-fn iter_bytes_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
+fn iter_bytes_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
     let (lsb0, f)= match substr.nonself_args {
         [l, f] => (l, f),
         _ => cx.span_bug(trait_span, "Incorrect number of arguments in `deriving(IterBytes)`")
index 33bac5c606040c7cd6825cb71573cdf01cd1b1ac..4430f4abdbf467d6d33215faaae632e4f1f7aa0c 100644 (file)
@@ -44,7 +44,7 @@
 
 pub mod generic;
 
-pub fn expand_meta_deriving(cx: &ExtCtxt,
+pub fn expand_meta_deriving(cx: &mut ExtCtxt,
                             _span: Span,
                             mitem: @MetaItem,
                             in_items: ~[@Item])
index e2f72e8708551adea5a574b95868316cb52d0754..86c46705d81b98d0ba82808be37e268af6555d7d 100644 (file)
@@ -16,7 +16,7 @@
 use ext::deriving::generic::*;
 use parse::token::InternedString;
 
-pub fn expand_deriving_from_primitive(cx: &ExtCtxt,
+pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
                                       span: Span,
                                       mitem: @MetaItem,
                                       in_items: ~[@Item]) -> ~[@Item] {
@@ -65,7 +65,7 @@ pub fn expand_deriving_from_primitive(cx: &ExtCtxt,
     trait_def.expand(mitem, in_items)
 }
 
-fn cs_from(name: &str, cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
+fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
     let n = match substr.nonself_args {
         [n] => n,
         _ => cx.span_bug(trait_span, "Incorrect number of arguments in `deriving(FromPrimitive)`")
index a22822c2ddcc5cde3f560f93268cf0c875215f54..15595f6eddc404922e7469e8dbaa64c0b4ac7980 100644 (file)
@@ -16,7 +16,7 @@
 use ext::deriving::generic::*;
 use opt_vec;
 
-pub fn expand_deriving_rand(cx: &ExtCtxt,
+pub fn expand_deriving_rand(cx: &mut ExtCtxt,
                             span: Span,
                             mitem: @MetaItem,
                             in_items: ~[@Item])
@@ -50,7 +50,7 @@ pub fn expand_deriving_rand(cx: &ExtCtxt,
     trait_def.expand(mitem, in_items)
 }
 
-fn rand_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
+fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
     let rng = match substr.nonself_args {
         [rng] => ~[ rng ],
         _ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`")
@@ -112,9 +112,8 @@ fn rand_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @
                 let i_expr = cx.expr_uint(v_span, i);
                 let pat = cx.pat_lit(v_span, i_expr);
 
-                cx.arm(v_span,
-                       ~[ pat ],
-                       rand_thing(cx, v_span, ident, summary, |sp| rand_call(sp)))
+                let thing = rand_thing(cx, v_span, ident, summary, |sp| rand_call(sp));
+                cx.arm(v_span, ~[ pat ], thing)
             }).collect::<~[ast::Arm]>();
 
             // _ => {} at the end. Should never occur
@@ -128,7 +127,7 @@ fn rand_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @
         _ => cx.bug("Non-static method in `deriving(Rand)`")
     };
 
-    fn rand_thing(cx: &ExtCtxt,
+    fn rand_thing(cx: &mut ExtCtxt,
                   trait_span: Span,
                   ctor_ident: Ident,
                   summary: &StaticFields,
index 6101d647ca5dd9beed219375ecb0a3623760b211..2f50d5ad121cb77abfb2b7169a72ffb931fb1b52 100644 (file)
@@ -17,7 +17,7 @@
 use parse::token::InternedString;
 use parse::token;
 
-pub fn expand_deriving_to_str(cx: &ExtCtxt,
+pub fn expand_deriving_to_str(cx: &mut ExtCtxt,
                               span: Span,
                               mitem: @MetaItem,
                               in_items: ~[@Item])
@@ -49,7 +49,7 @@ pub fn expand_deriving_to_str(cx: &ExtCtxt,
 // doesn't invoke the to_str() method on each field. Hence we mirror
 // the logic of the repr_to_str() method, but with tweaks to call to_str()
 // on sub-fields.
-fn to_str_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure)
+fn to_str_substructure(cx: &mut ExtCtxt, span: Span, substr: &Substructure)
                        -> @Expr {
     let to_str = cx.ident_of("to_str");
 
index dd99e8216200544f59d4158c71e5005cdd35a617..ecd06b3f49e5678debec88805e096910fdb927ac 100644 (file)
@@ -14,7 +14,7 @@
 use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 
-pub fn expand_deriving_zero(cx: &ExtCtxt,
+pub fn expand_deriving_zero(cx: &mut ExtCtxt,
                             span: Span,
                             mitem: @MetaItem,
                             in_items: ~[@Item])
@@ -57,7 +57,7 @@ pub fn expand_deriving_zero(cx: &ExtCtxt,
     trait_def.expand(mitem, in_items)
 }
 
-fn zero_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
+fn zero_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
     let zero_ident = ~[
         cx.ident_of("std"),
         cx.ident_of("num"),