Rename AstBuilder::expr_int -> AstBuilder::expr_isize
This commit is contained in:
parent
4957ecce3e
commit
5892b40859
4 changed files with 12 additions and 8 deletions
|
|
@ -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>;
|
||||
|
|
@ -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))))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -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![]);
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue