Skip to content

Commit

Permalink
Rename AstBuilder::expr_int -> AstBuilder::expr_isize
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed May 2, 2015
1 parent 4957ecc commit 5892b40
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/libsyntax/ext/build.rs
Expand Up @@ -146,7 +146,7 @@ pub trait AstBuilder {
fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P<ast::Expr>;

fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr>;
fn expr_int(&self, sp: Span, i: isize) -> P<ast::Expr>;
fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr>;
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr>;
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr>;
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr>;
Expand Down Expand Up @@ -698,7 +698,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> {
self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs)))
}
fn expr_int(&self, sp: Span, i: isize) -> P<ast::Expr> {
fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs,
ast::Sign::new(i))))
}
Expand Down
9 changes: 6 additions & 3 deletions src/libsyntax/ext/deriving/generic/mod.rs
Expand Up @@ -380,7 +380,7 @@ impl<'a> TraitDef<'a> {
pub fn expand(&self,
cx: &mut ExtCtxt,
mitem: &ast::MetaItem,
item: &'a ast::Item,
item: &'a ast::Item,
push: &mut FnMut(P<ast::Item>))
{
let newitem = match item.node {
Expand Down Expand Up @@ -1407,7 +1407,9 @@ impl<'a> TraitDef<'a> {
struct_def: &'a StructDef,
prefix: &str,
mutbl: ast::Mutability)
-> (P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>, &'a [ast::Attribute])>) {
-> (P<ast::Pat>, Vec<(Span, Option<Ident>,
P<Expr>,
&'a [ast::Attribute])>) {
if struct_def.fields.is_empty() {
return (cx.pat_enum(self.span, struct_path, vec![]), vec![]);
}
Expand Down Expand Up @@ -1445,7 +1447,8 @@ impl<'a> TraitDef<'a> {
// struct_type is definitely not Unknown, since struct_def.fields
// must be nonempty to reach here
let pattern = if struct_type == Record {
let field_pats = subpats.into_iter().zip(ident_expr.iter()).map(|(pat, &(_, id, _, _))| {
let field_pats = subpats.into_iter().zip(ident_expr.iter())
.map(|(pat, &(_, id, _, _))| {
// id is guaranteed to be Some
codemap::Spanned {
span: pat.span,
Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/custom_derive_plugin.rs
Expand Up @@ -55,7 +55,7 @@ fn expand(cx: &mut ExtCtxt,
ret_ty: Literal(Path::new_local("isize")),
attributes: vec![],
combine_substructure: combine_substructure(box |cx, span, substr| {
let zero = cx.expr_int(span, 0);
let zero = cx.expr_isize(span, 0);
cs_fold(false,
|cx, span, subexpr, field, _| {
cx.expr_binary(span, ast::BiAdd, subexpr,
Expand Down
5 changes: 3 additions & 2 deletions src/test/auxiliary/custom_derive_plugin_attr.rs
Expand Up @@ -66,13 +66,14 @@ fn expand(cx: &mut ExtCtxt,

// Mostly copied from syntax::ext::deriving::hash
/// Defines how the implementation for `trace()` is to be generated
fn totalsum_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<ast::Expr> {
fn totalsum_substructure(cx: &mut ExtCtxt, trait_span: Span,
substr: &Substructure) -> P<ast::Expr> {
let fields = match *substr.fields {
Struct(ref fs) | EnumMatching(_, _, ref fs) => fs,
_ => cx.span_bug(trait_span, "impossible substructure")
};

fields.iter().fold(cx.expr_int(trait_span, 0), |acc, ref item| {
fields.iter().fold(cx.expr_isize(trait_span, 0), |acc, ref item| {
if item.attrs.iter().find(|a| a.check_name("ignore")).is_some() {
acc
} else {
Expand Down

0 comments on commit 5892b40

Please sign in to comment.