diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-03-18 17:20:45 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-03-19 13:40:48 -0700 |
| commit | 2e7ec80bcce454d55d31c6bd335bb2ad64a7298e (patch) | |
| tree | 02bbd5d40bbf7873fd32c87ea81f5e0012502a6c /src/libsyntax | |
| parent | a14ec73cd2d15a2454113011835557ccf447f14d (diff) | |
| download | rust-2e7ec80bcce454d55d31c6bd335bb2ad64a7298e.tar.gz rust-2e7ec80bcce454d55d31c6bd335bb2ad64a7298e.zip | |
librustc: Enforce privacy for static methods.
This starts moving a bunch of privacy checks into the privacy checking phase and out of resolve.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_map.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 5266d1b049a..9371055556e 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -87,7 +87,7 @@ pub fn path_elt_to_str(pe: path_elt, itr: @ident_interner) -> ~str { pub enum ast_node { node_item(@item, @path), - node_foreign_item(@foreign_item, foreign_abi, @path), + node_foreign_item(@foreign_item, foreign_abi, visibility, @path), node_trait_method(@trait_method, def_id /* trait did */, @path /* path to the trait */), node_method(@method, def_id /* impl did */, @path /* path to the impl */), @@ -170,7 +170,9 @@ pub fn map_decoded_item(diag: @span_handler, match ii { ii_item(*) | ii_dtor(*) => { /* fallthrough */ } ii_foreign(i) => { - cx.map.insert(i.id, node_foreign_item(i, foreign_abi_rust_intrinsic, + cx.map.insert(i.id, node_foreign_item(i, + foreign_abi_rust_intrinsic, + i.vis, // Wrong but OK @path)); } ii_method(impl_did, m) => { @@ -277,10 +279,18 @@ pub fn map_item(i: @item, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) { Right(abi) => abi }; for nm.items.each |nitem| { + // Compute the visibility for this native item. + let visibility = match nitem.vis { + public => public, + private => private, + inherited => i.vis + }; + cx.map.insert(nitem.id, node_foreign_item( *nitem, abi, + visibility, // FIXME (#2543) if nm.sort == ast::named { extend(cx, i.ident) @@ -380,7 +390,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str { }; fmt!("%s %s (id=%?)", item_str, path_str, id) } - Some(node_foreign_item(item, abi, path)) => { + Some(node_foreign_item(item, abi, _, path)) => { fmt!("foreign item %s with abi %? (id=%?)", path_ident_to_str(*path, item.ident, itr), abi, id) } |
