Skip to content

Commit 2243d91

Browse files
committed
---
yaml --- r: 12178 b: refs/heads/master c: f7bbe53 h: refs/heads/master v: v3
1 parent 5029ff2 commit 2243d91

File tree

19 files changed

+203
-200
lines changed

19 files changed

+203
-200
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: fe610f04d89ae30e7ad68b9b519aa8461cd8d0fb
2+
refs/heads/master: f7bbe537c11b83c529d755622bc7fdb831d751cd
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/metadata/astencode.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,9 @@ fn visit_ids(item: ast::inlined_item, vfn: fn@(ast::node_id)) {
218218
}
219219
},
220220

221-
visit_class_item: fn@(_s: span, _p: ast::privacy,
222-
c: ast::class_member) {
223-
alt c {
224-
ast::instance_var(_, _, _, id) {
221+
visit_class_item: fn@(c: @ast::class_member) {
222+
alt c.node {
223+
ast::instance_var(_, _, _, id,_) {
225224
vfn(id)
226225
}
227226
ast::class_method(_) {

trunk/src/rustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ fn get_iface_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
431431
'u' { ast::unsafe_fn }
432432
'f' { ast::impure_fn }
433433
'p' { ast::pure_fn }
434-
}}];
434+
}, privacy: ast::pub}];
435435
}
436436
@result
437437
}

trunk/src/rustc/metadata/encoder.rs

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ fn encode_native_module_item_paths(ebml_w: ebml::writer, nmod: native_mod,
8383
}
8484

8585
fn encode_class_item_paths(ebml_w: ebml::writer,
86-
items: [@class_item], path: [str], &index: [entry<str>]) {
86+
items: [@class_member], path: [str], &index: [entry<str>]) {
8787
for it in items {
88-
alt it.node.privacy {
88+
alt ast_util::class_member_privacy(it) {
8989
priv { cont; }
9090
pub {
91-
let (id, ident) = alt it.node.decl {
92-
instance_var(v, _, _, vid) { (vid, v) }
91+
let (id, ident) = alt it.node {
92+
instance_var(v, _, _, vid, _) { (vid, v) }
9393
class_method(it) { (it.id, it.ident) }
9494
};
9595
add_to_index(ebml_w, path, index, ident);
@@ -368,20 +368,20 @@ fn encode_privacy(ebml_w: ebml::writer, privacy: privacy) {
368368
/* Returns an index of items in this class */
369369
fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
370370
id: node_id, path: ast_map::path,
371-
items: [@class_item],
371+
items: [@class_member],
372372
global_index: @mut[entry<int>])
373373
-> [entry<int>] {
374374
let index = @mut [];
375375
let tcx = ecx.ccx.tcx;
376376
for ci in items {
377377
/* We encode both private and public fields -- need to include
378378
private fields to get the offsets right */
379-
alt ci.node.decl {
380-
instance_var(nm, _, mt, id) {
379+
alt ci.node {
380+
instance_var(nm, _, mt, id, pr) {
381381
*index += [{val: id, pos: ebml_w.writer.tell()}];
382382
ebml_w.start_tag(tag_items_data_item);
383383
#debug("encode_info_for_class: doing %s %d", nm, id);
384-
encode_privacy(ebml_w, ci.node.privacy);
384+
encode_privacy(ebml_w, pr);
385385
encode_name(ebml_w, nm);
386386
encode_path(ebml_w, path, ast_map::path_name(nm));
387387
encode_type(ecx, ebml_w, node_id_to_type(tcx, id));
@@ -390,18 +390,23 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
390390
ebml_w.end_tag();
391391
}
392392
class_method(m) {
393-
*index += [{val: m.id, pos: ebml_w.writer.tell()}];
394-
/* Not sure whether we really need to have two indices,
395-
but it works for now -- tjc */
396-
*global_index += [{val: m.id, pos: ebml_w.writer.tell()}];
397-
let impl_path = path + [ast_map::path_name(m.ident)];
398-
/*
399-
Recall methods are (currently) monomorphic, and we don't
400-
repeat the class's ty params in the method decl
401-
*/
402-
#debug("encode_info_for_class: doing %s %d", m.ident, m.id);
403-
encode_info_for_method(ecx, ebml_w, impl_path,
404-
should_inline(m.attrs), id, m, []);
393+
alt m.privacy {
394+
pub {
395+
*index += [{val: m.id, pos: ebml_w.writer.tell()}];
396+
/* Not sure whether we really need to have two indices,
397+
but it works for now -- tjc */
398+
*global_index += [{val: m.id, pos: ebml_w.writer.tell()}];
399+
let impl_path = path + [ast_map::path_name(m.ident)];
400+
/*
401+
Recall methods are (currently) monomorphic, and we don't
402+
repeat the class's ty params in the method decl
403+
*/
404+
#debug("encode_info_for_class: doing %s %d", m.ident, m.id);
405+
encode_info_for_method(ecx, ebml_w, impl_path,
406+
should_inline(m.attrs), id, m, []);
407+
}
408+
_ { /* don't encode private methods */ }
409+
}
405410
}
406411
}
407412
}
@@ -581,11 +586,10 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
581586
encode_def_id(ebml_w, local_def(f.id));
582587
ebml_w.end_tag();
583588
}
584-
for mt in ms {
585-
alt mt.privacy {
589+
for m in ms {
590+
alt m.privacy {
586591
priv { /* do nothing */ }
587592
pub {
588-
let m = mt.meth;
589593
ebml_w.start_tag(tag_item_method);
590594
#debug("Writing %s %d", m.ident, m.id);
591595
encode_family(ebml_w, purity_fn_family(m.decl.purity));

trunk/src/rustc/middle/ast_map.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,8 @@ fn map_item(i: @item, cx: ctx, v: vt) {
182182
let p = extend(cx, i.ident);
183183
for ci in items {
184184
// only need to handle methods
185-
alt ci.node.decl {
186-
class_method(m) {
187-
map_method(d_id, p, m, cx);
188-
}
185+
alt ci.node {
186+
class_method(m) { map_method(d_id, p, m, cx); }
189187
_ {}
190188
}
191189
}

trunk/src/rustc/middle/mutbl.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,8 @@ fn visit_item(item: @item, &&cx: @ctx, v: visit::vt<@ctx>) {
216216
alt item.node {
217217
item_class(tps, items, ctor) {
218218
v.visit_ty_params(tps, cx, v);
219-
vec::map::<@class_item, ()>(items,
220-
{|i| v.visit_class_item(i.span,
221-
i.node.privacy, i.node.decl, cx, v); });
219+
vec::map::<@class_member, ()>(items,
220+
{|i| v.visit_class_item(i, cx, v); });
222221
v.visit_fn(visit::fk_ctor(item.ident, tps), ctor.node.dec,
223222
ctor.node.body, ctor.span, ctor.node.id,
224223
@{in_ctor: some(ctor.node.self_id) with *cx}, v);

trunk/src/rustc/middle/resolve.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ enum mod_index_entry {
8989
mie_import_ident(node_id, span),
9090
mie_item(@ast::item),
9191
mie_class_item(node_id, /* parent class name */
92-
@ast::class_item), /* class member */
92+
@ast::class_member), /* class member */
9393
mie_native_item(@ast::native_item),
9494
mie_enum_variant(/* variant index */uint,
9595
/*parts of enum item*/ [variant],
@@ -533,14 +533,14 @@ fn visit_item_with_scope(e: @env, i: @ast::item, sc: scopes, v: vt<scopes>) {
533533
ctor_scope, v);
534534
/* visit the items */
535535
for cm in members {
536-
alt cm.node.decl {
536+
alt cm.node {
537537
class_method(m) {
538538
let msc = cons(scope_method(m.self_id, tps + m.tps),
539539
@class_scope);
540540
visit_fn_with_scope(e,
541541
visit::fk_item_fn(m.ident, tps), m.decl, m.body,
542542
m.span, m.id, msc, v); }
543-
instance_var(_,t,_,_) { v.visit_ty(t, class_scope, v); }
543+
instance_var(_,t,_,_,_) { v.visit_ty(t, class_scope, v); }
544544
}
545545
}
546546
}
@@ -1161,11 +1161,11 @@ fn lookup_in_fn(e: env, name: ident, decl: ast::fn_decl,
11611161
using the mod_index stuff
11621162
*/
11631163
fn lookup_in_class(parent_id: def_id,
1164-
members: [@class_item], name: ident)
1164+
members: [@class_member], name: ident)
11651165
-> option<def> {
11661166
for m in members {
1167-
alt m.node.decl {
1168-
instance_var(v_name,_,_,id) {
1167+
alt m.node {
1168+
instance_var(v_name,_,_,id,_) {
11691169
if v_name == name {
11701170
ret some(def_class_field(parent_id, local_def(id)));
11711171
}
@@ -1560,8 +1560,8 @@ fn lookup_in_mie(e: env, mie: mod_index_entry, ns: namespace) ->
15601560
}
15611561
}
15621562
mie_class_item(parent_id, class_item) {
1563-
alt class_item.node.decl {
1564-
instance_var(_,_,_,id) {
1563+
alt class_item.node {
1564+
instance_var(_,_,_,id,_) {
15651565
ret some(ast::def_class_field(local_def(parent_id),
15661566
local_def(id)));
15671567
}

trunk/src/rustc/middle/trans/base.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4368,8 +4368,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
43684368

43694369
// Translate methods
43704370
let (_, ms) = ast_util::split_class_items(items);
4371-
impl::trans_impl(ccx, *path, item.ident,
4372-
vec::map(ms, {|m| m.meth}), tps);
4371+
impl::trans_impl(ccx, *path, item.ident, ms, tps);
43734372
}
43744373
_ {/* fall through */ }
43754374
}

trunk/src/rustc/middle/trans/reachable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
101101
item_class(tps, items, ctor) {
102102
cx.rmap.insert(ctor.node.id, ());
103103
for vec::each(items) {|item|
104-
alt item.node.decl {
104+
alt item.node {
105105
class_method(m) {
106106
cx.rmap.insert(m.id, ());
107107
if tps.len() > 0u ||

trunk/src/rustc/middle/ty.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ type param_bounds = @[param_bound];
156156
type method = {ident: ast::ident,
157157
tps: @[param_bounds],
158158
fty: fn_ty,
159-
purity: ast::purity};
159+
purity: ast::purity,
160+
privacy: ast::privacy};
160161

161162
type constr_table = hashmap<ast::node_id, [constr]>;
162163

@@ -2165,7 +2166,7 @@ fn lookup_class_method_ids(cx: ctxt, did: ast::def_id)
21652166
alt cx.items.find(did.node) {
21662167
some(ast_map::node_item(@{node: item_class(_,items,_), _}, _)) {
21672168
let (_,ms) = split_class_items(items);
2168-
vec::map(ms, {|m| {name: m.meth.ident, id: m.meth.id,
2169+
vec::map(ms, {|m| {name: m.ident, id: m.id,
21692170
privacy: m.privacy}})
21702171
}
21712172
_ {
@@ -2176,34 +2177,35 @@ fn lookup_class_method_ids(cx: ctxt, did: ast::def_id)
21762177

21772178
/* Given a class def_id and a method name, return the method's
21782179
def_id. Needed so we can do static dispatch for methods
2179-
Fails if the requested method is private */
2180+
Doesn't care about the method's privacy. (It's assumed that
2181+
the caller already checked that.)
2182+
*/
21802183
fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident,
21812184
sp: span) -> def_id {
21822185
if check is_local(did) {
21832186
let ms = lookup_class_method_ids(cx, did);
21842187
for m in ms {
2185-
if m.name == name && m.privacy == ast::pub {
2188+
if m.name == name {
21862189
ret ast_util::local_def(m.id);
21872190
}
21882191
}
2189-
cx.sess.span_fatal(sp, #fmt("Class doesn't have a public method \
2192+
cx.sess.span_fatal(sp, #fmt("Class doesn't have a method \
21902193
named %s", name));
21912194
}
21922195
else {
21932196
csearch::get_class_method(cx.sess.cstore, did, name)
21942197
}
21952198
}
21962199

2197-
fn class_field_tys(items: [@class_item]) -> [field_ty] {
2200+
fn class_field_tys(items: [@class_member]) -> [field_ty] {
21982201
let mut rslt = [];
21992202
for it in items {
2200-
alt it.node.decl {
2201-
instance_var(nm, _, cm, id) {
2203+
alt it.node {
2204+
instance_var(nm, _, cm, id, privacy) {
22022205
rslt += [{ident: nm, id: ast_util::local_def(id),
2203-
privacy: it.node.privacy, mutability: cm}];
2204-
}
2205-
class_method(_) {
2206+
privacy: privacy, mutability: cm}];
22062207
}
2208+
class_method(_) { }
22072209
}
22082210
}
22092211
rslt

0 commit comments

Comments
 (0)