Skip to content

Commit 2e7ec80

Browse files
committed
librustc: Enforce privacy for static methods.
This starts moving a bunch of privacy checks into the privacy checking phase and out of resolve.
1 parent a14ec73 commit 2e7ec80

File tree

18 files changed

+306
-106
lines changed

18 files changed

+306
-106
lines changed

src/libcore/rt/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ pub fn get() -> &Environment {
4444

4545
extern {
4646
fn rust_get_rt_env() -> &Environment;
47-
}
47+
}

src/libcore/rt/stack.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ pub impl StackSegment {
3737
pub struct StackPool(());
3838

3939
impl StackPool {
40-
41-
static fn new() -> StackPool { StackPool(()) }
40+
static pub fn new() -> StackPool { StackPool(()) }
4241

4342
fn take_segment(&self, min_size: uint) -> StackSegment {
4443
StackSegment::new(min_size)

src/libcore/task/rt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub type rust_task = libc::c_void;
3030
#[allow(non_camel_case_types)] // runtime type
3131
pub type rust_closure = libc::c_void;
3232

33-
extern {
33+
pub extern {
3434
#[rust_stack]
3535
fn rust_task_yield(task: *rust_task) -> bool;
3636

src/librustc/metadata/decoder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ fn item_family(item: ebml::Doc) -> Family {
146146

147147
fn item_visibility(item: ebml::Doc) -> ast::visibility {
148148
let visibility = reader::get_doc(item, tag_items_data_item_visibility);
149+
debug!("item visibility for %?", item_family(item));
149150
match reader::doc_as_u8(visibility) as char {
150151
'y' => ast::public,
151152
'n' => ast::private,

src/librustc/metadata/encoder.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
881881
encode_family(ebml_w, purity_fn_family(mty.fty.purity));
882882
encode_self_type(ebml_w, mty.self_ty);
883883
encode_method_sort(ebml_w, 'r');
884+
encode_visibility(ebml_w, ast::public);
884885
ebml_w.end_tag();
885886
}
886887
provided(m) => {
@@ -896,6 +897,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
896897
encode_family(ebml_w, purity_fn_family(mty.fty.purity));
897898
encode_self_type(ebml_w, mty.self_ty);
898899
encode_method_sort(ebml_w, 'p');
900+
encode_visibility(ebml_w, m.vis);
899901
ebml_w.end_tag();
900902
}
901903
}
@@ -930,6 +932,11 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
930932
let mut m_path = vec::append(~[], path); // :-(
931933
m_path += [ast_map::path_name(item.ident)];
932934
encode_path(ecx, ebml_w, m_path, ast_map::path_name(ty_m.ident));
935+
936+
// For now, use the item visibility until trait methods can have
937+
// real visibility in the AST.
938+
encode_visibility(ebml_w, item.vis);
939+
933940
ebml_w.end_tag();
934941
}
935942
@@ -1018,7 +1025,7 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: writer::Encoder,
10181025
|ni, cx, v| {
10191026
visit::visit_foreign_item(ni, cx, v);
10201027
match ecx.tcx.items.get(&ni.id) {
1021-
ast_map::node_foreign_item(_, abi, pt) => {
1028+
ast_map::node_foreign_item(_, abi, _, pt) => {
10221029
encode_info_for_foreign_item(ecx, ebml_w, ni,
10231030
index, /*bad*/copy *pt,
10241031
abi);

0 commit comments

Comments
 (0)