mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-13 07:24:00 +00:00
Fallout from glob shadowing
This commit is contained in:
parent
f53314cd70
commit
9c1567e622
@ -1554,8 +1554,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
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
@ -478,7 +477,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 +517,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 +591,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 +599,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 +617,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 +634,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 +677,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 +826,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 +834,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 +842,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 +880,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 +888,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 +896,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 +923,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 +952,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 +984,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 +1014,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(); },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user