Skip to content

Commit 5ba7e55

Browse files
ericktcatamorphism
authored andcommitted
convert ast::{ty_field_,ty_method} into a struct
1 parent 8cdc3fd commit 5ba7e55

File tree

5 files changed

+47
-21
lines changed

5 files changed

+47
-21
lines changed

src/libsyntax/ast.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -940,15 +940,25 @@ struct mt {
940940

941941
#[auto_encode]
942942
#[auto_decode]
943-
type ty_field_ = {ident: ident, mt: mt};
943+
struct ty_field_ {
944+
ident: ident,
945+
mt: mt,
946+
}
944947

945948
type ty_field = spanned<ty_field_>;
946949

947950
#[auto_encode]
948951
#[auto_decode]
949-
type ty_method = {ident: ident, attrs: ~[attribute], purity: purity,
950-
decl: fn_decl, tps: ~[ty_param], self_ty: self_ty,
951-
id: node_id, span: span};
952+
struct ty_method {
953+
ident: ident,
954+
attrs: ~[attribute],
955+
purity: purity,
956+
decl: fn_decl,
957+
tps: ~[ty_param],
958+
self_ty: self_ty,
959+
id: node_id,
960+
span: span,
961+
}
952962

953963
#[auto_encode]
954964
#[auto_decode]

src/libsyntax/ast_util.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,19 @@ fn public_methods(ms: ~[@method]) -> ~[@method] {
341341
// a default, pull out the useful fields to make a ty_method
342342
fn trait_method_to_ty_method(method: trait_method) -> ty_method {
343343
match method {
344-
required(ref m) => (*m),
345-
provided(m) => {
346-
{ident: m.ident, attrs: m.attrs,
347-
purity: m.purity, decl: m.decl,
348-
tps: m.tps, self_ty: m.self_ty,
349-
id: m.id, span: m.span}
350-
}
344+
required(ref m) => (*m),
345+
provided(m) => {
346+
ty_method {
347+
ident: m.ident,
348+
attrs: m.attrs,
349+
purity: m.purity,
350+
decl: m.decl,
351+
tps: m.tps,
352+
self_ty: m.self_ty,
353+
id: m.id,
354+
span: m.span,
355+
}
356+
}
351357
}
352358
}
353359

src/libsyntax/ext/pipes/ast_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl ext_ctxt: ext_ctxt_ast_builder {
167167

168168
fn ty_field_imm(name: ident, ty: @ast::Ty) -> ast::ty_field {
169169
spanned {
170-
node: {
170+
node: ast::ty_field_ {
171171
ident: name,
172172
mt: ast::mt { ty: ty, mutbl: ast::m_imm },
173173
},

src/libsyntax/fold.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,13 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
541541
mt { ty: fld.fold_ty(mt.ty), mutbl: mt.mutbl }
542542
}
543543
fn fold_field(f: ty_field, fld: ast_fold) -> ty_field {
544-
spanned { node: { ident: fld.fold_ident(f.node.ident),
545-
mt: fold_mt(f.node.mt, fld) },
546-
span: fld.new_span(f.span) }
544+
spanned {
545+
node: ast::ty_field_ {
546+
ident: fld.fold_ident(f.node.ident),
547+
mt: fold_mt(f.node.mt, fld),
548+
},
549+
span: fld.new_span(f.span),
550+
}
547551
}
548552
match t {
549553
ty_nil | ty_bot | ty_infer => copy t,

src/libsyntax/parse/parser.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,16 @@ impl Parser {
421421
debug!("parse_trait_methods(): parsing required method");
422422
// NB: at the moment, visibility annotations on required
423423
// methods are ignored; this could change.
424-
required({ident: ident, attrs: attrs,
425-
purity: pur, decl: d, tps: tps,
426-
self_ty: self_ty,
427-
id: p.get_id(), span: mk_sp(lo, hi)})
424+
required(ty_method {
425+
ident: ident,
426+
attrs: attrs,
427+
purity: pur,
428+
decl: d,
429+
tps: tps,
430+
self_ty: self_ty,
431+
id: p.get_id(),
432+
span: mk_sp(lo, hi)
433+
})
428434
}
429435
token::LBRACE => {
430436
debug!("parse_trait_methods(): parsing provided method");
@@ -467,9 +473,9 @@ impl Parser {
467473
spanned(
468474
lo,
469475
ty.span.hi,
470-
{
476+
ast::ty_field_ {
471477
ident: id,
472-
mt: ast::mt { ty: ty, mutbl: mutbl }
478+
mt: ast::mt { ty: ty, mutbl: mutbl },
473479
}
474480
)
475481
}

0 commit comments

Comments
 (0)