Revert "librustc: Make unqualified identifier searches terminate at the nearest module scope. r=tjc"

This reverts commit a8d37af247.
This commit is contained in:
Patrick Walton 2013-01-08 19:29:16 -08:00
parent a8d37af247
commit 44ab00ee37
250 changed files with 453 additions and 1342 deletions

View file

@ -45,9 +45,9 @@ trait word_reader {
fn read_word() -> Option<~str>;
}
// These used to be in task, but they disappeared.
pub type joinable_task = Port<()>;
pub fn spawn_joinable(+f: fn~()) -> joinable_task {
// These used to be in task, but they disappeard.
type joinable_task = Port<()>;
fn spawn_joinable(+f: fn~()) -> joinable_task {
let p = Port();
let c = Chan(&p);
do task::spawn() |move f| {
@ -57,7 +57,7 @@ pub fn spawn_joinable(+f: fn~()) -> joinable_task {
p
}
pub fn join(t: joinable_task) {
fn join(t: joinable_task) {
t.recv()
}
@ -90,11 +90,11 @@ fn reduce(word: &~str, get: map_reduce::getter<int>) {
io::println(fmt!("%s\t%?", *word, count));
}
pub struct box<T> {
struct box<T> {
mut contents: Option<T>,
}
pub impl<T> box<T> {
impl<T> box<T> {
fn swap(f: fn(+v: T) -> T) {
let mut tmp = None;
self.contents <-> tmp;
@ -108,16 +108,13 @@ pub impl<T> box<T> {
}
}
pub fn box<T>(+x: T) -> box<T> {
fn box<T>(+x: T) -> box<T> {
box {
contents: Some(move x)
}
}
mod map_reduce {
use core::oldcomm::*;
use std::map::HashMap;
use std::map;
pub type putter<K: Owned, V: Owned> = fn(&K, V);
@ -129,7 +126,7 @@ mod map_reduce {
pub type reducer<K: Copy Owned, V: Copy Owned> = fn~(&K, getter<V>);
enum ctrl_proto<K: Copy Owned, V: Copy Owned> {
find_reducer(K, Chan<Chan<::map_reduce::reduce_proto<V>>>),
find_reducer(K, Chan<Chan<reduce_proto<V>>>),
mapper_done
}
@ -141,32 +138,26 @@ mod map_reduce {
}
reducer_response: recv<K: Copy Owned, V: Copy Owned> {
reducer(::core::oldcomm::Chan<::map_reduce::reduce_proto<V>>)
-> open<K, V>
reducer(Chan<reduce_proto<V>>) -> open<K, V>
}
)
pub enum reduce_proto<V: Copy Owned> {
emit_val(V),
done,
addref,
release
}
enum reduce_proto<V: Copy Owned> { emit_val(V), done, addref, release }
fn start_mappers<K1: Copy Owned, K2: Hash IterBytes Eq Const Copy Owned,
V: Copy Owned>(
map: &mapper<K1, K2, V>,
ctrls: &mut ~[ctrl_proto::server::open<K2, V>],
inputs: &~[K1])
-> ~[::joinable_task]
-> ~[joinable_task]
{
let mut tasks = ~[];
for inputs.each |i| {
let (ctrl, ctrl_server) = ctrl_proto::init();
let ctrl = ::box(move ctrl);
let ctrl = box(move ctrl);
let i = copy *i;
let m = copy *map;
tasks.push(::spawn_joinable(|move ctrl, move i| map_task(copy m, &ctrl, i)));
tasks.push(spawn_joinable(|move ctrl, move i| map_task(copy m, &ctrl, i)));
ctrls.push(move ctrl_server);
}
move tasks
@ -174,16 +165,16 @@ mod map_reduce {
fn map_task<K1: Copy Owned, K2: Hash IterBytes Eq Const Copy Owned, V: Copy Owned>(
map: mapper<K1, K2, V>,
ctrl: &::box<ctrl_proto::client::open<K2, V>>,
ctrl: &box<ctrl_proto::client::open<K2, V>>,
input: K1)
{
// log(error, "map_task " + input);
let intermediates: HashMap<K2, Chan<::map_reduce::reduce_proto<V>>>
let intermediates: HashMap<K2, Chan<reduce_proto<V>>>
= map::HashMap();
do map(input) |key: &K2, val| {
let mut c = None;
let found: Option<Chan<::map_reduce::reduce_proto<V>>>
let found: Option<Chan<reduce_proto<V>>>
= intermediates.find(*key);
match found {
Some(_c) => { c = Some(_c); }
@ -204,8 +195,7 @@ mod map_reduce {
send(c.get(), emit_val(val));
}
fn finish<K: Copy Owned, V: Copy Owned>(
_k: K, v: Chan<::map_reduce::reduce_proto<V>>)
fn finish<K: Copy Owned, V: Copy Owned>(_k: K, v: Chan<reduce_proto<V>>)
{
send(v, release);
}
@ -216,7 +206,7 @@ mod map_reduce {
fn reduce_task<K: Copy Owned, V: Copy Owned>(
reduce: ~reducer<K, V>,
key: K,
out: Chan<Chan<::map_reduce::reduce_proto<V>>>)
out: Chan<Chan<reduce_proto<V>>>)
{
let p = Port();
@ -225,7 +215,7 @@ mod map_reduce {
let mut ref_count = 0;
let mut is_done = false;
fn get<V: Copy Owned>(p: Port<::map_reduce::reduce_proto<V>>,
fn get<V: Copy Owned>(p: Port<reduce_proto<V>>,
ref_count: &mut int, is_done: &mut bool)
-> Option<V> {
while !*is_done || *ref_count > 0 {
@ -284,7 +274,7 @@ mod map_reduce {
let p = Port();
let ch = Chan(&p);
let r = copy reduce, kk = k;
tasks.push(::spawn_joinable(|move r|
tasks.push(spawn_joinable(|move r|
reduce_task(~copy r, kk, ch)
));
c = recv(p);
@ -300,7 +290,7 @@ mod map_reduce {
for reducers.each_value |v| { send(v, done) }
for tasks.each |t| { ::join(*t); }
for tasks.each |t| { join(*t); }
}
}

View file

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn closure2(+x: core::util::NonCopyable)
-> (core::util::NonCopyable, fn@() -> core::util::NonCopyable) {
let f = fn@(copy x) -> core::util::NonCopyable {
fn closure2(+x: util::NonCopyable) -> (util::NonCopyable,
fn@() -> util::NonCopyable) {
let f = fn@(copy x) -> util::NonCopyable {
//~^ ERROR copying a noncopyable value
//~^^ NOTE non-copyable value cannot be copied into a @fn closure
copy x
@ -18,7 +18,7 @@ fn closure2(+x: core::util::NonCopyable)
};
(move x,f)
}
fn closure3(+x: core::util::NonCopyable) {
fn closure3(+x: util::NonCopyable) {
do task::spawn |copy x| {
//~^ ERROR copying a noncopyable value
//~^^ NOTE non-copyable value cannot be copied into a ~fn closure

View file

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub struct send_packet<T: Copy> {
struct send_packet<T: Copy> {
p: T
}
mod pingpong {
use send_packet;
pub type ping = send_packet<pong>;
pub enum pong = send_packet<ping>; //~ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable
#[legacy_exports];
type ping = send_packet<pong>;
enum pong = send_packet<ping>; //~ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable
}
fn main() {}

View file

@ -9,11 +9,16 @@
// except according to those terms.
mod foo {
#[legacy_exports];
export bar;
mod bar {
pub fn y() { ::foo::x(); }
#[legacy_exports];
fn y() { x(); }
}
pub fn x() { debug!("x"); }
fn x() { debug!("x"); }
}
fn main() { foo::bar::y(); }

View file

@ -20,20 +20,16 @@ extern mod std;
use std::map;
use std::map::HashMap;
use core::oldcomm::Chan;
use core::oldcomm::Port;
use core::oldcomm::send;
use core::oldcomm::recv;
use oldcomm::Chan;
use oldcomm::Port;
use oldcomm::send;
use oldcomm::recv;
pub fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, ~"1"); }
fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, ~"1"); }
mod map_reduce {
use std::map;
use std::map::HashMap;
use core::oldcomm::Chan;
use core::oldcomm::Port;
use core::oldcomm::send;
use core::oldcomm::recv;
pub type putter = fn@(~str, ~str);
@ -68,7 +64,7 @@ mod map_reduce {
}
}
::map(input, |a,b| emit(intermediates, ctrl, a, b) );
map(input, |a,b| emit(intermediates, ctrl, a, b) );
send(ctrl, mapper_done);
}

View file

@ -250,7 +250,7 @@ pub mod pingpong {
pub fn do_ping(-c: ping) -> pong {
let (sp, rp) = ::pipes::entangle();
::pipes::send(move c, pingpong::ping(move sp));
::pipes::send(move c, ping(move sp));
move rp
}
@ -259,7 +259,7 @@ pub mod pingpong {
if packet.is_none() {
fail ~"sender closed the connection"
}
(pingpong::liberate_pong(option::unwrap(move packet)), ())
(liberate_pong(option::unwrap(move packet)), ())
}
}
@ -274,12 +274,12 @@ pub mod pingpong {
if packet.is_none() {
fail ~"sender closed the connection"
}
(pingpong::liberate_ping(option::unwrap(move packet)), ())
(liberate_ping(option::unwrap(move packet)), ())
}
pub fn do_pong(-c: pong) -> ping {
let (sp, rp) = ::pipes::entangle();
::pipes::send(move c, pingpong::pong(move sp));
::pipes::send(move c, pong(move sp));
move rp
}
}

View file

@ -17,14 +17,14 @@
use pipes::try_recv;
pub type username = ~str;
pub type password = ~str;
pub type money = float;
pub type amount = float;
type username = ~str;
type password = ~str;
type money = float;
type amount = float;
proto! bank (
login:send {
login(::username, ::password) -> login_response
login(username, password) -> login_response
}
login_response:recv {
@ -33,12 +33,12 @@ proto! bank (
}
connected:send {
deposit(::money) -> connected,
withdrawal(::amount) -> withdrawal_response
deposit(money) -> connected,
withdrawal(amount) -> withdrawal_response
}
withdrawal_response:recv {
money(::money) -> connected,
money(money) -> connected,
insufficient_funds -> connected
}
)

View file

@ -43,7 +43,6 @@ mod pingpong {
pub enum ping = server::pong;
pub enum pong = client::ping;
pub mod client {
use core::pipes::*;
use core::ptr;
pub fn ping(+pipe: ping) -> pong {
@ -62,7 +61,6 @@ mod pingpong {
::pingpong::packets>;
}
pub mod server {
use core::pipes::*;
use core::ptr;
pub type ping = pipes::RecvPacketBuffered<::pingpong::ping,

View file

@ -75,12 +75,12 @@ macro_rules! select (
)
// Types and protocols
pub struct Buffer {
struct Buffer {
foo: (),
}
pub impl Buffer : Drop {
impl Buffer : Drop {
fn finalize(&self) {}
}
@ -90,11 +90,11 @@ proto! double_buffer (
}
wait_buffer:recv {
give_buffer(::Buffer) -> release
give_buffer(Buffer) -> release
}
release:send {
release(::Buffer) -> acquire
release(Buffer) -> acquire
}
)

View file

@ -11,7 +11,6 @@
// xfail-fast
#[legacy_modes];
use core::bool;
use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor};
use libc::c_void;
use vec::UnboxedVecRepr;

View file

@ -11,18 +11,20 @@
// xfail-fast
#[legacy_modes];
pub trait plus {
use a::*;
trait plus {
fn plus() -> int;
}
mod a {
use plus;
pub impl uint: plus { fn plus() -> int { self as int + 20 } }
#[legacy_exports];
impl uint: plus { fn plus() -> int { self as int + 20 } }
}
mod b {
use plus;
pub impl ~str: plus { fn plus() -> int { 200 } }
#[legacy_exports];
impl ~str: plus { fn plus() -> int { 200 } }
}
trait uint_utils {