mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
syntax: convert deriving to take &mut ExtCtxt.
This commit is contained in:
parent
eac673ab0c
commit
fa191a5591
@ -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,
|
||||
|
@ -14,7 +14,7 @@ use ext::base::ExtCtxt;
|
||||
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;
|
||||
|
@ -14,17 +14,17 @@ use ext::base::ExtCtxt;
|
||||
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)
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use ext::base::ExtCtxt;
|
||||
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 @@ pub fn expand_deriving_ord(cx: &ExtCtxt,
|
||||
}
|
||||
|
||||
/// 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,
|
||||
|
@ -14,11 +14,11 @@ use ext::base::ExtCtxt;
|
||||
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)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use ext::build::AstBuilder;
|
||||
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)`")
|
||||
}
|
||||
},
|
||||
|
@ -21,7 +21,7 @@ use ext::deriving::generic::*;
|
||||
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)
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use ext::base::ExtCtxt;
|
||||
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"),
|
||||
|
@ -82,7 +82,7 @@ use ext::build::AstBuilder;
|
||||
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
|
||||
|
@ -194,7 +194,7 @@ mod ty;
|
||||
|
||||
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 @@ Combine the values of all the fields together. The last argument is
|
||||
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 @@ representing each variant: (variant index, ast::Variant instance,
|
||||
[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 @@ impl<'a> TraitDef<'a> {
|
||||
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 @@ impl<'a> MethodDef<'a> {
|
||||
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 @@ impl<'a> TraitDef<'a> {
|
||||
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 @@ impl<'a> TraitDef<'a> {
|
||||
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 @@ Fold the fields. `use_foldl` controls whether this is done
|
||||
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 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1),
|
||||
~~~
|
||||
*/
|
||||
#[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 @@ fields. `use_foldl` controls whether this is done left-to-right
|
||||
*/
|
||||
#[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 @@ on all the fields.
|
||||
#[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,
|
||||
|
@ -15,7 +15,7 @@ use ext::build::AstBuilder;
|
||||
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)`")
|
||||
|
@ -44,7 +44,7 @@ pub mod totalord;
|
||||
|
||||
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])
|
||||
|
@ -16,7 +16,7 @@ use ext::build::AstBuilder;
|
||||
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)`")
|
||||
|
@ -16,7 +16,7 @@ use ext::build::{AstBuilder};
|
||||
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,
|
||||
|
@ -17,7 +17,7 @@ use ext::deriving::generic::*;
|
||||
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");
|
||||
|
||||
|
@ -14,7 +14,7 @@ use ext::base::ExtCtxt;
|
||||
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"),
|
||||
|
Loading…
Reference in New Issue
Block a user