Skip to content

Commit b9aedb5

Browse files
committed
---
yaml --- r: 31712 b: refs/heads/dist-snap c: deaef48 h: refs/heads/master v: v3
1 parent 9052fef commit b9aedb5

File tree

16 files changed

+116
-97
lines changed

16 files changed

+116
-97
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 1a6dadad5bc7a0bb85f67ddaa9d38d9d4f741057
10+
refs/heads/dist-snap: deaef48675c34f3a63ded090058dfe6cbe60c3c6
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/libsyntax/ast.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,17 @@ type trait_ref = {path: @path, ref_id: node_id, impl_id: node_id};
710710
#[auto_serialize]
711711
enum visibility { public, private, inherited }
712712

713+
#[auto_serialize]
714+
type struct_def = {
715+
traits: ~[@trait_ref], /* traits this class implements */
716+
members: ~[@class_member], /* methods, etc. */
717+
/* (not including ctor or dtor) */
718+
/* ctor is optional, and will soon go away */
719+
ctor: option<class_ctor>,
720+
/* dtor is optional */
721+
dtor: option<class_dtor>
722+
};
723+
713724
#[auto_serialize]
714725
type item = {ident: ident, attrs: ~[attribute],
715726
id: node_id, node: item_,
@@ -723,15 +734,7 @@ enum item_ {
723734
item_foreign_mod(foreign_mod),
724735
item_ty(@ty, ~[ty_param]),
725736
item_enum(~[variant], ~[ty_param]),
726-
item_class(~[ty_param], /* ty params for class */
727-
~[@trait_ref], /* traits this class implements */
728-
~[@class_member], /* methods, etc. */
729-
/* (not including ctor or dtor) */
730-
/* ctor is optional, and will soon go away */
731-
option<class_ctor>,
732-
/* dtor is optional */
733-
option<class_dtor>
734-
),
737+
item_class(struct_def, ~[ty_param]),
735738
item_trait(~[ty_param], ~[@trait_ref], ~[trait_method]),
736739
item_impl(~[ty_param],
737740
~[@trait_ref], /* traits this impl implements */

branches/dist-snap/src/libsyntax/ast_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ fn map_item(i: @item, cx: ctx, v: vt) {
216216
extend(cx, i.ident)));
217217
}
218218
}
219-
item_class(tps, traits, items, ctor, dtor) => {
220-
let (_, ms) = ast_util::split_class_items(items);
219+
item_class(struct_def, _) => {
220+
let (_, ms) = ast_util::split_class_items(struct_def.members);
221221
// Map trait refs to their parent classes. This is
222222
// so we can find the self_ty
223-
for traits.each |p| {
223+
for struct_def.traits.each |p| {
224224
cx.map.insert(p.ref_id, node_item(i, item_path));
225225
// This is so we can look up the right things when
226226
// encoding/decoding

branches/dist-snap/src/libsyntax/fold.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
242242
item_enum(vec::map(variants, |x| fld.fold_variant(x)),
243243
fold_ty_params(typms, fld))
244244
}
245-
item_class(typms, traits, items, m_ctor, m_dtor) => {
245+
item_class(struct_def, typms) => {
246246
let resulting_optional_constructor;
247-
match m_ctor {
247+
match struct_def.ctor {
248248
none => {
249249
resulting_optional_constructor = none;
250250
}
@@ -260,18 +260,20 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
260260
});
261261
}
262262
}
263-
let dtor = do option::map(m_dtor) |dtor| {
263+
let dtor = do option::map(struct_def.dtor) |dtor| {
264264
let dtor_body = fld.fold_block(dtor.node.body);
265265
let dtor_id = fld.new_id(dtor.node.id);
266266
{node: {body: dtor_body,
267267
id: dtor_id with dtor.node}
268268
with dtor}};
269-
item_class(
270-
/* FIXME (#2543) */ copy typms,
271-
vec::map(traits, |p| fold_trait_ref(p, fld)),
272-
vec::map(items, |x| fld.fold_class_item(x)),
273-
resulting_optional_constructor,
274-
dtor)
269+
item_class({
270+
traits: vec::map(struct_def.traits,
271+
|p| fold_trait_ref(p, fld)),
272+
members: vec::map(struct_def.members,
273+
|x| fld.fold_class_item(x)),
274+
ctor: resulting_optional_constructor,
275+
dtor: dtor},
276+
/* FIXME (#2543) */ copy typms)
275277
}
276278
item_impl(tps, ifce, ty, methods) => {
277279
item_impl(fold_ty_params(tps, fld),

branches/dist-snap/src/libsyntax/parse/parser.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,18 +2581,28 @@ class parser {
25812581
match the_ctor {
25822582
some((ct_d, ct_attrs, ct_b, ct_s)) => {
25832583
(class_name,
2584-
item_class(ty_params, traits, ms, some({
2584+
item_class({
2585+
traits: traits,
2586+
members: ms,
2587+
ctor: some({
25852588
node: {id: ctor_id,
25862589
attrs: ct_attrs,
25872590
self_id: self.get_id(),
25882591
dec: ct_d,
25892592
body: ct_b},
2590-
span: ct_s}), actual_dtor),
2593+
span: ct_s}),
2594+
dtor: actual_dtor
2595+
}, ty_params),
25912596
none)
25922597
}
25932598
none => {
25942599
(class_name,
2595-
item_class(ty_params, traits, ms, none, actual_dtor),
2600+
item_class({
2601+
traits: traits,
2602+
members: ms,
2603+
ctor: none,
2604+
dtor: actual_dtor
2605+
}, ty_params),
25962606
none)
25972607
}
25982608
}

branches/dist-snap/src/libsyntax/print/pprust.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,18 +530,18 @@ fn print_item(s: ps, &&item: @ast::item) {
530530
bclose(s, item.span);
531531
}
532532
}
533-
ast::item_class(tps, traits, items, m_ctor, m_dtor) => {
533+
ast::item_class(struct_def, tps) => {
534534
head(s, ~"class");
535535
word_nbsp(s, *item.ident);
536536
print_type_params(s, tps);
537-
if vec::len(traits) != 0u {
537+
if vec::len(struct_def.traits) != 0u {
538538
word_space(s, ~":");
539-
commasep(s, inconsistent, traits, |s, p|
539+
commasep(s, inconsistent, struct_def.traits, |s, p|
540540
print_path(s, p.path, false));
541541
}
542542
bopen(s);
543543
hardbreak_if_not_bol(s);
544-
do option::iter(m_ctor) |ctor| {
544+
do option::iter(struct_def.ctor) |ctor| {
545545
maybe_print_comment(s, ctor.span.lo);
546546
print_outer_attributes(s, ctor.node.attrs);
547547
// Doesn't call head because there shouldn't be a space after new.
@@ -553,14 +553,14 @@ fn print_item(s: ps, &&item: @ast::item) {
553553
space(s.s);
554554
print_block(s, ctor.node.body);
555555
}
556-
do option::iter(m_dtor) |dtor| {
556+
do option::iter(struct_def.dtor) |dtor| {
557557
hardbreak_if_not_bol(s);
558558
maybe_print_comment(s, dtor.span.lo);
559559
print_outer_attributes(s, dtor.node.attrs);
560560
head(s, ~"drop");
561561
print_block(s, dtor.node.body);
562562
}
563-
for items.each |ci| {
563+
for struct_def.members.each |ci| {
564564
/*
565565
FIXME (#1893): collect all private items and print
566566
them in a single "priv" section

branches/dist-snap/src/libsyntax/visit.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,17 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
152152
visit_method_helper(m, e, v)
153153
}
154154
}
155-
item_class(tps, traits, members, m_ctor, m_dtor) => {
155+
item_class(struct_def, tps) => {
156156
v.visit_ty_params(tps, e, v);
157-
for members.each |m| {
157+
for struct_def.members.each |m| {
158158
v.visit_class_item(m, e, v);
159159
}
160-
for traits.each |p| { visit_path(p.path, e, v); }
161-
do option::iter(m_ctor) |ctor| {
160+
for struct_def.traits.each |p| { visit_path(p.path, e, v); }
161+
do option::iter(struct_def.ctor) |ctor| {
162162
visit_class_ctor_helper(ctor, i.ident, tps,
163163
ast_util::local_def(i.id), e, v);
164164
};
165-
do option::iter(m_dtor) |dtor| {
165+
do option::iter(struct_def.dtor) |dtor| {
166166
visit_class_dtor_helper(dtor, tps,
167167
ast_util::local_def(i.id), e, v)
168168
};

branches/dist-snap/src/rustc/metadata/encoder.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
196196
encode_name_and_def_id(ebml_w, it.ident, it.id);
197197
}
198198
}
199-
item_class(_, _, items, m_ctor, m_dtor) => {
199+
item_class(struct_def, _) => {
200200
do ebml_w.wr_tag(tag_paths_data_item) {
201201
encode_name_and_def_id(ebml_w, it.ident, it.id);
202202
}
@@ -205,7 +205,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
205205
// class and for its ctor
206206
add_to_index(ebml_w, path, index, it.ident);
207207

208-
match m_ctor {
208+
match struct_def.ctor {
209209
none => {
210210
// Nothing to do.
211211
}
@@ -215,7 +215,8 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
215215
}
216216
}
217217

218-
encode_class_item_paths(ebml_w, items,
218+
encode_class_item_paths(ebml_w,
219+
struct_def.members,
219220
vec::append_one(path, it.ident),
220221
index);
221222
}
@@ -700,15 +701,15 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
700701
encode_enum_variant_info(ecx, ebml_w, item.id, variants,
701702
path, index, tps);
702703
}
703-
item_class(tps, traits, items, ctor, m_dtor) => {
704+
item_class(struct_def, tps) => {
704705
/* First, encode the fields and methods
705706
These come first because we need to write them to make
706707
the index, and the index needs to be in the item for the
707708
class itself */
708709
let idx = encode_info_for_class(ecx, ebml_w, item.id, path, tps,
709-
items, index);
710+
struct_def.members, index);
710711
/* Encode the dtor */
711-
do option::iter(m_dtor) |dtor| {
712+
do option::iter(struct_def.dtor) |dtor| {
712713
vec::push(*index, {val: dtor.node.id, pos: ebml_w.writer.tell()});
713714
encode_info_for_fn(ecx, ebml_w, dtor.node.id, @(*item.ident
714715
+ ~"_dtor"), path, if tps.len() > 0u {
@@ -723,7 +724,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
723724
ebml_w.start_tag(tag_items_data_item);
724725
encode_def_id(ebml_w, local_def(item.id));
725726

726-
match ctor {
727+
match struct_def.ctor {
727728
none => encode_family(ebml_w, 'S'),
728729
some(_) => encode_family(ebml_w, 'C')
729730
}
@@ -733,12 +734,12 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
733734
encode_name(ebml_w, item.ident);
734735
encode_path(ebml_w, path, ast_map::path_name(item.ident));
735736
encode_region_param(ecx, ebml_w, item);
736-
for traits.each |t| {
737+
for struct_def.traits.each |t| {
737738
encode_trait_ref(ebml_w, ecx, t);
738739
}
739740
/* Encode the dtor */
740741
/* Encode id for dtor */
741-
do option::iter(m_dtor) |dtor| {
742+
do option::iter(struct_def.dtor) |dtor| {
742743
do ebml_w.wr_tag(tag_item_dtor) {
743744
encode_def_id(ebml_w, local_def(dtor.node.id));
744745
}
@@ -747,7 +748,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
747748
/* Encode def_ids for each field and method
748749
for methods, write all the stuff get_trait_method
749750
needs to know*/
750-
let (fs,ms) = ast_util::split_class_items(items);
751+
let (fs,ms) = ast_util::split_class_items(struct_def.members);
751752
for fs.each |f| {
752753
ebml_w.start_tag(tag_item_field);
753754
encode_visibility(ebml_w, f.vis);
@@ -783,7 +784,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
783784
ebml_w.end_tag();
784785

785786
/* Encode the constructor */
786-
for ctor.each |ctor| {
787+
for struct_def.ctor.each |ctor| {
787788
debug!{"encoding info for ctor %s %d", *item.ident,
788789
ctor.node.id};
789790
vec::push(*index, {

branches/dist-snap/src/rustc/middle/resolve3.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -984,13 +984,13 @@ class Resolver {
984984
visitor);
985985
}
986986
}
987-
item_class(_, _, class_members, optional_ctor, _) => {
987+
item_class(struct_definition, _) => {
988988
let (name_bindings, new_parent) = self.add_child(atom, parent,
989989
~[ValueNS, TypeNS], sp);
990990

991991
(*name_bindings).define_type(def_ty(local_def(item.id)), sp);
992992

993-
match optional_ctor {
993+
match struct_definition.ctor {
994994
none => {
995995
// Nothing to do.
996996
}
@@ -1008,7 +1008,7 @@ class Resolver {
10081008
// bindings.
10091009

10101010
let mut method_infos = ~[];
1011-
for class_members.each |class_member| {
1011+
for struct_definition.members.each |class_member| {
10121012
match class_member.node {
10131013
class_method(method) => {
10141014
// XXX: Combine with impl method code below.
@@ -1037,7 +1037,7 @@ class Resolver {
10371037

10381038
// Record the def ID of this struct.
10391039
self.structs.insert(local_def(item.id),
1040-
is_some(optional_ctor));
1040+
is_some(struct_definition.ctor));
10411041

10421042
visit_item(item, new_parent, visitor);
10431043
}
@@ -3249,15 +3249,13 @@ class Resolver {
32493249
(*self.type_ribs).pop();
32503250
}
32513251

3252-
item_class(ty_params, traits, class_members,
3253-
optional_constructor, optional_destructor) => {
3254-
3252+
item_class(struct_def, ty_params) => {
32553253
self.resolve_class(item.id,
32563254
@copy ty_params,
3257-
traits,
3258-
class_members,
3259-
optional_constructor,
3260-
optional_destructor,
3255+
struct_def.traits,
3256+
struct_def.members,
3257+
struct_def.ctor,
3258+
struct_def.dtor,
32613259
visitor);
32623260
}
32633261

branches/dist-snap/src/rustc/middle/trans/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4899,25 +4899,25 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
48994899
};
49004900
foreign::trans_foreign_mod(ccx, foreign_mod, abi);
49014901
}
4902-
ast::item_class(tps, _traits, items, m_ctor, m_dtor) => {
4902+
ast::item_class(struct_def, tps) => {
49034903
if tps.len() == 0u {
49044904
let psubsts = {tys: ty::ty_params_to_tys(ccx.tcx, tps),
49054905
vtables: none,
49064906
bounds: @~[]};
4907-
do option::iter(m_ctor) |ctor| {
4907+
do option::iter(struct_def.ctor) |ctor| {
49084908
trans_class_ctor(ccx, *path, ctor.node.dec, ctor.node.body,
49094909
get_item_val(ccx, ctor.node.id), psubsts,
49104910
ctor.node.id, local_def(item.id), ctor.span);
49114911
}
4912-
do option::iter(m_dtor) |dtor| {
4912+
do option::iter(struct_def.dtor) |dtor| {
49134913
trans_class_dtor(ccx, *path, dtor.node.body,
49144914
dtor.node.id, none, none, local_def(item.id));
49154915
};
49164916
}
49174917
// If there are ty params, the ctor will get monomorphized
49184918

49194919
// Translate methods
4920-
let (_, ms) = ast_util::split_class_items(items);
4920+
let (_, ms) = ast_util::split_class_items(struct_def.members);
49214921
impl::trans_impl(ccx, *path, item.ident, ms, tps);
49224922
}
49234923
_ => {/* fall through */ }

branches/dist-snap/src/rustc/middle/trans/impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
9494
method_from_methods(ms, name)
9595
}
9696
ast_map::node_item(@{node:
97-
ast::item_class(_, _, items, _, _), _}, _) => {
98-
let (_,ms) = split_class_items(items);
97+
ast::item_class(struct_def, _), _}, _) => {
98+
let (_,ms) = split_class_items(struct_def.members);
9999
method_from_methods(ms, name)
100100
}
101101
}

0 commit comments

Comments
 (0)