use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
-
use parse::token;
use collections::HashMap;
+use std::strbuf::StrBuf;
pub fn expand_deriving_show(cx: &mut ExtCtxt,
span: Span,
explicit_self: borrowed_explicit_self(),
args: vec!(fmtr),
ret_ty: Literal(Path::new(vec!("std", "fmt", "Result"))),
- inline: false,
+ attributes: Vec::new(),
const_nonmatching: false,
- combine_substructure: show_substructure
+ combine_substructure: combine_substructure(|a, b, c| {
+ show_substructure(a, b, c)
+ })
}
)
};
}
};
- let mut format_string = token::get_ident(name).get().to_owned();
+ let mut format_string = StrBuf::from_str(token::get_ident(name).get());
// the internal fields we're actually formatting
let mut exprs = Vec::new();
EnumMatching(_, _, ref fields) if fields.len() == 0 => {}
Struct(ref fields) | EnumMatching(_, _, ref fields) => {
- if fields[0].name.is_none() {
+ if fields.get(0).name.is_none() {
// tuple struct/"normal" variant
format_string.push_str("(");
let write_call = cx.expr_call_global(span, std_write, vec!(buf, cx.expr_ident(span, args)));
let format_closure = cx.lambda_expr(span, vec!(args), write_call);
- let s = token::intern_and_get_ident(format_string);
+ let s = token::intern_and_get_ident(format_string.as_slice());
let format_string = cx.expr_str(span, s);
// phew, not our responsibility any more!
format::expand_preparsed_format_args(cx, span,
format_closure,
- format_string, exprs, ~[],
+ format_string, exprs, Vec::new(),
HashMap::new())
}