convert ast::struct_field_ into a struct

This commit is contained in:
Erick Tryzelaar 2013-01-13 15:28:49 -08:00
parent 1f5e9ff362
commit eafed93d72
3 changed files with 23 additions and 17 deletions
src/libsyntax

@ -1457,11 +1457,11 @@ impl visibility : cmp::Eq {
#[auto_encode]
#[auto_decode]
type struct_field_ = {
struct struct_field_ {
kind: struct_field_kind,
id: node_id,
ty: @Ty
};
ty: @Ty,
}
type struct_field = spanned<struct_field_>;

@ -216,9 +216,9 @@ fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> {
fn noop_fold_struct_field(&&sf: @struct_field, fld: ast_fold)
-> @struct_field {
@spanned { node: { kind: copy sf.node.kind,
id: sf.node.id,
ty: fld.fold_ty(sf.node.ty) },
@spanned { node: ast::struct_field_ { kind: copy sf.node.kind,
id: sf.node.id,
ty: fld.fold_ty(sf.node.ty) },
span: sf.span }
}
@ -293,9 +293,9 @@ fn fold_trait_ref(&&p: @trait_ref, fld: ast_fold) -> @trait_ref {
}
fn fold_struct_field(&&f: @struct_field, fld: ast_fold) -> @struct_field {
@spanned { node: { kind: copy f.node.kind,
id: fld.new_id(f.node.id),
ty: fld.fold_ty(f.node.ty) },
@spanned { node: ast::struct_field_ { kind: copy f.node.kind,
id: fld.new_id(f.node.id),
ty: fld.fold_ty(f.node.ty) },
span: fld.new_span(f.span) }
}
@ -693,10 +693,14 @@ impl ast_fold_fns: ast_fold {
return (self.fold_item)(i, self as ast_fold);
}
fn fold_struct_field(&&sf: @struct_field) -> @struct_field {
@spanned { node: { kind: copy sf.node.kind,
id: sf.node.id,
ty: (self as ast_fold).fold_ty(sf.node.ty) },
span: (self.new_span)(sf.span) }
@spanned {
node: ast::struct_field_ {
kind: copy sf.node.kind,
id: sf.node.id,
ty: (self as ast_fold).fold_ty(sf.node.ty),
},
span: (self.new_span)(sf.span),
}
}
fn fold_item_underscore(i: item_) ->
item_ {

@ -2150,11 +2150,11 @@ impl Parser {
let name = self.parse_ident();
self.expect(token::COLON);
let ty = self.parse_ty(false);
return @spanned(lo, self.last_span.hi, {
@spanned(lo, self.last_span.hi, ast::struct_field_ {
kind: named_field(name, is_mutbl, pr),
id: self.get_id(),
ty: ty
});
})
}
fn parse_stmt(+first_item_attrs: ~[attribute]) -> @stmt {
@ -2816,7 +2816,7 @@ impl Parser {
seq_sep_trailing_allowed
(token::COMMA)) |p| {
let lo = p.span.lo;
let struct_field_ = {
let struct_field_ = ast::struct_field_ {
kind: unnamed_field,
id: self.get_id(),
ty: p.parse_ty(false)
@ -2893,7 +2893,9 @@ impl Parser {
self.parse_method();
// bogus value
@spanned(self.span.lo, self.span.hi,
{ kind: unnamed_field, id: self.get_id(),
ast::struct_field_ {
kind: unnamed_field,
id: self.get_id(),
ty: @{id: self.get_id(),
node: ty_nil,
span: copy self.span} })