rollup merge of #20289: nick29581/shadowing

r? eddyb
This commit is contained in:
Alex Crichton 2014-12-29 16:36:49 -08:00
commit 806cb35f4d
26 changed files with 401 additions and 193 deletions

View File

@ -1343,7 +1343,10 @@ pub mod raw {
#[cfg(test)]
mod tests {
use std::boxed::Box;
use prelude::*;
use prelude::{Some, None, range, Vec, ToString, Clone, Greater, Less, Equal};
use prelude::{SliceExt, Iterator, IteratorExt, DoubleEndedIteratorExt};
use prelude::{OrdSliceExt, CloneSliceExt, PartialEqSliceExt, AsSlice};
use prelude::{RandomAccessIterator, Ord, VectorVector};
use core::cell::Cell;
use core::default::Default;
use core::mem;

View File

@ -3347,7 +3347,7 @@ mod tests {
#[cfg(test)]
mod bench {
use super::*;
use prelude::*;
use prelude::{SliceExt, IteratorExt, DoubleEndedIteratorExt};
use test::Bencher;
use test::black_box;

View File

@ -345,9 +345,6 @@ impl Rib {
#[deriving(Show,PartialEq,Clone,Copy)]
enum Shadowable {
Always,
/// Means that the recorded import obeys the glob shadowing rules, i.e., can
/// only be shadowed by another glob import.
Glob,
Never
}
@ -462,6 +459,22 @@ impl ImportResolution {
target.unwrap().shadowable
}
fn set_target_and_id(&mut self,
namespace: Namespace,
target: Option<Target>,
id: NodeId) {
match namespace {
TypeNS => {
self.type_target = target;
self.type_id = id;
}
ValueNS => {
self.value_target = target;
self.value_id = id;
}
}
}
}
/// The link from a module up to its nearest parent node.
@ -1719,11 +1732,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
view_path.span,
id,
is_public,
if shadowable == Shadowable::Never {
Shadowable::Glob
} else {
shadowable
});
shadowable);
}
}
}
@ -2712,64 +2721,45 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// We've successfully resolved the import. Write the results in.
let mut import_resolutions = module_.import_resolutions.borrow_mut();
let import_resolution = &mut (*import_resolutions)[target];
{
let check_and_write_import = |namespace, result: &_, used_public: &mut bool| {
let namespace_name = match namespace {
TypeNS => "type",
ValueNS => "value",
};
match value_result {
BoundResult(ref target_module, ref name_bindings) => {
debug!("(resolving single import) found value target: {}",
{ name_bindings.value_def.borrow().clone().unwrap().def });
self.check_for_conflicting_import(
&import_resolution.value_target,
directive.span,
target,
ValueNS);
match *result {
BoundResult(ref target_module, ref name_bindings) => {
debug!("(resolving single import) found {} target: {}",
namespace_name,
name_bindings.def_for_namespace(namespace));
self.check_for_conflicting_import(
&import_resolution.target_for_namespace(namespace),
directive.span,
target,
namespace);
self.check_that_import_is_importable(
&**name_bindings,
directive.span,
target,
ValueNS);
self.check_that_import_is_importable(
&**name_bindings,
directive.span,
target,
namespace);
import_resolution.value_target =
Some(Target::new(target_module.clone(),
name_bindings.clone(),
directive.shadowable));
import_resolution.value_id = directive.id;
import_resolution.is_public = directive.is_public;
value_used_public = name_bindings.defined_in_public_namespace(ValueNS);
}
UnboundResult => { /* Continue. */ }
UnknownResult => {
panic!("value result should be known at this point");
}
}
match type_result {
BoundResult(ref target_module, ref name_bindings) => {
debug!("(resolving single import) found type target: {}",
{ name_bindings.type_def.borrow().clone().unwrap().type_def });
self.check_for_conflicting_import(
&import_resolution.type_target,
directive.span,
target,
TypeNS);
self.check_that_import_is_importable(
&**name_bindings,
directive.span,
target,
TypeNS);
import_resolution.type_target =
Some(Target::new(target_module.clone(),
name_bindings.clone(),
directive.shadowable));
import_resolution.type_id = directive.id;
import_resolution.is_public = directive.is_public;
type_used_public = name_bindings.defined_in_public_namespace(TypeNS);
}
UnboundResult => { /* Continue. */ }
UnknownResult => {
panic!("type result should be known at this point");
}
let target = Some(Target::new(target_module.clone(),
name_bindings.clone(),
directive.shadowable));
import_resolution.set_target_and_id(namespace, target, directive.id);
import_resolution.is_public = directive.is_public;
*used_public = name_bindings.defined_in_public_namespace(namespace);
}
UnboundResult => { /* Continue. */ }
UnknownResult => {
panic!("{} result should be known at this point", namespace_name);
}
}
};
check_and_write_import(ValueNS, &value_result, &mut value_used_public);
check_and_write_import(TypeNS, &type_result, &mut type_used_public);
}
self.check_for_conflicts_between_imports_and_items(
@ -2825,7 +2815,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Resolves a glob import. Note that this function cannot fail; it either
// succeeds or bails out (as importing * from an empty module or a module
// that exports nothing is valid).
// that exports nothing is valid). containing_module is the module we are
// actually importing, i.e., `foo` in `use foo::*`.
fn resolve_glob_import(&mut self,
module_: &Module,
containing_module: Rc<Module>,
@ -2851,12 +2842,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
assert_eq!(containing_module.glob_count.get(), 0);
// Add all resolved imports from the containing module.
let import_resolutions = containing_module.import_resolutions
.borrow();
let import_resolutions = containing_module.import_resolutions.borrow();
for (ident, target_import_resolution) in import_resolutions.iter() {
debug!("(resolving glob import) writing module resolution \
{} into `{}`",
target_import_resolution.type_target.is_none(),
token::get_name(*ident),
self.module_to_string(module_));
if !target_import_resolution.is_public {
@ -2876,8 +2866,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Continue.
}
Some(ref value_target) => {
dest_import_resolution.value_target =
Some(value_target.clone());
self.check_for_conflicting_import(&dest_import_resolution.value_target,
import_directive.span,
*ident,
ValueNS);
dest_import_resolution.value_target = Some(value_target.clone());
}
}
match target_import_resolution.type_target {
@ -2885,8 +2878,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Continue.
}
Some(ref type_target) => {
dest_import_resolution.type_target =
Some(type_target.clone());
self.check_for_conflicting_import(&dest_import_resolution.type_target,
import_directive.span,
*ident,
TypeNS);
dest_import_resolution.type_target = Some(type_target.clone());
}
}
dest_import_resolution.is_public = is_public;
@ -2908,8 +2904,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Add all children from the containing module.
self.populate_module_if_necessary(&containing_module);
for (&name, name_bindings) in containing_module.children
.borrow().iter() {
for (&name, name_bindings) in containing_module.children.borrow().iter() {
self.merge_import_resolution(module_,
containing_module.clone(),
import_directive,
@ -2919,8 +2914,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
// Add external module children from the containing module.
for (&name, module) in containing_module.external_module_children
.borrow().iter() {
for (&name, module) in containing_module.external_module_children.borrow().iter() {
let name_bindings =
Rc::new(Resolver::create_name_bindings_from_module(module.clone()));
self.merge_import_resolution(module_,
@ -2965,41 +2959,39 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
debug!("(resolving glob import) writing resolution `{}` in `{}` \
to `{}`",
token::get_name(name).get().to_string(),
token::get_name(name).get(),
self.module_to_string(&*containing_module),
self.module_to_string(module_));
// Merge the child item into the import resolution.
if name_bindings.defined_in_namespace_with(ValueNS, IMPORTABLE | PUBLIC) {
debug!("(resolving glob import) ... for value target");
if dest_import_resolution.shadowable(ValueNS) == Shadowable::Never {
let msg = format!("a value named `{}` has already been imported \
in this module",
token::get_name(name).get());
self.session.span_err(import_directive.span, msg.as_slice());
} else {
dest_import_resolution.value_target =
Some(Target::new(containing_module.clone(),
name_bindings.clone(),
import_directive.shadowable));
dest_import_resolution.value_id = id;
}
}
if name_bindings.defined_in_namespace_with(TypeNS, IMPORTABLE | PUBLIC) {
debug!("(resolving glob import) ... for type target");
if dest_import_resolution.shadowable(TypeNS) == Shadowable::Never {
let msg = format!("a type named `{}` has already been imported \
in this module",
token::get_name(name).get());
self.session.span_err(import_directive.span, msg.as_slice());
} else {
dest_import_resolution.type_target =
Some(Target::new(containing_module,
name_bindings.clone(),
import_directive.shadowable));
dest_import_resolution.type_id = id;
}
{
let merge_child_item = |namespace| {
if name_bindings.defined_in_namespace_with(namespace, IMPORTABLE | PUBLIC) {
let namespace_name = match namespace {
TypeNS => "type",
ValueNS => "value",
};
debug!("(resolving glob import) ... for {} target", namespace_name);
if dest_import_resolution.shadowable(namespace) == Shadowable::Never {
let msg = format!("a {} named `{}` has already been imported \
in this module",
namespace_name,
token::get_name(name).get());
self.session.span_err(import_directive.span, msg.as_slice());
} else {
let target = Target::new(containing_module.clone(),
name_bindings.clone(),
import_directive.shadowable);
dest_import_resolution.set_target_and_id(namespace,
Some(target),
id);
}
}
};
merge_child_item(ValueNS);
merge_child_item(TypeNS);
}
dest_import_resolution.is_public = is_public;
self.check_for_conflicts_between_imports_and_items(
@ -3019,6 +3011,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
return
}
debug!("check_for_conflicting_import: {}; target exists: {}",
token::get_name(name).get(),
target.is_some());
match *target {
Some(ref target) if target.shadowable != Shadowable::Always => {
let msg = format!("a {} named `{}` has already been imported \

View File

@ -1545,8 +1545,7 @@ pub fn arg_kind<'a, 'tcx>(cx: &FunctionContext<'a, 'tcx>, t: Ty<'tcx>)
}
// work around bizarre resolve errors
pub type RvalueDatum<'tcx> = datum::Datum<'tcx, datum::Rvalue>;
pub type LvalueDatum<'tcx> = datum::Datum<'tcx, datum::Lvalue>;
type RvalueDatum<'tcx> = datum::Datum<'tcx, datum::Rvalue>;
// create_datums_for_fn_args: creates rvalue datums for each of the
// incoming function arguments. These will later be stored into

View File

@ -190,8 +190,8 @@ pub fn validate_substs(substs: &Substs) {
}
// work around bizarre resolve errors
pub type RvalueDatum<'tcx> = datum::Datum<'tcx, datum::Rvalue>;
pub type LvalueDatum<'tcx> = datum::Datum<'tcx, datum::Lvalue>;
type RvalueDatum<'tcx> = datum::Datum<'tcx, datum::Rvalue>;
type LvalueDatum<'tcx> = datum::Datum<'tcx, datum::Lvalue>;
// Function context. Every LLVM function we create will have one of
// these.

View File

@ -537,7 +537,8 @@ pub unsafe fn from_c_multistring<F>(buf: *const libc::c_char,
#[cfg(test)]
mod tests {
use super::*;
use prelude::*;
use prelude::{spawn, Some, None, Option, FnOnce, ToString, CloneSliceExt};
use prelude::{Clone, RawPtr, Iterator, SliceExt, StrExt};
use ptr;
use thread::Thread;
use libc;

View File

@ -181,7 +181,7 @@
// senders. Under the hood, however, there are actually three flavors of
// channels in play.
//
// * Oneshots - these channels are highly optimized for the one-send use case.
// * Flavor::Oneshots - these channels are highly optimized for the one-send use case.
// They contain as few atomics as possible and involve one and
// exactly one allocation.
// * Streams - these channels are optimized for the non-shared use case. They
@ -316,7 +316,6 @@ use core::prelude::*;
pub use self::TryRecvError::*;
pub use self::TrySendError::*;
use self::Flavor::*;
use alloc::arc::Arc;
use core::kinds;
@ -337,7 +336,8 @@ macro_rules! test {
use super::*;
use comm::*;
use thread::Thread;
use prelude::*;
use prelude::{Ok, Err, spawn, range, drop, Box, Some, None, Option};
use prelude::{Vec, Buffer, from_str, Clone};
$(#[$a])* #[test] fn f() { $b }
}
@ -478,7 +478,7 @@ impl<T> UnsafeFlavor<T> for Receiver<T> {
#[unstable]
pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {
let a = Arc::new(RacyCell::new(oneshot::Packet::new()));
(Sender::new(Oneshot(a.clone())), Receiver::new(Oneshot(a)))
(Sender::new(Flavor::Oneshot(a.clone())), Receiver::new(Flavor::Oneshot(a)))
}
/// Creates a new synchronous, bounded channel.
@ -518,7 +518,7 @@ pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {
of channel that is is creating"]
pub fn sync_channel<T: Send>(bound: uint) -> (SyncSender<T>, Receiver<T>) {
let a = Arc::new(RacyCell::new(sync::Packet::new(bound)));
(SyncSender::new(a.clone()), Receiver::new(Sync(a)))
(SyncSender::new(a.clone()), Receiver::new(Flavor::Sync(a)))
}
////////////////////////////////////////////////////////////////////////////////
@ -592,7 +592,7 @@ impl<T: Send> Sender<T> {
#[unstable = "this function may be renamed to send() in the future"]
pub fn send_opt(&self, t: T) -> Result<(), T> {
let (new_inner, ret) = match *unsafe { self.inner() } {
Oneshot(ref p) => {
Flavor::Oneshot(ref p) => {
unsafe {
let p = p.get();
if !(*p).sent() {
@ -600,7 +600,7 @@ impl<T: Send> Sender<T> {
} else {
let a =
Arc::new(RacyCell::new(stream::Packet::new()));
match (*p).upgrade(Receiver::new(Stream(a.clone()))) {
match (*p).upgrade(Receiver::new(Flavor::Stream(a.clone()))) {
oneshot::UpSuccess => {
let ret = (*a.get()).send(t);
(a, ret)
@ -618,13 +618,13 @@ impl<T: Send> Sender<T> {
}
}
}
Stream(ref p) => return unsafe { (*p.get()).send(t) },
Shared(ref p) => return unsafe { (*p.get()).send(t) },
Sync(..) => unreachable!(),
Flavor::Stream(ref p) => return unsafe { (*p.get()).send(t) },
Flavor::Shared(ref p) => return unsafe { (*p.get()).send(t) },
Flavor::Sync(..) => unreachable!(),
};
unsafe {
let tmp = Sender::new(Stream(new_inner));
let tmp = Sender::new(Flavor::Stream(new_inner));
mem::swap(self.inner_mut(), tmp.inner_mut());
}
return ret;
@ -635,42 +635,42 @@ impl<T: Send> Sender<T> {
impl<T: Send> Clone for Sender<T> {
fn clone(&self) -> Sender<T> {
let (packet, sleeper, guard) = match *unsafe { self.inner() } {
Oneshot(ref p) => {
Flavor::Oneshot(ref p) => {
let a = Arc::new(RacyCell::new(shared::Packet::new()));
unsafe {
let guard = (*a.get()).postinit_lock();
match (*p.get()).upgrade(Receiver::new(Shared(a.clone()))) {
match (*p.get()).upgrade(Receiver::new(Flavor::Shared(a.clone()))) {
oneshot::UpSuccess |
oneshot::UpDisconnected => (a, None, guard),
oneshot::UpWoke(task) => (a, Some(task), guard)
}
}
}
Stream(ref p) => {
Flavor::Stream(ref p) => {
let a = Arc::new(RacyCell::new(shared::Packet::new()));
unsafe {
let guard = (*a.get()).postinit_lock();
match (*p.get()).upgrade(Receiver::new(Shared(a.clone()))) {
match (*p.get()).upgrade(Receiver::new(Flavor::Shared(a.clone()))) {
stream::UpSuccess |
stream::UpDisconnected => (a, None, guard),
stream::UpWoke(task) => (a, Some(task), guard),
}
}
}
Shared(ref p) => {
Flavor::Shared(ref p) => {
unsafe { (*p.get()).clone_chan(); }
return Sender::new(Shared(p.clone()));
return Sender::new(Flavor::Shared(p.clone()));
}
Sync(..) => unreachable!(),
Flavor::Sync(..) => unreachable!(),
};
unsafe {
(*packet.get()).inherit_blocker(sleeper, guard);
let tmp = Sender::new(Shared(packet.clone()));
let tmp = Sender::new(Flavor::Shared(packet.clone()));
mem::swap(self.inner_mut(), tmp.inner_mut());
}
Sender::new(Shared(packet))
Sender::new(Flavor::Shared(packet))
}
}
@ -678,10 +678,10 @@ impl<T: Send> Clone for Sender<T> {
impl<T: Send> Drop for Sender<T> {
fn drop(&mut self) {
match *unsafe { self.inner_mut() } {
Oneshot(ref mut p) => unsafe { (*p.get()).drop_chan(); },
Stream(ref mut p) => unsafe { (*p.get()).drop_chan(); },
Shared(ref mut p) => unsafe { (*p.get()).drop_chan(); },
Sync(..) => unreachable!(),
Flavor::Oneshot(ref mut p) => unsafe { (*p.get()).drop_chan(); },
Flavor::Stream(ref mut p) => unsafe { (*p.get()).drop_chan(); },
Flavor::Shared(ref mut p) => unsafe { (*p.get()).drop_chan(); },
Flavor::Sync(..) => unreachable!(),
}
}
}
@ -827,7 +827,7 @@ impl<T: Send> Receiver<T> {
pub fn try_recv(&self) -> Result<T, TryRecvError> {
loop {
let new_port = match *unsafe { self.inner() } {
Oneshot(ref p) => {
Flavor::Oneshot(ref p) => {
match unsafe { (*p.get()).try_recv() } {
Ok(t) => return Ok(t),
Err(oneshot::Empty) => return Err(Empty),
@ -835,7 +835,7 @@ impl<T: Send> Receiver<T> {
Err(oneshot::Upgraded(rx)) => rx,
}
}
Stream(ref p) => {
Flavor::Stream(ref p) => {
match unsafe { (*p.get()).try_recv() } {
Ok(t) => return Ok(t),
Err(stream::Empty) => return Err(Empty),
@ -843,14 +843,14 @@ impl<T: Send> Receiver<T> {
Err(stream::Upgraded(rx)) => rx,
}
}
Shared(ref p) => {
Flavor::Shared(ref p) => {
match unsafe { (*p.get()).try_recv() } {
Ok(t) => return Ok(t),
Err(shared::Empty) => return Err(Empty),
Err(shared::Disconnected) => return Err(Disconnected),
}
}
Sync(ref p) => {
Flavor::Sync(ref p) => {
match unsafe { (*p.get()).try_recv() } {
Ok(t) => return Ok(t),
Err(sync::Empty) => return Err(Empty),
@ -881,7 +881,7 @@ impl<T: Send> Receiver<T> {
pub fn recv_opt(&self) -> Result<T, ()> {
loop {
let new_port = match *unsafe { self.inner() } {
Oneshot(ref p) => {
Flavor::Oneshot(ref p) => {
match unsafe { (*p.get()).recv() } {
Ok(t) => return Ok(t),
Err(oneshot::Empty) => return unreachable!(),
@ -889,7 +889,7 @@ impl<T: Send> Receiver<T> {
Err(oneshot::Upgraded(rx)) => rx,
}
}
Stream(ref p) => {
Flavor::Stream(ref p) => {
match unsafe { (*p.get()).recv() } {
Ok(t) => return Ok(t),
Err(stream::Empty) => return unreachable!(),
@ -897,14 +897,14 @@ impl<T: Send> Receiver<T> {
Err(stream::Upgraded(rx)) => rx,
}
}
Shared(ref p) => {
Flavor::Shared(ref p) => {
match unsafe { (*p.get()).recv() } {
Ok(t) => return Ok(t),
Err(shared::Empty) => return unreachable!(),
Err(shared::Disconnected) => return Err(()),
}
}
Sync(ref p) => return unsafe { (*p.get()).recv() }
Flavor::Sync(ref p) => return unsafe { (*p.get()).recv() }
};
unsafe {
mem::swap(self.inner_mut(), new_port.inner_mut());
@ -924,22 +924,22 @@ impl<T: Send> select::Packet for Receiver<T> {
fn can_recv(&self) -> bool {
loop {
let new_port = match *unsafe { self.inner() } {
Oneshot(ref p) => {
Flavor::Oneshot(ref p) => {
match unsafe { (*p.get()).can_recv() } {
Ok(ret) => return ret,
Err(upgrade) => upgrade,
}
}
Stream(ref p) => {
Flavor::Stream(ref p) => {
match unsafe { (*p.get()).can_recv() } {
Ok(ret) => return ret,
Err(upgrade) => upgrade,
}
}
Shared(ref p) => {
Flavor::Shared(ref p) => {
return unsafe { (*p.get()).can_recv() };
}
Sync(ref p) => {
Flavor::Sync(ref p) => {
return unsafe { (*p.get()).can_recv() };
}
};
@ -953,24 +953,24 @@ impl<T: Send> select::Packet for Receiver<T> {
fn start_selection(&self, mut token: SignalToken) -> StartResult {
loop {
let (t, new_port) = match *unsafe { self.inner() } {
Oneshot(ref p) => {
Flavor::Oneshot(ref p) => {
match unsafe { (*p.get()).start_selection(token) } {
oneshot::SelSuccess => return Installed,
oneshot::SelCanceled => return Abort,
oneshot::SelUpgraded(t, rx) => (t, rx),
}
}
Stream(ref p) => {
Flavor::Stream(ref p) => {
match unsafe { (*p.get()).start_selection(token) } {
stream::SelSuccess => return Installed,
stream::SelCanceled => return Abort,
stream::SelUpgraded(t, rx) => (t, rx),
}
}
Shared(ref p) => {
Flavor::Shared(ref p) => {
return unsafe { (*p.get()).start_selection(token) };
}
Sync(ref p) => {
Flavor::Sync(ref p) => {
return unsafe { (*p.get()).start_selection(token) };
}
};
@ -985,14 +985,14 @@ impl<T: Send> select::Packet for Receiver<T> {
let mut was_upgrade = false;
loop {
let result = match *unsafe { self.inner() } {
Oneshot(ref p) => unsafe { (*p.get()).abort_selection() },
Stream(ref p) => unsafe {
Flavor::Oneshot(ref p) => unsafe { (*p.get()).abort_selection() },
Flavor::Stream(ref p) => unsafe {
(*p.get()).abort_selection(was_upgrade)
},
Shared(ref p) => return unsafe {
Flavor::Shared(ref p) => return unsafe {
(*p.get()).abort_selection(was_upgrade)
},
Sync(ref p) => return unsafe {
Flavor::Sync(ref p) => return unsafe {
(*p.get()).abort_selection()
},
};
@ -1015,10 +1015,10 @@ impl<'a, T: Send> Iterator<T> for Messages<'a, T> {
impl<T: Send> Drop for Receiver<T> {
fn drop(&mut self) {
match *unsafe { self.inner_mut() } {
Oneshot(ref mut p) => unsafe { (*p.get()).drop_port(); },
Stream(ref mut p) => unsafe { (*p.get()).drop_port(); },
Shared(ref mut p) => unsafe { (*p.get()).drop_port(); },
Sync(ref mut p) => unsafe { (*p.get()).drop_port(); },
Flavor::Oneshot(ref mut p) => unsafe { (*p.get()).drop_port(); },
Flavor::Stream(ref mut p) => unsafe { (*p.get()).drop_port(); },
Flavor::Shared(ref mut p) => unsafe { (*p.get()).drop_port(); },
Flavor::Sync(ref mut p) => unsafe { (*p.get()).drop_port(); },
}
}
}
@ -1047,7 +1047,7 @@ unsafe impl<T> kinds::Sync for RacyCell<T> { } // Oh dear
#[cfg(test)]
mod test {
use super::*;
use prelude::*;
use prelude::{spawn, range, Some, None, from_str, Clone, Str};
use os;
pub fn stress_factor() -> uint {

View File

@ -400,8 +400,8 @@ impl<'a> Buffer for BufReader<'a> {
mod test {
extern crate "test" as test_crate;
use super::*;
use io::*;
use prelude::*;
use io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek};
use prelude::{Ok, Err, range, Vec, Buffer, AsSlice, SliceExt, IteratorExt, CloneSliceExt};
use io;
use self::test_crate::Bencher;

View File

@ -1959,8 +1959,8 @@ impl fmt::Show for FilePermission {
#[cfg(test)]
mod tests {
use self::BadReaderBehavior::*;
use super::{IoResult, Reader, MemReader, NoProgress, InvalidInput};
use prelude::*;
use super::{IoResult, Reader, MemReader, NoProgress, InvalidInput, Writer};
use prelude::{Ok, Vec, Buffer, CloneSliceExt};
use uint;
#[deriving(Clone, PartialEq, Show)]

View File

@ -269,7 +269,7 @@ mod tests {
use super::*;
use io::*;
use io::test::*;
use prelude::*;
use prelude::{Ok, Err, spawn, range, drop, Some, None, channel, Send, FnOnce, Clone};
use io::fs::PathExtensions;
use time::Duration;

View File

@ -484,9 +484,12 @@ impl sys_common::AsInner<TcpAcceptorImp> for TcpAcceptor {
mod test {
use io::net::tcp::*;
use io::net::ip::*;
use io::*;
use io::{EndOfFile, TimedOut, IoError, ShortWrite, OtherIoError, ConnectionAborted};
use io::{ConnectionRefused, ConnectionReset, BrokenPipe, NotConnected};
use io::{PermissionDenied, Listener, Acceptor};
use io::test::*;
use prelude::*;
use prelude::{Ok, Err, spawn, range, drop, Some, None, channel, Clone};
use prelude::{Reader, Writer, IteratorExt};
// FIXME #11530 this fails on android because tests are run as root
#[cfg_attr(any(windows, target_os = "android"), ignore)]

View File

@ -250,9 +250,9 @@ impl Writer for UdpStream {
mod test {
use super::*;
use io::net::ip::*;
use io::*;
use io::{ShortWrite, IoError, TimedOut, PermissionDenied};
use io::test::*;
use prelude::*;
use prelude::{Ok, Err, spawn, range, drop, Some, None, channel, Clone, Reader, Writer};
// FIXME #11530 this fails on android because tests are run as root
#[cfg_attr(any(windows, target_os = "android"), ignore)]

View File

@ -745,8 +745,10 @@ mod tests {
use super::*;
use io::timer::*;
use io::*;
use prelude::*;
use io::{Truncate, Write, TimedOut, timer, process, FileNotFound};
use prelude::{Ok, Err, spawn, range, drop, Box, Some, None, Option, Vec, Buffer};
use prelude::{from_str, Path, String, channel, Reader, Writer, Clone, Slice};
use prelude::{SliceExt, Str, StrExt, AsSlice, ToString, GenericPath};
use io::fs::PathExtensions;
use time::Duration;
use str;

View File

@ -280,7 +280,7 @@ mod test {
use io;
use boxed::Box;
use super::*;
use prelude::*;
use prelude::{Ok, range, Vec, Buffer, Writer, Reader, ToString, AsSlice};
#[test]
fn test_limit_reader_unlimited() {

View File

@ -147,8 +147,10 @@ pub fn test_num<T>(ten: T, two: T) where
#[cfg(test)]
mod tests {
use prelude::*;
use super::*;
use prelude::{range, Some, None, Option, IteratorExt};
use super::{from_int, from_uint, from_i32, from_i64, from_u64, from_u32};
use super::{from_f64, from_f32, from_u16, from_i16, from_u8, from_i8, Int};
use super::{cast, NumCast, ToPrimitive, FromPrimitive, UnsignedInt};
use i8;
use i16;
use i32;

View File

@ -1239,7 +1239,7 @@ mod bench {
extern crate test;
use self::test::Bencher;
use super::*;
use prelude::*;
use prelude::{Clone, GenericPath};
#[bench]
fn join_home_dir(b: &mut Bencher) {

View File

@ -180,7 +180,7 @@ impl<T: Send> Drop for AtomicOption<T> {
#[cfg(test)]
mod test {
use prelude::*;
use prelude::{Some, None};
use super::*;
#[test]

View File

@ -0,0 +1,31 @@
// Copyright 2014 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.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
#![feature(globs)]
use foo::*;
use bar::*; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = int;
}
mod bar {
pub type Baz = int;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View File

@ -0,0 +1,31 @@
// Copyright 2014 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.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
#![feature(globs)]
use foo::*;
use foo::*; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = int;
}
mod bar {
pub type Baz = int;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View File

@ -0,0 +1,31 @@
// Copyright 2014 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.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
#![feature(globs)]
use foo::Baz;
use bar::*; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = int;
}
mod bar {
pub type Baz = int;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View File

@ -0,0 +1,31 @@
// Copyright 2014 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.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
#![feature(globs)]
use foo::*;
use bar::Baz; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = int;
}
mod bar {
pub type Baz = int;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View File

@ -0,0 +1,31 @@
// Copyright 2014 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.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
#![feature(globs)]
use foo::Baz;
use bar::Baz; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = int;
}
mod bar {
pub type Baz = int;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View File

@ -0,0 +1,31 @@
// Copyright 2014 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.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
#![feature(globs)]
use qux::*;
use foo::*; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = int;
}
mod bar {
pub type Baz = int;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View File

@ -0,0 +1,31 @@
// Copyright 2014 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.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
#![feature(globs)]
use foo::*;
use qux::*; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = int;
}
mod bar {
pub type Baz = int;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View File

@ -17,8 +17,7 @@ mod test1 {
mod bar { pub fn p() -> int { 2 } }
pub mod baz {
use test1::foo::*;
use test1::bar::*;
use test1::bar::p;
pub fn my_main() { assert!(p() == 2); }
}
@ -36,20 +35,7 @@ mod test2 {
}
}
mod test3 {
mod foo { pub fn p() -> int { 1 } }
mod bar { pub fn p() -> int { 2 } }
pub mod baz {
use test3::bar::p;
pub fn my_main() { assert!(p() == 2); }
}
}
fn main() {
test1::baz::my_main();
test2::baz::my_main();
test3::baz::my_main();
}

View File

@ -23,7 +23,6 @@
#![allow(unused_imports)]
use std::io::*;
use std::io::net::tcp::*;
use std::io::test::*;
use std::io;
use std::time::Duration;