Skip to content

Commit 190de43

Browse files
committed
---
yaml --- r: 22974 b: refs/heads/master c: a805a1f h: refs/heads/master v: v3
1 parent 17b08d5 commit 190de43

File tree

11 files changed

+84
-66
lines changed

11 files changed

+84
-66
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: 0c623c4474f439c0bb85b7f91ae663d9584e7973
2+
refs/heads/master: a805a1fb37443601819604954510cb312a724fe9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ type attribute_ = {style: attr_style, value: meta_item, is_sugared_doc: bool};
700700
type trait_ref = {path: @path, ref_id: node_id, impl_id: node_id};
701701

702702
#[auto_serialize]
703-
enum visibility { public, private }
703+
enum visibility { public, private, inherited }
704704

705705
#[auto_serialize]
706706
type item = {ident: ident, attrs: ~[attribute],

trunk/src/libsyntax/ext/pipes/pipec.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ impl parse_utils of ext_ctxt_parse_utils for ext_ctxt {
437437
@(copy s),
438438
self.cfg(),
439439
~[],
440-
ast::public,
441440
self.parse_sess());
442441
alt res {
443442
some(ast) { ast }

trunk/src/libsyntax/ext/qquote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fn parse_expr(p: parser) -> @ast::expr { p.parse_expr() }
183183
fn parse_pat(p: parser) -> @ast::pat { p.parse_pat(true) }
184184

185185
fn parse_item(p: parser) -> @ast::item {
186-
alt p.parse_item(~[], ast::public) {
186+
alt p.parse_item(~[]) {
187187
some(item) { item }
188188
none { fail ~"parse_item: parsing an item failed"; }
189189
}

trunk/src/libsyntax/ext/tt/earley_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
320320
321321
fn parse_nt(p: parser, name: ~str) -> nonterminal {
322322
alt name {
323-
~"item" { alt p.parse_item(~[], ast::public) {
323+
~"item" { alt p.parse_item(~[]) {
324324
some(i) { token::nt_item(i) }
325325
none { p.fatal(~"expected an item keyword") }
326326
}}

trunk/src/libsyntax/parse.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,10 @@ fn parse_expr_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg,
120120
121121
fn parse_item_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg,
122122
+attrs: ~[ast::attribute],
123-
vis: ast::visibility,
124123
sess: parse_sess) -> option<@ast::item> {
125124
let (p, rdr) = new_parser_etc_from_source_str(sess, cfg, name,
126125
codemap::fss_none, source);
127-
let r = p.parse_item(attrs, vis);
126+
let r = p.parse_item(attrs);
128127
sess.chpos = rdr.chpos;
129128
sess.byte_pos = sess.byte_pos + rdr.pos;
130129
return r;

trunk/src/libsyntax/parse/parser.rs

Lines changed: 61 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@ import ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
3131
expr_rec, expr_ret, expr_swap, expr_struct, expr_tup, expr_unary,
3232
expr_unary_move, expr_vec, expr_vstore, expr_while, extern_fn,
3333
field, fn_decl, foreign_item, foreign_item_fn, foreign_mod,
34-
ident, impure_fn, infer, init_assign, init_move, initializer,
35-
instance_var, item, item_, item_class, item_const, item_enum,
36-
item_fn, item_foreign_mod, item_impl, item_mac, item_mod,
37-
item_trait, item_ty, lit, lit_, lit_bool, lit_float, lit_int,
38-
lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local, m_const,
39-
m_imm, m_mutbl, mac_, mac_aq, mac_ellipsis,
40-
mac_invoc, mac_invoc_tt, mac_var, matcher, match_nonterminal,
41-
match_seq, match_tok, method, mode, mt, mul, mutability, neg,
42-
noreturn, not, pat, pat_box, pat_enum, pat_ident, pat_lit,
43-
pat_range, pat_rec, pat_tup, pat_uniq, pat_wild, path, private,
44-
proto, proto_any, proto_bare, proto_block, proto_box, proto_uniq,
45-
provided, public, pure_fn, purity, re_anon, re_named, region,
46-
rem, required, ret_style, return_val, self_ty, shl, shr, stmt,
47-
stmt_decl, stmt_expr, stmt_semi, subtract, sty_box, sty_by_ref,
48-
sty_region, sty_uniq, sty_value, token_tree, trait_method,
49-
trait_ref, tt_delim, tt_seq, tt_tok, tt_nonterminal, ty, ty_,
50-
ty_bot, ty_box, ty_field, ty_fn, ty_infer, ty_mac, ty_method,
51-
ty_nil, ty_param, ty_path, ty_ptr, ty_rec, ty_rptr, ty_tup,
52-
ty_u32, ty_uniq, ty_vec, ty_fixed_length, unchecked_blk, uniq,
34+
ident, impure_fn, infer, inherited, init_assign, init_move,
35+
initializer, instance_var, item, item_, item_class, item_const,
36+
item_enum, item_fn, item_foreign_mod, item_impl, item_mac,
37+
item_mod, item_trait, item_ty, lit, lit_, lit_bool, lit_float,
38+
lit_int, lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local,
39+
m_const, m_imm, m_mutbl, mac_, mac_aq, mac_ellipsis, mac_invoc,
40+
mac_invoc_tt, mac_var, matcher, match_nonterminal, match_seq,
41+
match_tok, method, mode, mt, mul, mutability, neg, noreturn, not,
42+
pat, pat_box, pat_enum, pat_ident, pat_lit, pat_range, pat_rec,
43+
pat_tup, pat_uniq, pat_wild, path, private, proto, proto_any,
44+
proto_bare, proto_block, proto_box, proto_uniq, provided, public,
45+
pure_fn, purity, re_anon, re_named, region, rem, required,
46+
ret_style, return_val, self_ty, shl, shr, stmt, stmt_decl,
47+
stmt_expr, stmt_semi, subtract, sty_box, sty_by_ref, sty_region,
48+
sty_uniq, sty_value, token_tree, trait_method, trait_ref,
49+
tt_delim, tt_seq, tt_tok, tt_nonterminal, ty, ty_, ty_bot,
50+
ty_box, ty_field, ty_fn, ty_infer, ty_mac, ty_method, ty_nil,
51+
ty_param, ty_path, ty_ptr, ty_rec, ty_rptr, ty_tup, ty_u32,
52+
ty_uniq, ty_vec, ty_fixed_length, unchecked_blk, uniq,
5353
unsafe_blk, unsafe_fn, variant, view_item, view_item_,
5454
view_item_export, view_item_import, view_item_use, view_path,
5555
view_path_glob, view_path_list, view_path_simple, visibility,
@@ -273,7 +273,7 @@ class parser {
273273
let pur = p.parse_fn_purity();
274274
// NB: at the moment, trait methods are public by default; this
275275
// could change.
276-
let vis = p.parse_visibility(public);
276+
let vis = p.parse_visibility();
277277
let ident = p.parse_method_name();
278278
let tps = p.parse_ty_params();
279279
let d = p.parse_ty_fn_decl(pur);
@@ -1873,7 +1873,7 @@ class parser {
18731873

18741874
let item_attrs = vec::append(first_item_attrs, item_attrs);
18751875

1876-
alt self.parse_item(item_attrs, public) {
1876+
alt self.parse_item(item_attrs) {
18771877
some(i) {
18781878
let mut hi = i.span.hi;
18791879
let decl = @spanned(lo, hi, decl_item(i));
@@ -2459,8 +2459,7 @@ class parser {
24592459
}
24602460
}
24612461
2462-
fn parse_single_class_item(vis: visibility)
2463-
-> @class_member {
2462+
fn parse_single_class_item(vis: visibility) -> @class_member {
24642463
if (self.eat_keyword(~"let") ||
24652464
self.token_is_keyword(~"mut", copy self.token) ||
24662465
!self.is_any_keyword(copy self.token)) &&
@@ -2491,17 +2490,27 @@ class parser {
24912490
dtor_decl(body, attrs, mk_sp(lo, self.last_span.hi))
24922491
}
24932492

2494-
fn parse_class_item(class_name_with_tps: @path)
2495-
-> class_contents {
2496-
2493+
fn parse_class_item(class_name_with_tps: @path) -> class_contents {
24972494
if self.eat_keyword(~"priv") {
2498-
self.expect(token::LBRACE);
2499-
let mut results = ~[];
2500-
while self.token != token::RBRACE {
2501-
vec::push(results, self.parse_single_class_item(private));
2495+
// XXX: Remove after snapshot.
2496+
match self.token {
2497+
token::LBRACE => {
2498+
self.bump();
2499+
let mut results = ~[];
2500+
while self.token != token::RBRACE {
2501+
vec::push(results,
2502+
self.parse_single_class_item(private));
2503+
}
2504+
self.bump();
2505+
return members(results);
2506+
}
2507+
_ =>
2508+
return members(~[self.parse_single_class_item(private)])
25022509
}
2503-
self.bump();
2504-
return members(results);
2510+
}
2511+
2512+
if self.eat_keyword(~"pub") {
2513+
return members(~[self.parse_single_class_item(public)]);
25052514
}
25062515

25072516
let attrs = self.parse_outer_attributes();
@@ -2515,14 +2524,14 @@ class parser {
25152524
return self.parse_dtor(attrs);
25162525
}
25172526
else {
2518-
return members(~[self.parse_single_class_item(public)]);
2527+
return members(~[self.parse_single_class_item(inherited)]);
25192528
}
25202529
}
25212530

2522-
fn parse_visibility(def: visibility) -> visibility {
2531+
fn parse_visibility() -> visibility {
25232532
if self.eat_keyword(~"pub") { public }
25242533
else if self.eat_keyword(~"priv") { private }
2525-
else { def }
2534+
else { inherited }
25262535
}
25272536

25282537
fn parse_mod_items(term: token::token,
@@ -2539,8 +2548,7 @@ class parser {
25392548
first = false;
25402549
}
25412550
debug!{"parse_mod_items: parse_item(attrs=%?)", attrs};
2542-
let vis = self.parse_visibility(private);
2543-
alt self.parse_item(attrs, vis) {
2551+
alt self.parse_item(attrs) {
25442552
some(i) { vec::push(items, i); }
25452553
_ {
25462554
self.fatal(~"expected item but found `" +
@@ -2661,7 +2669,7 @@ class parser {
26612669
}
26622670
}
26632671

2664-
fn parse_item_enum(default_vis: visibility) -> item_info {
2672+
fn parse_item_enum() -> item_info {
26652673
let id = self.parse_ident();
26662674
self.parse_region_param();
26672675
let ty_params = self.parse_ty_params();
@@ -2689,7 +2697,7 @@ class parser {
26892697
while self.token != token::RBRACE {
26902698
let variant_attrs = self.parse_outer_attributes();
26912699
let vlo = self.span.lo;
2692-
let vis = self.parse_visibility(default_vis);
2700+
let vis = self.parse_visibility();
26932701
let ident = self.parse_value_ident();
26942702
let mut args = ~[], disr_expr = none;
26952703
if self.token == token::LPAREN {
@@ -2752,11 +2760,19 @@ class parser {
27522760
}
27532761
}
27542762

2755-
fn parse_item(+attrs: ~[attribute], vis: visibility)
2756-
-> option<@item> {
2757-
2763+
fn parse_item(+attrs: ~[attribute]) -> option<@item> {
27582764
maybe_whole!{some self,nt_item};
27592765
let lo = self.span.lo;
2766+
2767+
let visibility;
2768+
if self.eat_keyword(~"pub") {
2769+
visibility = public;
2770+
} else if self.eat_keyword(~"priv") {
2771+
visibility = private;
2772+
} else {
2773+
visibility = inherited;
2774+
}
2775+
27602776
let (ident, item_, extra_attrs) = if self.eat_keyword(~"const") {
27612777
self.parse_item_const()
27622778
} else if self.is_keyword(~"fn") &&
@@ -2782,7 +2798,7 @@ class parser {
27822798
} else if self.eat_keyword(~"type") {
27832799
self.parse_item_type()
27842800
} else if self.eat_keyword(~"enum") {
2785-
self.parse_item_enum(vis)
2801+
self.parse_item_enum()
27862802
} else if self.eat_keyword(~"iface") {
27872803
self.warn(~"`iface` is deprecated; use `trait`");
27882804
self.parse_item_trait()
@@ -2816,7 +2832,7 @@ class parser {
28162832
expn_info: none}};
28172833
(id, item_mac(m), none)
28182834
} else { return none; };
2819-
some(self.mk_item(lo, self.last_span.hi, ident, item_, vis,
2835+
some(self.mk_item(lo, self.last_span.hi, ident, item_, visibility,
28202836
alt extra_attrs {
28212837
some(as) { vec::append(attrs, as) }
28222838
none { attrs }
@@ -2917,7 +2933,7 @@ class parser {
29172933
}
29182934

29192935
fn parse_view_item(+attrs: ~[attribute]) -> @view_item {
2920-
let lo = self.span.lo, vis = self.parse_visibility(private);
2936+
let lo = self.span.lo, vis = self.parse_visibility();
29212937
let node = if self.eat_keyword(~"use") {
29222938
self.parse_use()
29232939
} else if self.eat_keyword(~"import") {

trunk/src/rustc/front/intrinsic_inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn inject_intrinsic(sess: session,
1212
let item = parse::parse_item_from_source_str(~"<intrinsic>",
1313
intrinsic_module,
1414
sess.opts.cfg,
15-
~[], ast::public,
15+
~[],
1616
sess.parse_sess);
1717
let item =
1818
alt item {

trunk/src/rustc/metadata/decoder.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn item_to_def_like(item: ebml::doc, did: ast::def_id, cnum: ast::crate_num)
294294
}
295295
'I' { dl_def(ast::def_ty(did)) }
296296
'i' { dl_impl(did) }
297-
'g' | 'j' { dl_field }
297+
'g' | 'j' | 'N' => { dl_field }
298298
ch { fail fmt!{"unexpected family code: '%c'", ch} }
299299
}
300300
}
@@ -741,14 +741,16 @@ fn get_class_members(cdata: cmd, id: ast::node_id,
741741

742742
pure fn family_to_visibility(family: char) -> ast::visibility {
743743
alt family {
744-
'g' { ast::public }
745-
_ { ast::private }
744+
'g' => ast::public,
745+
'j' => ast::private,
746+
'N' => ast::inherited,
747+
_ => fail
746748
}
747749
}
748750

749-
/* 'g' for public field, 'j' for private field */
751+
/* 'g' for public field, 'j' for private field, 'N' for inherited field */
750752
fn get_class_fields(cdata: cmd, id: ast::node_id) -> ~[ty::field_ty] {
751-
get_class_members(cdata, id, |f| f == 'g' || f == 'j')
753+
get_class_members(cdata, id, |f| f == 'g' || f == 'j' || f == 'N')
752754
}
753755

754756
fn family_has_type_params(fam_ch: char) -> bool {
@@ -802,6 +804,7 @@ fn item_family_to_str(fam: char) -> ~str {
802804
'S' { return ~"struct"; }
803805
'g' { return ~"public field"; }
804806
'j' { return ~"private field"; }
807+
'N' { return ~"inherited field"; }
805808
}
806809
}
807810

trunk/src/rustc/metadata/encoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ fn encode_class_item_paths(ebml_w: ebml::writer,
144144
for items.each |it| {
145145
alt ast_util::class_member_visibility(it) {
146146
private { again; }
147-
public {
147+
public | inherited {
148148
let (id, ident) = alt it.node {
149149
instance_var(v, _, _, vid, _) { (vid, v) }
150150
class_method(it) { (it.id, it.ident) }
@@ -434,7 +434,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
434434

435435
fn encode_visibility(ebml_w: ebml::writer, visibility: visibility) {
436436
encode_family(ebml_w, alt visibility {
437-
public { 'g' } private { 'j' }
437+
public { 'g' } private { 'j' } inherited { 'N' }
438438
});
439439
}
440440

@@ -519,7 +519,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
519519
}
520520
class_method(m) {
521521
alt m.vis {
522-
public {
522+
public | inherited {
523523
vec::push(*index, {val: m.id, pos: ebml_w.writer.tell()});
524524
vec::push(*global_index,
525525
{val: m.id, pos: ebml_w.writer.tell()});
@@ -756,7 +756,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
756756
for ms.each |m| {
757757
alt m.vis {
758758
private { /* do nothing */ }
759-
public {
759+
public | inherited {
760760
/* Write the info that's needed when viewing this class
761761
as a trait */
762762
ebml_w.start_tag(tag_item_trait_method);

trunk/src/rustc/middle/ty.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2940,10 +2940,11 @@ fn lookup_public_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
29402940
}
29412941

29422942
pure fn is_public(f: field_ty) -> bool {
2943-
alt f.vis {
2944-
public { true }
2945-
private { false }
2946-
}
2943+
// XXX: This is wrong.
2944+
match f.vis {
2945+
public | inherited => true,
2946+
private => false
2947+
}
29472948
}
29482949

29492950
/* Given a class def_id and a method name, return the method's

0 commit comments

Comments
 (0)