Skip to content

Commit de7d143

Browse files
committed
Fix existing privacy/visibility violations
This commit fixes all of the fallout of the previous commit which is an attempt to refine privacy. There were a few unfortunate leaks which now must be plugged, and the most horrible one is the current `shouldnt_be_public` module now inside `std::rt`. I think that this either needs a slight reorganization of the runtime, or otherwise it needs to just wait for the external users of these modules to get replaced with their `rt` implementations. Other fixes involve making things pub which should be pub, and otherwise updating error messages that now reference privacy instead of referencing an "unresolved name" (yay!).
1 parent 439e277 commit de7d143

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+168
-111
lines changed

src/libextra/container.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub trait Deque<T> : Mutable {
4040
}
4141

4242
#[cfg(test)]
43-
mod bench {
43+
pub mod bench {
4444
use std::container::MutableMap;
4545
use std::{vec, rand};
4646
use std::rand::Rng;

src/libextra/crypto/cryptoutil.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl <T: FixedBuffer> StandardPadding for T {
346346

347347

348348
#[cfg(test)]
349-
mod test {
349+
pub mod test {
350350
use std::rand::{IsaacRng, Rng};
351351
use std::vec;
352352

src/libextra/stats.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ pub trait Stats {
101101

102102
/// Extracted collection of all the summary statistics of a sample set.
103103
#[deriving(Clone, Eq)]
104-
struct Summary {
104+
#[allow(missing_doc)]
105+
pub struct Summary {
105106
sum: f64,
106107
min: f64,
107108
max: f64,

src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ use syntax::ast_util::id_range;
3131
use syntax::codemap::Span;
3232
use syntax::print::pprust;
3333
use syntax::visit;
34-
use syntax::visit::Visitor;
35-
use syntax::ast::{Expr, fn_kind, fn_decl, Block, NodeId, Stmt, Pat, Local};
34+
use syntax::visit::{Visitor, fn_kind};
35+
use syntax::ast::{Expr, fn_decl, Block, NodeId, Stmt, Pat, Local};
3636

3737
mod lifetime;
3838
mod restrictions;

src/librustc/middle/trans/datum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ impl Datum {
581581

582582
if !header && !ty::type_contents(bcx.tcx(), content_ty).contains_managed() {
583583
let ptr = self.to_value_llval(bcx);
584-
let ty = type_of(bcx.ccx(), content_ty);
584+
let ty = type_of::type_of(bcx.ccx(), content_ty);
585585
let body = PointerCast(bcx, ptr, ty.ptr_to());
586586
Datum {val: body, ty: content_ty, mode: ByRef(ZeroMem)}
587587
} else { // has a header

src/librustc/middle/trans/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
10261026
// which may not be equal to the enum's type for
10271027
// non-C-like enums.
10281028
let val = base::get_item_val(bcx.ccx(), did.node);
1029-
let pty = type_of(bcx.ccx(), const_ty).ptr_to();
1029+
let pty = type_of::type_of(bcx.ccx(), const_ty).ptr_to();
10301030
PointerCast(bcx, val, pty)
10311031
} else {
10321032
{
@@ -1040,7 +1040,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
10401040
}
10411041

10421042
unsafe {
1043-
let llty = type_of(bcx.ccx(), const_ty);
1043+
let llty = type_of::type_of(bcx.ccx(), const_ty);
10441044
let symbol = csearch::get_symbol(
10451045
bcx.ccx().sess.cstore,
10461046
did);
@@ -1396,7 +1396,7 @@ fn trans_unary_datum(bcx: @mut Block,
13961396
heap: heap) -> DatumBlock {
13971397
let _icx = push_ctxt("trans_boxed_expr");
13981398
if heap == heap_exchange {
1399-
let llty = type_of(bcx.ccx(), contents_ty);
1399+
let llty = type_of::type_of(bcx.ccx(), contents_ty);
14001400
let size = llsize_of(bcx.ccx(), llty);
14011401
let Result { bcx: bcx, val: val } = malloc_raw_dyn(bcx, contents_ty,
14021402
heap_exchange, size);

src/librustc/middle/trans/glue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext,
203203
field: uint,
204204
ti: @mut tydesc_info) {
205205
let _icx = push_ctxt("lazily_emit_tydesc_glue");
206-
let llfnty = Type::glue_fn(type_of::type_of(ccx, ti.ty).ptr_to());
206+
let llfnty = Type::glue_fn(type_of(ccx, ti.ty).ptr_to());
207207

208208
if lazily_emit_simplified_tydesc_glue(ccx, field, ti) {
209209
return;
@@ -345,7 +345,7 @@ pub fn make_visit_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
345345
bcx.tcx().sess.fatal(s);
346346
}
347347
};
348-
let v = PointerCast(bcx, v, type_of::type_of(bcx.ccx(), object_ty).ptr_to());
348+
let v = PointerCast(bcx, v, type_of(bcx.ccx(), object_ty).ptr_to());
349349
bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, visitor_trait.def_id);
350350
// The visitor is a boxed object and needs to be dropped
351351
add_clean(bcx, v, object_ty);

src/librustc/middle/typeck/coherence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ impl CoherenceChecker {
330330

331331
let impl_poly_type = ty::lookup_item_type(tcx, impl_id);
332332

333-
let provided = ty::provided_trait_methods(tcx, trait_ref.def_id);
334-
for trait_method in provided.iter() {
333+
let prov = ty::provided_trait_methods(tcx, trait_ref.def_id);
334+
for trait_method in prov.iter() {
335335
// Synthesize an ID.
336336
let new_id = tcx.sess.next_node_id();
337337
let new_did = local_def(new_id);

src/librustdoc/html/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ enum Implementor {
126126
/// to be a fairly large and expensive structure to clone. Instead this adheres
127127
/// to both `Send` and `Freeze` so it may be stored in a `RWArc` instance and
128128
/// shared among the various rendering tasks.
129-
struct Cache {
129+
pub struct Cache {
130130
/// Mapping of typaram ids to the name of the type parameter. This is used
131131
/// when pretty-printing a type (so pretty printing doesn't have to
132132
/// painfully maintain a context like this)

src/librusti/program.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use utils::*;
2424
/// This structure keeps track of the state of the world for the code being
2525
/// executed in rusti.
2626
#[deriving(Clone)]
27-
struct Program {
27+
pub struct Program {
2828
/// All known local variables
2929
local_vars: HashMap<~str, LocalVariable>,
3030
/// New variables which will be present (learned from typechecking)

src/libstd/num/cmath.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ pub mod c_double_utils {
3636
pub fn exp(n: c_double) -> c_double;
3737
// rename: for consistency with underscore usage elsewhere
3838
#[link_name="expm1"]
39-
fn exp_m1(n: c_double) -> c_double;
39+
pub fn exp_m1(n: c_double) -> c_double;
4040
pub fn exp2(n: c_double) -> c_double;
4141
#[link_name="fabs"]
42-
fn abs(n: c_double) -> c_double;
42+
pub fn abs(n: c_double) -> c_double;
4343
// rename: for clarity and consistency with add/sub/mul/div
4444
#[link_name="fdim"]
4545
pub fn abs_sub(a: c_double, b: c_double) -> c_double;

src/libstd/rt/io/buffered.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,15 @@ mod test {
335335
// newtype struct autoderef weirdness
336336
#[test]
337337
fn test_buffered_stream() {
338+
use rt;
338339
struct S;
339340

340-
impl Writer for S {
341+
impl rt::io::Writer for S {
341342
fn write(&mut self, _: &[u8]) {}
342343
fn flush(&mut self) {}
343344
}
344345

345-
impl Reader for S {
346+
impl rt::io::Reader for S {
346347
fn read(&mut self, _: &mut [u8]) -> Option<uint> { None }
347348
fn eof(&mut self) -> bool { true }
348349
}

src/libstd/rt/io/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ pub mod comm_adapters;
300300
mod extensions;
301301

302302
/// Non-I/O things needed by the I/O module
303-
mod support;
303+
// XXX: shouldn this really be pub?
304+
pub mod support;
304305

305306
/// Basic Timer
306307
pub mod timer;

src/libstd/rt/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,27 @@ use rt::local::Local;
6767
use rt::sched::{Scheduler, Shutdown};
6868
use rt::sleeper_list::SleeperList;
6969
use rt::task::{Task, SchedTask, GreenTask, Sched};
70-
use rt::thread::Thread;
71-
use rt::work_queue::WorkQueue;
7270
use rt::uv::uvio::UvEventLoop;
7371
use unstable::atomics::{AtomicInt, SeqCst};
7472
use unstable::sync::UnsafeArc;
7573
use vec;
7674
use vec::{OwnedVector, MutableVector, ImmutableVector};
7775

76+
use self::thread::Thread;
77+
use self::work_queue::WorkQueue;
78+
79+
// XXX: these probably shouldn't be public...
80+
#[doc(hidden)]
81+
pub mod shouldnt_be_public {
82+
pub use super::sched::Scheduler;
83+
pub use super::kill::KillHandle;
84+
pub use super::thread::Thread;
85+
pub use super::work_queue::WorkQueue;
86+
pub use super::select::SelectInner;
87+
pub use super::rtio::EventLoop;
88+
pub use super::select::{SelectInner, SelectPortInner};
89+
}
90+
7891
/// The global (exchange) heap.
7992
pub mod global_heap;
8093

src/libstd/rt/sched.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,12 @@ impl SchedHandle {
803803
self.queue.push(msg);
804804
self.remote.fire();
805805
}
806+
pub fn send_task_from_friend(&mut self, friend: ~Task) {
807+
self.send(TaskFromFriend(friend));
808+
}
809+
pub fn send_shutdown(&mut self) {
810+
self.send(Shutdown);
811+
}
806812
}
807813

808814
struct CleanupJob {

src/libstd/select.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ use iter::{Iterator, DoubleEndedIterator};
1515
use option::*;
1616
// use either::{Either, Left, Right};
1717
// use rt::kill::BlockedTask;
18-
use rt::sched::Scheduler;
19-
use rt::select::{SelectInner, SelectPortInner};
2018
use rt::local::Local;
21-
use rt::rtio::EventLoop;
19+
use rt::shouldnt_be_public::{EventLoop, Scheduler, SelectInner, SelectPortInner};
2220
use task;
2321
use unstable::finally::Finally;
2422
use vec::{OwnedVector, MutableVector};

src/libstd/task/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ pub fn deschedule() {
551551
//! Yield control to the task scheduler
552552
553553
use rt::local::Local;
554-
use rt::sched::Scheduler;
554+
use rt::shouldnt_be_public::Scheduler;
555555

556556
// FIXME(#7544): Optimize this, since we know we won't block.
557557
let sched: ~Scheduler = Local::take();

src/libstd/task/spawn.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,8 @@ use unstable::sync::Exclusive;
8989
use rt::in_green_task_context;
9090
use rt::local::Local;
9191
use rt::task::{Task, Sched};
92-
use rt::kill::KillHandle;
93-
use rt::sched::Scheduler;
92+
use rt::shouldnt_be_public::{Scheduler, KillHandle, WorkQueue, Thread};
9493
use rt::uv::uvio::UvEventLoop;
95-
use rt::thread::Thread;
96-
use rt::work_queue::WorkQueue;
9794

9895
#[cfg(test)] use task::default_task_opts;
9996
#[cfg(test)] use comm;
@@ -556,8 +553,6 @@ fn enlist_many(child: &KillHandle, child_arc: &TaskGroupArc,
556553
}
557554

558555
pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) {
559-
use rt::sched::*;
560-
561556
rtassert!(in_green_task_context());
562557

563558
let child_data = Cell::new(gen_child_taskgroup(opts.linked, opts.supervised));
@@ -622,7 +617,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) {
622617
let mut new_sched_handle = new_sched.make_handle();
623618

624619
// Allow the scheduler to exit when the pinned task exits
625-
new_sched_handle.send(Shutdown);
620+
new_sched_handle.send_shutdown();
626621

627622
// Pin the new task to the new scheduler
628623
let new_task = if opts.watched {
@@ -660,7 +655,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) {
660655
rtdebug!("enqueing join_task");
661656
// Now tell the original scheduler to join with this thread
662657
// by scheduling a thread-joining task on the original scheduler
663-
orig_sched_handle.send(TaskFromFriend(join_task));
658+
orig_sched_handle.send_task_from_friend(join_task);
664659

665660
// NB: We can't simply send a message from here to another task
666661
// because this code isn't running in a task and message passing doesn't

src/libstd/unstable/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ a normal large stack.
3838
*/
3939
pub fn run_in_bare_thread(f: ~fn()) {
4040
use cell::Cell;
41-
use rt::thread::Thread;
41+
use rt::shouldnt_be_public::Thread;
4242

4343
let f_cell = Cell::new(f);
4444
let (port, chan) = comm::stream();

src/libstd/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ mod tests {
9090
use super::*;
9191

9292
use clone::Clone;
93+
use ops::Drop;
9394
use option::{None, Some};
9495
use either::{Either, Left, Right};
9596
use sys::size_of;
96-
use kinds::Drop;
9797

9898
#[test]
9999
fn identity_crisis() {

src/libsyntax/ast_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ mod test {
964964
use super::*;
965965
use std::io;
966966
use opt_vec;
967-
use std::hash::HashMap;
967+
use std::hashmap::HashMap;
968968

969969
fn ident_to_segment(id : &Ident) -> PathSegment {
970970
PathSegment{identifier:id.clone(), lifetime: None, types: opt_vec::Empty}

src/libsyntax/ext/expand.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,8 @@ mod test {
15511551
let varrefs = @mut ~[];
15521552
visit::walk_crate(&mut new_path_finder(varrefs), &renamed_ast, ());
15531553
match varrefs {
1554-
@[Path{segments:[ref seg],_}] => assert_eq!(mtwt_resolve(seg.identifier),a2_name),
1554+
@[ast::Path{segments:[ref seg],_}] =>
1555+
assert_eq!(mtwt_resolve(seg.identifier),a2_name),
15551556
_ => assert_eq!(0,1)
15561557
}
15571558

@@ -1565,7 +1566,8 @@ mod test {
15651566
let varrefs = @mut ~[];
15661567
visit::walk_crate(&mut new_path_finder(varrefs), &double_renamed, ());
15671568
match varrefs {
1568-
@[Path{segments:[ref seg],_}] => assert_eq!(mtwt_resolve(seg.identifier),a3_name),
1569+
@[ast::Path{segments:[ref seg],_}] =>
1570+
assert_eq!(mtwt_resolve(seg.identifier),a3_name),
15691571
_ => assert_eq!(0,1)
15701572
}
15711573
}

src/test/compile-fail/export-import.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern: import
12-
1311
use m::unexported;
12+
//~^ ERROR: is private
1413

1514
mod m {
1615
pub fn exported() { }

src/test/compile-fail/export-tag-variant.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern: unresolved name
12-
1311
mod foo {
1412
pub fn x() { }
1513

1614
enum y { y1, }
1715
}
1816

19-
fn main() { let z = foo::y1; }
17+
fn main() { let z = foo::y1; } //~ ERROR: is private

src/test/compile-fail/issue-3993-2.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use zoo::{duck, goose}; //~ ERROR failed to resolve import
12-
//~^ ERROR unresolved import: found `goose` in `zoo` but it is private
11+
use zoo::{duck, goose}; //~ ERROR: variant `goose` is private
1312

1413
mod zoo {
1514
pub enum bird {
16-
pub duck,
15+
pub duck, //~ ERROR: unnecessary `pub` visibility
1716
priv goose
1817
}
1918
}

src/test/compile-fail/issue-3993-3.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use zoo::fly; //~ ERROR failed to resolve import
12-
//~^ ERROR unresolved import: found `fly` in `zoo` but it is private
11+
use zoo::fly; //~ ERROR: function `fly` is private
1312

1413
mod zoo {
15-
type fly = ();
1614
fn fly() {}
1715
}
1816

1917

20-
fn main() {}
18+
fn main() {
19+
fly();
20+
}

src/test/compile-fail/issue-3993.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use zoo::fly; //~ ERROR failed to resolve import
12-
//~^ ERROR unresolved import: found `fly` in `zoo` but it is private
11+
use zoo::fly; //~ ERROR: function `fly` is private
1312

1413
mod zoo {
1514
fn fly() {}
1615
}
1716

1817

19-
fn main() {}
18+
fn main() {
19+
fly();
20+
}

0 commit comments

Comments
 (0)