mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
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!).
This commit is contained in:
parent
439e2770be
commit
de7d143176
@ -40,7 +40,7 @@ pub trait Deque<T> : Mutable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod bench {
|
pub mod bench {
|
||||||
use std::container::MutableMap;
|
use std::container::MutableMap;
|
||||||
use std::{vec, rand};
|
use std::{vec, rand};
|
||||||
use std::rand::Rng;
|
use std::rand::Rng;
|
||||||
|
@ -346,7 +346,7 @@ impl <T: FixedBuffer> StandardPadding for T {
|
|||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
pub mod test {
|
||||||
use std::rand::{IsaacRng, Rng};
|
use std::rand::{IsaacRng, Rng};
|
||||||
use std::vec;
|
use std::vec;
|
||||||
|
|
||||||
|
@ -101,7 +101,8 @@ pub trait Stats {
|
|||||||
|
|
||||||
/// Extracted collection of all the summary statistics of a sample set.
|
/// Extracted collection of all the summary statistics of a sample set.
|
||||||
#[deriving(Clone, Eq)]
|
#[deriving(Clone, Eq)]
|
||||||
struct Summary {
|
#[allow(missing_doc)]
|
||||||
|
pub struct Summary {
|
||||||
sum: f64,
|
sum: f64,
|
||||||
min: f64,
|
min: f64,
|
||||||
max: f64,
|
max: f64,
|
||||||
|
@ -31,8 +31,8 @@ use syntax::ast_util::id_range;
|
|||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::print::pprust;
|
use syntax::print::pprust;
|
||||||
use syntax::visit;
|
use syntax::visit;
|
||||||
use syntax::visit::Visitor;
|
use syntax::visit::{Visitor, fn_kind};
|
||||||
use syntax::ast::{Expr, fn_kind, fn_decl, Block, NodeId, Stmt, Pat, Local};
|
use syntax::ast::{Expr, fn_decl, Block, NodeId, Stmt, Pat, Local};
|
||||||
|
|
||||||
mod lifetime;
|
mod lifetime;
|
||||||
mod restrictions;
|
mod restrictions;
|
||||||
|
@ -581,7 +581,7 @@ impl Datum {
|
|||||||
|
|
||||||
if !header && !ty::type_contents(bcx.tcx(), content_ty).contains_managed() {
|
if !header && !ty::type_contents(bcx.tcx(), content_ty).contains_managed() {
|
||||||
let ptr = self.to_value_llval(bcx);
|
let ptr = self.to_value_llval(bcx);
|
||||||
let ty = type_of(bcx.ccx(), content_ty);
|
let ty = type_of::type_of(bcx.ccx(), content_ty);
|
||||||
let body = PointerCast(bcx, ptr, ty.ptr_to());
|
let body = PointerCast(bcx, ptr, ty.ptr_to());
|
||||||
Datum {val: body, ty: content_ty, mode: ByRef(ZeroMem)}
|
Datum {val: body, ty: content_ty, mode: ByRef(ZeroMem)}
|
||||||
} else { // has a header
|
} else { // has a header
|
||||||
|
@ -1026,7 +1026,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
|
|||||||
// which may not be equal to the enum's type for
|
// which may not be equal to the enum's type for
|
||||||
// non-C-like enums.
|
// non-C-like enums.
|
||||||
let val = base::get_item_val(bcx.ccx(), did.node);
|
let val = base::get_item_val(bcx.ccx(), did.node);
|
||||||
let pty = type_of(bcx.ccx(), const_ty).ptr_to();
|
let pty = type_of::type_of(bcx.ccx(), const_ty).ptr_to();
|
||||||
PointerCast(bcx, val, pty)
|
PointerCast(bcx, val, pty)
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
@ -1040,7 +1040,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let llty = type_of(bcx.ccx(), const_ty);
|
let llty = type_of::type_of(bcx.ccx(), const_ty);
|
||||||
let symbol = csearch::get_symbol(
|
let symbol = csearch::get_symbol(
|
||||||
bcx.ccx().sess.cstore,
|
bcx.ccx().sess.cstore,
|
||||||
did);
|
did);
|
||||||
@ -1396,7 +1396,7 @@ fn trans_unary_datum(bcx: @mut Block,
|
|||||||
heap: heap) -> DatumBlock {
|
heap: heap) -> DatumBlock {
|
||||||
let _icx = push_ctxt("trans_boxed_expr");
|
let _icx = push_ctxt("trans_boxed_expr");
|
||||||
if heap == heap_exchange {
|
if heap == heap_exchange {
|
||||||
let llty = type_of(bcx.ccx(), contents_ty);
|
let llty = type_of::type_of(bcx.ccx(), contents_ty);
|
||||||
let size = llsize_of(bcx.ccx(), llty);
|
let size = llsize_of(bcx.ccx(), llty);
|
||||||
let Result { bcx: bcx, val: val } = malloc_raw_dyn(bcx, contents_ty,
|
let Result { bcx: bcx, val: val } = malloc_raw_dyn(bcx, contents_ty,
|
||||||
heap_exchange, size);
|
heap_exchange, size);
|
||||||
|
@ -203,7 +203,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext,
|
|||||||
field: uint,
|
field: uint,
|
||||||
ti: @mut tydesc_info) {
|
ti: @mut tydesc_info) {
|
||||||
let _icx = push_ctxt("lazily_emit_tydesc_glue");
|
let _icx = push_ctxt("lazily_emit_tydesc_glue");
|
||||||
let llfnty = Type::glue_fn(type_of::type_of(ccx, ti.ty).ptr_to());
|
let llfnty = Type::glue_fn(type_of(ccx, ti.ty).ptr_to());
|
||||||
|
|
||||||
if lazily_emit_simplified_tydesc_glue(ccx, field, ti) {
|
if lazily_emit_simplified_tydesc_glue(ccx, field, ti) {
|
||||||
return;
|
return;
|
||||||
@ -345,7 +345,7 @@ pub fn make_visit_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
|
|||||||
bcx.tcx().sess.fatal(s);
|
bcx.tcx().sess.fatal(s);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let v = PointerCast(bcx, v, type_of::type_of(bcx.ccx(), object_ty).ptr_to());
|
let v = PointerCast(bcx, v, type_of(bcx.ccx(), object_ty).ptr_to());
|
||||||
bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, visitor_trait.def_id);
|
bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, visitor_trait.def_id);
|
||||||
// The visitor is a boxed object and needs to be dropped
|
// The visitor is a boxed object and needs to be dropped
|
||||||
add_clean(bcx, v, object_ty);
|
add_clean(bcx, v, object_ty);
|
||||||
|
@ -330,8 +330,8 @@ impl CoherenceChecker {
|
|||||||
|
|
||||||
let impl_poly_type = ty::lookup_item_type(tcx, impl_id);
|
let impl_poly_type = ty::lookup_item_type(tcx, impl_id);
|
||||||
|
|
||||||
let provided = ty::provided_trait_methods(tcx, trait_ref.def_id);
|
let prov = ty::provided_trait_methods(tcx, trait_ref.def_id);
|
||||||
for trait_method in provided.iter() {
|
for trait_method in prov.iter() {
|
||||||
// Synthesize an ID.
|
// Synthesize an ID.
|
||||||
let new_id = tcx.sess.next_node_id();
|
let new_id = tcx.sess.next_node_id();
|
||||||
let new_did = local_def(new_id);
|
let new_did = local_def(new_id);
|
||||||
|
@ -126,7 +126,7 @@ enum Implementor {
|
|||||||
/// to be a fairly large and expensive structure to clone. Instead this adheres
|
/// to be a fairly large and expensive structure to clone. Instead this adheres
|
||||||
/// to both `Send` and `Freeze` so it may be stored in a `RWArc` instance and
|
/// to both `Send` and `Freeze` so it may be stored in a `RWArc` instance and
|
||||||
/// shared among the various rendering tasks.
|
/// shared among the various rendering tasks.
|
||||||
struct Cache {
|
pub struct Cache {
|
||||||
/// Mapping of typaram ids to the name of the type parameter. This is used
|
/// Mapping of typaram ids to the name of the type parameter. This is used
|
||||||
/// when pretty-printing a type (so pretty printing doesn't have to
|
/// when pretty-printing a type (so pretty printing doesn't have to
|
||||||
/// painfully maintain a context like this)
|
/// painfully maintain a context like this)
|
||||||
|
@ -24,7 +24,7 @@ use utils::*;
|
|||||||
/// This structure keeps track of the state of the world for the code being
|
/// This structure keeps track of the state of the world for the code being
|
||||||
/// executed in rusti.
|
/// executed in rusti.
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
struct Program {
|
pub struct Program {
|
||||||
/// All known local variables
|
/// All known local variables
|
||||||
local_vars: HashMap<~str, LocalVariable>,
|
local_vars: HashMap<~str, LocalVariable>,
|
||||||
/// New variables which will be present (learned from typechecking)
|
/// New variables which will be present (learned from typechecking)
|
||||||
|
@ -36,10 +36,10 @@ pub mod c_double_utils {
|
|||||||
pub fn exp(n: c_double) -> c_double;
|
pub fn exp(n: c_double) -> c_double;
|
||||||
// rename: for consistency with underscore usage elsewhere
|
// rename: for consistency with underscore usage elsewhere
|
||||||
#[link_name="expm1"]
|
#[link_name="expm1"]
|
||||||
fn exp_m1(n: c_double) -> c_double;
|
pub fn exp_m1(n: c_double) -> c_double;
|
||||||
pub fn exp2(n: c_double) -> c_double;
|
pub fn exp2(n: c_double) -> c_double;
|
||||||
#[link_name="fabs"]
|
#[link_name="fabs"]
|
||||||
fn abs(n: c_double) -> c_double;
|
pub fn abs(n: c_double) -> c_double;
|
||||||
// rename: for clarity and consistency with add/sub/mul/div
|
// rename: for clarity and consistency with add/sub/mul/div
|
||||||
#[link_name="fdim"]
|
#[link_name="fdim"]
|
||||||
pub fn abs_sub(a: c_double, b: c_double) -> c_double;
|
pub fn abs_sub(a: c_double, b: c_double) -> c_double;
|
||||||
|
@ -335,14 +335,15 @@ mod test {
|
|||||||
// newtype struct autoderef weirdness
|
// newtype struct autoderef weirdness
|
||||||
#[test]
|
#[test]
|
||||||
fn test_buffered_stream() {
|
fn test_buffered_stream() {
|
||||||
|
use rt;
|
||||||
struct S;
|
struct S;
|
||||||
|
|
||||||
impl Writer for S {
|
impl rt::io::Writer for S {
|
||||||
fn write(&mut self, _: &[u8]) {}
|
fn write(&mut self, _: &[u8]) {}
|
||||||
fn flush(&mut self) {}
|
fn flush(&mut self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reader for S {
|
impl rt::io::Reader for S {
|
||||||
fn read(&mut self, _: &mut [u8]) -> Option<uint> { None }
|
fn read(&mut self, _: &mut [u8]) -> Option<uint> { None }
|
||||||
fn eof(&mut self) -> bool { true }
|
fn eof(&mut self) -> bool { true }
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,8 @@ pub mod comm_adapters;
|
|||||||
mod extensions;
|
mod extensions;
|
||||||
|
|
||||||
/// Non-I/O things needed by the I/O module
|
/// Non-I/O things needed by the I/O module
|
||||||
mod support;
|
// XXX: shouldn this really be pub?
|
||||||
|
pub mod support;
|
||||||
|
|
||||||
/// Basic Timer
|
/// Basic Timer
|
||||||
pub mod timer;
|
pub mod timer;
|
||||||
|
@ -67,14 +67,27 @@ use rt::local::Local;
|
|||||||
use rt::sched::{Scheduler, Shutdown};
|
use rt::sched::{Scheduler, Shutdown};
|
||||||
use rt::sleeper_list::SleeperList;
|
use rt::sleeper_list::SleeperList;
|
||||||
use rt::task::{Task, SchedTask, GreenTask, Sched};
|
use rt::task::{Task, SchedTask, GreenTask, Sched};
|
||||||
use rt::thread::Thread;
|
|
||||||
use rt::work_queue::WorkQueue;
|
|
||||||
use rt::uv::uvio::UvEventLoop;
|
use rt::uv::uvio::UvEventLoop;
|
||||||
use unstable::atomics::{AtomicInt, SeqCst};
|
use unstable::atomics::{AtomicInt, SeqCst};
|
||||||
use unstable::sync::UnsafeArc;
|
use unstable::sync::UnsafeArc;
|
||||||
use vec;
|
use vec;
|
||||||
use vec::{OwnedVector, MutableVector, ImmutableVector};
|
use vec::{OwnedVector, MutableVector, ImmutableVector};
|
||||||
|
|
||||||
|
use self::thread::Thread;
|
||||||
|
use self::work_queue::WorkQueue;
|
||||||
|
|
||||||
|
// XXX: these probably shouldn't be public...
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub mod shouldnt_be_public {
|
||||||
|
pub use super::sched::Scheduler;
|
||||||
|
pub use super::kill::KillHandle;
|
||||||
|
pub use super::thread::Thread;
|
||||||
|
pub use super::work_queue::WorkQueue;
|
||||||
|
pub use super::select::SelectInner;
|
||||||
|
pub use super::rtio::EventLoop;
|
||||||
|
pub use super::select::{SelectInner, SelectPortInner};
|
||||||
|
}
|
||||||
|
|
||||||
/// The global (exchange) heap.
|
/// The global (exchange) heap.
|
||||||
pub mod global_heap;
|
pub mod global_heap;
|
||||||
|
|
||||||
|
@ -803,6 +803,12 @@ impl SchedHandle {
|
|||||||
self.queue.push(msg);
|
self.queue.push(msg);
|
||||||
self.remote.fire();
|
self.remote.fire();
|
||||||
}
|
}
|
||||||
|
pub fn send_task_from_friend(&mut self, friend: ~Task) {
|
||||||
|
self.send(TaskFromFriend(friend));
|
||||||
|
}
|
||||||
|
pub fn send_shutdown(&mut self) {
|
||||||
|
self.send(Shutdown);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CleanupJob {
|
struct CleanupJob {
|
||||||
|
@ -15,10 +15,8 @@ use iter::{Iterator, DoubleEndedIterator};
|
|||||||
use option::*;
|
use option::*;
|
||||||
// use either::{Either, Left, Right};
|
// use either::{Either, Left, Right};
|
||||||
// use rt::kill::BlockedTask;
|
// use rt::kill::BlockedTask;
|
||||||
use rt::sched::Scheduler;
|
|
||||||
use rt::select::{SelectInner, SelectPortInner};
|
|
||||||
use rt::local::Local;
|
use rt::local::Local;
|
||||||
use rt::rtio::EventLoop;
|
use rt::shouldnt_be_public::{EventLoop, Scheduler, SelectInner, SelectPortInner};
|
||||||
use task;
|
use task;
|
||||||
use unstable::finally::Finally;
|
use unstable::finally::Finally;
|
||||||
use vec::{OwnedVector, MutableVector};
|
use vec::{OwnedVector, MutableVector};
|
||||||
|
@ -551,7 +551,7 @@ pub fn deschedule() {
|
|||||||
//! Yield control to the task scheduler
|
//! Yield control to the task scheduler
|
||||||
|
|
||||||
use rt::local::Local;
|
use rt::local::Local;
|
||||||
use rt::sched::Scheduler;
|
use rt::shouldnt_be_public::Scheduler;
|
||||||
|
|
||||||
// FIXME(#7544): Optimize this, since we know we won't block.
|
// FIXME(#7544): Optimize this, since we know we won't block.
|
||||||
let sched: ~Scheduler = Local::take();
|
let sched: ~Scheduler = Local::take();
|
||||||
|
@ -89,11 +89,8 @@ use unstable::sync::Exclusive;
|
|||||||
use rt::in_green_task_context;
|
use rt::in_green_task_context;
|
||||||
use rt::local::Local;
|
use rt::local::Local;
|
||||||
use rt::task::{Task, Sched};
|
use rt::task::{Task, Sched};
|
||||||
use rt::kill::KillHandle;
|
use rt::shouldnt_be_public::{Scheduler, KillHandle, WorkQueue, Thread};
|
||||||
use rt::sched::Scheduler;
|
|
||||||
use rt::uv::uvio::UvEventLoop;
|
use rt::uv::uvio::UvEventLoop;
|
||||||
use rt::thread::Thread;
|
|
||||||
use rt::work_queue::WorkQueue;
|
|
||||||
|
|
||||||
#[cfg(test)] use task::default_task_opts;
|
#[cfg(test)] use task::default_task_opts;
|
||||||
#[cfg(test)] use comm;
|
#[cfg(test)] use comm;
|
||||||
@ -556,8 +553,6 @@ fn enlist_many(child: &KillHandle, child_arc: &TaskGroupArc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) {
|
pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) {
|
||||||
use rt::sched::*;
|
|
||||||
|
|
||||||
rtassert!(in_green_task_context());
|
rtassert!(in_green_task_context());
|
||||||
|
|
||||||
let child_data = Cell::new(gen_child_taskgroup(opts.linked, opts.supervised));
|
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()) {
|
|||||||
let mut new_sched_handle = new_sched.make_handle();
|
let mut new_sched_handle = new_sched.make_handle();
|
||||||
|
|
||||||
// Allow the scheduler to exit when the pinned task exits
|
// Allow the scheduler to exit when the pinned task exits
|
||||||
new_sched_handle.send(Shutdown);
|
new_sched_handle.send_shutdown();
|
||||||
|
|
||||||
// Pin the new task to the new scheduler
|
// Pin the new task to the new scheduler
|
||||||
let new_task = if opts.watched {
|
let new_task = if opts.watched {
|
||||||
@ -660,7 +655,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) {
|
|||||||
rtdebug!("enqueing join_task");
|
rtdebug!("enqueing join_task");
|
||||||
// Now tell the original scheduler to join with this thread
|
// Now tell the original scheduler to join with this thread
|
||||||
// by scheduling a thread-joining task on the original scheduler
|
// by scheduling a thread-joining task on the original scheduler
|
||||||
orig_sched_handle.send(TaskFromFriend(join_task));
|
orig_sched_handle.send_task_from_friend(join_task);
|
||||||
|
|
||||||
// NB: We can't simply send a message from here to another task
|
// NB: We can't simply send a message from here to another task
|
||||||
// because this code isn't running in a task and message passing doesn't
|
// because this code isn't running in a task and message passing doesn't
|
||||||
|
@ -38,7 +38,7 @@ a normal large stack.
|
|||||||
*/
|
*/
|
||||||
pub fn run_in_bare_thread(f: ~fn()) {
|
pub fn run_in_bare_thread(f: ~fn()) {
|
||||||
use cell::Cell;
|
use cell::Cell;
|
||||||
use rt::thread::Thread;
|
use rt::shouldnt_be_public::Thread;
|
||||||
|
|
||||||
let f_cell = Cell::new(f);
|
let f_cell = Cell::new(f);
|
||||||
let (port, chan) = comm::stream();
|
let (port, chan) = comm::stream();
|
||||||
|
@ -90,10 +90,10 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use clone::Clone;
|
use clone::Clone;
|
||||||
|
use ops::Drop;
|
||||||
use option::{None, Some};
|
use option::{None, Some};
|
||||||
use either::{Either, Left, Right};
|
use either::{Either, Left, Right};
|
||||||
use sys::size_of;
|
use sys::size_of;
|
||||||
use kinds::Drop;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn identity_crisis() {
|
fn identity_crisis() {
|
||||||
|
@ -964,7 +964,7 @@ mod test {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use std::io;
|
use std::io;
|
||||||
use opt_vec;
|
use opt_vec;
|
||||||
use std::hash::HashMap;
|
use std::hashmap::HashMap;
|
||||||
|
|
||||||
fn ident_to_segment(id : &Ident) -> PathSegment {
|
fn ident_to_segment(id : &Ident) -> PathSegment {
|
||||||
PathSegment{identifier:id.clone(), lifetime: None, types: opt_vec::Empty}
|
PathSegment{identifier:id.clone(), lifetime: None, types: opt_vec::Empty}
|
||||||
|
@ -1551,7 +1551,8 @@ mod test {
|
|||||||
let varrefs = @mut ~[];
|
let varrefs = @mut ~[];
|
||||||
visit::walk_crate(&mut new_path_finder(varrefs), &renamed_ast, ());
|
visit::walk_crate(&mut new_path_finder(varrefs), &renamed_ast, ());
|
||||||
match varrefs {
|
match varrefs {
|
||||||
@[Path{segments:[ref seg],_}] => assert_eq!(mtwt_resolve(seg.identifier),a2_name),
|
@[ast::Path{segments:[ref seg],_}] =>
|
||||||
|
assert_eq!(mtwt_resolve(seg.identifier),a2_name),
|
||||||
_ => assert_eq!(0,1)
|
_ => assert_eq!(0,1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1565,7 +1566,8 @@ mod test {
|
|||||||
let varrefs = @mut ~[];
|
let varrefs = @mut ~[];
|
||||||
visit::walk_crate(&mut new_path_finder(varrefs), &double_renamed, ());
|
visit::walk_crate(&mut new_path_finder(varrefs), &double_renamed, ());
|
||||||
match varrefs {
|
match varrefs {
|
||||||
@[Path{segments:[ref seg],_}] => assert_eq!(mtwt_resolve(seg.identifier),a3_name),
|
@[ast::Path{segments:[ref seg],_}] =>
|
||||||
|
assert_eq!(mtwt_resolve(seg.identifier),a3_name),
|
||||||
_ => assert_eq!(0,1)
|
_ => assert_eq!(0,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// error-pattern: import
|
|
||||||
|
|
||||||
use m::unexported;
|
use m::unexported;
|
||||||
|
//~^ ERROR: is private
|
||||||
|
|
||||||
mod m {
|
mod m {
|
||||||
pub fn exported() { }
|
pub fn exported() { }
|
||||||
|
@ -8,12 +8,10 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// error-pattern: unresolved name
|
|
||||||
|
|
||||||
mod foo {
|
mod foo {
|
||||||
pub fn x() { }
|
pub fn x() { }
|
||||||
|
|
||||||
enum y { y1, }
|
enum y { y1, }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { let z = foo::y1; }
|
fn main() { let z = foo::y1; } //~ ERROR: is private
|
||||||
|
@ -8,12 +8,11 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use zoo::{duck, goose}; //~ ERROR failed to resolve import
|
use zoo::{duck, goose}; //~ ERROR: variant `goose` is private
|
||||||
//~^ ERROR unresolved import: found `goose` in `zoo` but it is private
|
|
||||||
|
|
||||||
mod zoo {
|
mod zoo {
|
||||||
pub enum bird {
|
pub enum bird {
|
||||||
pub duck,
|
pub duck, //~ ERROR: unnecessary `pub` visibility
|
||||||
priv goose
|
priv goose
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,13 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use zoo::fly; //~ ERROR failed to resolve import
|
use zoo::fly; //~ ERROR: function `fly` is private
|
||||||
//~^ ERROR unresolved import: found `fly` in `zoo` but it is private
|
|
||||||
|
|
||||||
mod zoo {
|
mod zoo {
|
||||||
type fly = ();
|
|
||||||
fn fly() {}
|
fn fly() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {
|
||||||
|
fly();
|
||||||
|
}
|
||||||
|
@ -8,12 +8,13 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use zoo::fly; //~ ERROR failed to resolve import
|
use zoo::fly; //~ ERROR: function `fly` is private
|
||||||
//~^ ERROR unresolved import: found `fly` in `zoo` but it is private
|
|
||||||
|
|
||||||
mod zoo {
|
mod zoo {
|
||||||
fn fly() {}
|
fn fly() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {
|
||||||
|
fly();
|
||||||
|
}
|
||||||
|
38
src/test/compile-fail/issue-4366-2.rs
Normal file
38
src/test/compile-fail/issue-4366-2.rs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
// ensures that 'use foo:*' doesn't import non-public item
|
||||||
|
|
||||||
|
use m1::*;
|
||||||
|
|
||||||
|
mod foo {
|
||||||
|
pub fn foo() {}
|
||||||
|
}
|
||||||
|
mod a {
|
||||||
|
pub mod b {
|
||||||
|
use foo::foo;
|
||||||
|
type bar = int;
|
||||||
|
}
|
||||||
|
pub mod sub {
|
||||||
|
use a::b::*;
|
||||||
|
fn sub() -> bar { 1 }
|
||||||
|
//~^ ERROR: undeclared type name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod m1 {
|
||||||
|
fn foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
foo(); //~ ERROR: unresolved name
|
||||||
|
}
|
||||||
|
|
@ -27,8 +27,7 @@ mod a {
|
|||||||
}
|
}
|
||||||
pub mod sub {
|
pub mod sub {
|
||||||
use a::b::*;
|
use a::b::*;
|
||||||
fn sub() -> bar { foo(); 1 } //~ ERROR: unresolved name `foo`
|
fn sub() -> int { foo(); 1 } //~ ERROR: unresolved name `foo`
|
||||||
//~^ ERROR: use of undeclared type name `bar`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +35,4 @@ mod m1 {
|
|||||||
fn foo() {}
|
fn foo() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
foo(); //~ ERROR: unresolved name `foo`
|
|
||||||
}
|
|
||||||
|
@ -18,5 +18,5 @@ mod bar {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
local_data::set(bar::baz, -10.0);
|
local_data::set(bar::baz, -10.0);
|
||||||
//~^ ERROR unresolved name `bar::baz`
|
//~^ ERROR static `baz` is private
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ mod a {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
a::f(); //~ ERROR unresolved name
|
a::f(); //~ ERROR function `f` is private
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,5 @@ mod a {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = a::Liege; //~ ERROR unresolved name
|
let x = a::Liege; //~ ERROR variant `Liege` is private
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,15 @@ mod child {
|
|||||||
fn foo(_: int) {}
|
fn foo(_: int) {}
|
||||||
|
|
||||||
fn full_ref() {
|
fn full_ref() {
|
||||||
foo(static_priv_by_default::private); //~ ERROR: unresolved name
|
foo(static_priv_by_default::private); //~ ERROR: static `private` is private
|
||||||
foo(static_priv_by_default::public);
|
foo(static_priv_by_default::public);
|
||||||
foo(child::childs_child::private); //~ ERROR: unresolved name
|
foo(child::childs_child::private); //~ ERROR: static `private` is private
|
||||||
foo(child::childs_child::public);
|
foo(child::childs_child::public);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn medium_ref() {
|
fn medium_ref() {
|
||||||
use child::childs_child;
|
use child::childs_child;
|
||||||
foo(childs_child::private); //~ ERROR: unresolved name
|
foo(childs_child::private); //~ ERROR: static `private` is private
|
||||||
foo(childs_child::public);
|
foo(childs_child::public);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +19,22 @@ mod child {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn foo<T>(_: T) {}
|
||||||
use static_priv_by_default::private; //~ ERROR: unresolved import
|
|
||||||
//~^ ERROR: failed to resolve
|
fn test1() {
|
||||||
use static_priv_by_default::public;
|
use child::childs_child::private;
|
||||||
use child::childs_child::private; //~ ERROR: unresolved import
|
//~^ ERROR: static `private` is private
|
||||||
//~^ ERROR: failed to resolve
|
|
||||||
use child::childs_child::public;
|
use child::childs_child::public;
|
||||||
|
|
||||||
|
foo(private);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test2() {
|
||||||
|
use static_priv_by_default::private;
|
||||||
|
//~^ ERROR: static `private` is private
|
||||||
|
use static_priv_by_default::public;
|
||||||
|
|
||||||
|
foo(private);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
|
@ -15,8 +15,8 @@ extern mod xc_private_method_lib;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = xc_private_method_lib::Struct::static_meth_struct();
|
let _ = xc_private_method_lib::Struct::static_meth_struct();
|
||||||
//~^ ERROR: unresolved name
|
//~^ ERROR: method `static_meth_struct` is private
|
||||||
|
|
||||||
let _ = xc_private_method_lib::Enum::static_meth_enum();
|
let _ = xc_private_method_lib::Enum::static_meth_enum();
|
||||||
//~^ ERROR: unresolved name
|
//~^ ERROR: method `static_meth_enum` is private
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,14 @@
|
|||||||
|
|
||||||
// aux-build:static_priv_by_default.rs
|
// aux-build:static_priv_by_default.rs
|
||||||
|
|
||||||
#[allow(unused_imports)];
|
#[no_std]; // helps if debugging resolve
|
||||||
#[no_std];
|
|
||||||
|
|
||||||
extern mod static_priv_by_default;
|
extern mod static_priv_by_default;
|
||||||
|
|
||||||
fn foo<T>() {}
|
fn foo<T>() {}
|
||||||
|
|
||||||
#[start]
|
#[start]
|
||||||
fn main(_: int, _: **u8, _: *u8) -> int {
|
fn main(_: int, _: **u8) -> int {
|
||||||
// Actual public items should be public
|
// Actual public items should be public
|
||||||
static_priv_by_default::a;
|
static_priv_by_default::a;
|
||||||
static_priv_by_default::b;
|
static_priv_by_default::b;
|
||||||
@ -33,25 +32,23 @@ fn main(_: int, _: **u8, _: *u8) -> int {
|
|||||||
|
|
||||||
// private items at the top should be inaccessible
|
// private items at the top should be inaccessible
|
||||||
static_priv_by_default::i;
|
static_priv_by_default::i;
|
||||||
//~^ ERROR: unresolved name
|
//~^ ERROR: static `i` is private
|
||||||
static_priv_by_default::j;
|
static_priv_by_default::j;
|
||||||
//~^ ERROR: unresolved name
|
//~^ ERROR: function `j` is private
|
||||||
static_priv_by_default::k;
|
static_priv_by_default::k;
|
||||||
//~^ ERROR: unresolved name
|
//~^ ERROR: struct `k` is private
|
||||||
foo::<static_priv_by_default::l>();
|
foo::<static_priv_by_default::l>();
|
||||||
//~^ ERROR: use of undeclared type name
|
//~^ ERROR: type `l` is private
|
||||||
//~^^ ERROR: use of undeclared type name
|
|
||||||
|
|
||||||
// public items in a private mod should be inaccessible
|
// public items in a private mod should be inaccessible
|
||||||
static_priv_by_default::foo::a;
|
static_priv_by_default::foo::a;
|
||||||
//~^ ERROR: unresolved name
|
//~^ ERROR: static `a` is private
|
||||||
static_priv_by_default::foo::b;
|
static_priv_by_default::foo::b;
|
||||||
//~^ ERROR: unresolved name
|
//~^ ERROR: function `b` is private
|
||||||
static_priv_by_default::foo::c;
|
static_priv_by_default::foo::c;
|
||||||
//~^ ERROR: unresolved name
|
//~^ ERROR: struct `c` is private
|
||||||
foo::<static_priv_by_default::foo::d>();
|
foo::<static_priv_by_default::foo::d>();
|
||||||
//~^ ERROR: use of undeclared type name
|
//~^ ERROR: type `d` is private
|
||||||
//~^^ ERROR: use of undeclared type name
|
|
||||||
|
|
||||||
3
|
3
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
mod foo {
|
mod foo {
|
||||||
mod bar {
|
pub mod bar {
|
||||||
pub fn y() { super::super::foo::x(); }
|
pub fn y() { super::super::foo::x(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ mod rustrt1 {
|
|||||||
#[abi = "cdecl"]
|
#[abi = "cdecl"]
|
||||||
#[link_name = "rustrt"]
|
#[link_name = "rustrt"]
|
||||||
extern {
|
extern {
|
||||||
fn rust_get_test_int() -> libc::intptr_t;
|
pub fn rust_get_test_int() -> libc::intptr_t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ mod rustrt2 {
|
|||||||
#[abi = "cdecl"]
|
#[abi = "cdecl"]
|
||||||
#[link_name = "rustrt"]
|
#[link_name = "rustrt"]
|
||||||
extern {
|
extern {
|
||||||
fn rust_get_test_int() -> libc::intptr_t;
|
pub fn rust_get_test_int() -> libc::intptr_t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ mod rustrt {
|
|||||||
use std::libc;
|
use std::libc;
|
||||||
|
|
||||||
extern {
|
extern {
|
||||||
fn rust_get_test_int() -> libc::intptr_t;
|
pub fn rust_get_test_int() -> libc::intptr_t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
mod rusti {
|
mod rusti {
|
||||||
#[abi = "rust-intrinsic"]
|
#[abi = "rust-intrinsic"]
|
||||||
extern "rust-intrinsic" {
|
extern "rust-intrinsic" {
|
||||||
fn uninit<T>() -> T;
|
pub fn uninit<T>() -> T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
@ -17,24 +17,24 @@ extern mod extra;
|
|||||||
mod rusti {
|
mod rusti {
|
||||||
#[abi = "rust-intrinsic"]
|
#[abi = "rust-intrinsic"]
|
||||||
extern "rust-intrinsic" {
|
extern "rust-intrinsic" {
|
||||||
fn ctpop8(x: i8) -> i8;
|
pub fn ctpop8(x: i8) -> i8;
|
||||||
fn ctpop16(x: i16) -> i16;
|
pub fn ctpop16(x: i16) -> i16;
|
||||||
fn ctpop32(x: i32) -> i32;
|
pub fn ctpop32(x: i32) -> i32;
|
||||||
fn ctpop64(x: i64) -> i64;
|
pub fn ctpop64(x: i64) -> i64;
|
||||||
|
|
||||||
fn ctlz8(x: i8) -> i8;
|
pub fn ctlz8(x: i8) -> i8;
|
||||||
fn ctlz16(x: i16) -> i16;
|
pub fn ctlz16(x: i16) -> i16;
|
||||||
fn ctlz32(x: i32) -> i32;
|
pub fn ctlz32(x: i32) -> i32;
|
||||||
fn ctlz64(x: i64) -> i64;
|
pub fn ctlz64(x: i64) -> i64;
|
||||||
|
|
||||||
fn cttz8(x: i8) -> i8;
|
pub fn cttz8(x: i8) -> i8;
|
||||||
fn cttz16(x: i16) -> i16;
|
pub fn cttz16(x: i16) -> i16;
|
||||||
fn cttz32(x: i32) -> i32;
|
pub fn cttz32(x: i32) -> i32;
|
||||||
fn cttz64(x: i64) -> i64;
|
pub fn cttz64(x: i64) -> i64;
|
||||||
|
|
||||||
fn bswap16(x: i16) -> i16;
|
pub fn bswap16(x: i16) -> i16;
|
||||||
fn bswap32(x: i32) -> i32;
|
pub fn bswap32(x: i32) -> i32;
|
||||||
fn bswap64(x: i64) -> i64;
|
pub fn bswap64(x: i64) -> i64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,4 +8,4 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
mod test;
|
pub mod test;
|
||||||
|
@ -46,7 +46,7 @@ mod m {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
mod m {
|
pub mod m {
|
||||||
pub fn align() -> uint { 8u }
|
pub fn align() -> uint { 8u }
|
||||||
pub fn size() -> uint { 16u }
|
pub fn size() -> uint { 16u }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user