Remove by-copy mode from std, mostly

One instance remains in net_tcp due to a foreign fn. Lots of
instances remain in serialization.rs, but IIRC that is being removed.

I had to do unholy things to task-perf-word-count-generic to get it
to compile after demoding pipes. I may well have messed up its
performance, but it passes.
This commit is contained in:
Tim Chevalier 2012-10-04 19:58:31 -07:00
parent f5dfd9b3ce
commit 8fc60af441
35 changed files with 146 additions and 151 deletions

View File

@ -87,7 +87,7 @@ pub fn from_port<A:Send>(port: future_pipe::client::waiting<A>) ->
}
}
pub fn from_fn<A>(+f: ~fn() -> A) -> Future<A> {
pub fn from_fn<A>(f: ~fn() -> A) -> Future<A> {
/*!
* Create a future from a function.
*
@ -99,7 +99,7 @@ pub fn from_fn<A>(+f: ~fn() -> A) -> Future<A> {
Future {state: Pending(move f)}
}
pub fn spawn<A:Send>(+blk: fn~() -> A) -> Future<A> {
pub fn spawn<A:Send>(blk: fn~() -> A) -> Future<A> {
/*!
* Create a future from a unique closure.
*

View File

@ -860,7 +860,7 @@ endpoint is passed to the new task.
pub fn spawn_service<T: Send, Tb: Send>(
init: extern fn() -> (SendPacketBuffered<T, Tb>,
RecvPacketBuffered<T, Tb>),
+service: fn~(v: RecvPacketBuffered<T, Tb>))
service: fn~(v: RecvPacketBuffered<T, Tb>))
-> SendPacketBuffered<T, Tb>
{
let (client, server) = init();
@ -884,7 +884,7 @@ receive state.
pub fn spawn_service_recv<T: Send, Tb: Send>(
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
SendPacketBuffered<T, Tb>),
+service: fn~(v: SendPacketBuffered<T, Tb>))
service: fn~(v: SendPacketBuffered<T, Tb>))
-> RecvPacketBuffered<T, Tb>
{
let (client, server) = init();

View File

@ -46,7 +46,7 @@ type GlobalPtr = *libc::uintptr_t;
pub unsafe fn chan_from_global_ptr<T: Send>(
global: GlobalPtr,
task_fn: fn() -> task::TaskBuilder,
+f: fn~(comm::Port<T>)
f: fn~(comm::Port<T>)
) -> comm::Chan<T> {
enum Msg {

View File

@ -220,7 +220,7 @@ pub type TaskOpts = {
// FIXME (#2585): Replace the 'consumed' bit with move mode on self
pub enum TaskBuilder = {
opts: TaskOpts,
gen_body: fn@(+v: fn~()) -> fn~(),
gen_body: fn@(v: fn~()) -> fn~(),
can_not_copy: Option<util::NonCopyable>,
mut consumed: bool,
};
@ -233,7 +233,7 @@ pub enum TaskBuilder = {
pub fn task() -> TaskBuilder {
TaskBuilder({
opts: default_task_opts(),
gen_body: |+body| move body, // Identity function
gen_body: |body| move body, // Identity function
can_not_copy: None,
mut consumed: false,
})
@ -410,7 +410,7 @@ impl TaskBuilder {
* generator by applying the task body which results from the
* existing body generator to the new body generator.
*/
fn add_wrapper(wrapper: fn@(+v: fn~()) -> fn~()) -> TaskBuilder {
fn add_wrapper(wrapper: fn@(v: fn~()) -> fn~()) -> TaskBuilder {
let prev_gen_body = self.gen_body;
let notify_chan = if self.opts.notify_chan.is_none() {
None
@ -442,7 +442,7 @@ impl TaskBuilder {
* When spawning into a new scheduler, the number of threads requested
* must be greater than zero.
*/
fn spawn(+f: fn~()) {
fn spawn(f: fn~()) {
let notify_chan = if self.opts.notify_chan.is_none() {
None
} else {
@ -460,7 +460,7 @@ impl TaskBuilder {
spawn::spawn_raw(move opts, x.gen_body(move f));
}
/// Runs a task, while transfering ownership of one argument to the child.
fn spawn_with<A: Send>(arg: A, +f: fn~(+v: A)) {
fn spawn_with<A: Send>(arg: A, f: fn~(v: A)) {
let arg = ~mut Some(move arg);
do self.spawn |move arg, move f| {
f(option::swap_unwrap(arg))
@ -478,7 +478,7 @@ impl TaskBuilder {
* otherwise be required to establish communication from the parent
* to the child.
*/
fn spawn_listener<A: Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
fn spawn_listener<A: Send>(f: fn~(comm::Port<A>)) -> comm::Chan<A> {
let setup_po = comm::Port();
let setup_ch = comm::Chan(&setup_po);
do self.spawn |move f| {
@ -494,7 +494,7 @@ impl TaskBuilder {
* Runs a new task, setting up communication in both directions
*/
fn spawn_conversation<A: Send, B: Send>
(+f: fn~(comm::Port<A>, comm::Chan<B>))
(f: fn~(comm::Port<A>, comm::Chan<B>))
-> (comm::Port<B>, comm::Chan<A>) {
let from_child = comm::Port();
let to_parent = comm::Chan(&from_child);
@ -517,7 +517,7 @@ impl TaskBuilder {
* # Failure
* Fails if a future_result was already set for this task.
*/
fn try<T: Send>(+f: fn~() -> T) -> Result<T,()> {
fn try<T: Send>(f: fn~() -> T) -> Result<T,()> {
let po = comm::Port();
let ch = comm::Chan(&po);
let mut result = None;
@ -556,7 +556,7 @@ pub fn default_task_opts() -> TaskOpts {
/* Spawn convenience functions */
pub fn spawn(+f: fn~()) {
pub fn spawn(f: fn~()) {
/*!
* Creates and executes a new child task
*
@ -569,7 +569,7 @@ pub fn spawn(+f: fn~()) {
task().spawn(move f)
}
pub fn spawn_unlinked(+f: fn~()) {
pub fn spawn_unlinked(f: fn~()) {
/*!
* Creates a child task unlinked from the current one. If either this
* task or the child task fails, the other will not be killed.
@ -578,7 +578,7 @@ pub fn spawn_unlinked(+f: fn~()) {
task().unlinked().spawn(move f)
}
pub fn spawn_supervised(+f: fn~()) {
pub fn spawn_supervised(f: fn~()) {
/*!
* Creates a child task unlinked from the current one. If either this
* task or the child task fails, the other will not be killed.
@ -587,7 +587,7 @@ pub fn spawn_supervised(+f: fn~()) {
task().supervised().spawn(move f)
}
pub fn spawn_with<A:Send>(+arg: A, +f: fn~(+v: A)) {
pub fn spawn_with<A:Send>(arg: A, f: fn~(v: A)) {
/*!
* Runs a task, while transfering ownership of one argument to the
* child.
@ -601,7 +601,7 @@ pub fn spawn_with<A:Send>(+arg: A, +f: fn~(+v: A)) {
task().spawn_with(move arg, move f)
}
pub fn spawn_listener<A:Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
pub fn spawn_listener<A:Send>(f: fn~(comm::Port<A>)) -> comm::Chan<A> {
/*!
* Runs a new task while providing a channel from the parent to the child
*
@ -612,7 +612,7 @@ pub fn spawn_listener<A:Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
}
pub fn spawn_conversation<A: Send, B: Send>
(+f: fn~(comm::Port<A>, comm::Chan<B>))
(f: fn~(comm::Port<A>, comm::Chan<B>))
-> (comm::Port<B>, comm::Chan<A>) {
/*!
* Runs a new task, setting up communication in both directions
@ -623,7 +623,7 @@ pub fn spawn_conversation<A: Send, B: Send>
task().spawn_conversation(move f)
}
pub fn spawn_sched(mode: SchedMode, +f: fn~()) {
pub fn spawn_sched(mode: SchedMode, f: fn~()) {
/*!
* Creates a new scheduler and executes a task on it
*
@ -640,7 +640,7 @@ pub fn spawn_sched(mode: SchedMode, +f: fn~()) {
task().sched_mode(mode).spawn(move f)
}
pub fn try<T:Send>(+f: fn~() -> T) -> Result<T,()> {
pub fn try<T:Send>(f: fn~() -> T) -> Result<T,()> {
/*!
* Execute a function in another task and return either the return value
* of the function or result::err.
@ -1127,7 +1127,7 @@ fn test_spawn_sched_blocking() {
}
#[cfg(test)]
fn avoid_copying_the_body(spawnfn: fn(+v: fn~())) {
fn avoid_copying_the_body(spawnfn: fn(v: fn~())) {
let p = comm::Port::<uint>();
let ch = comm::Chan(&p);
@ -1150,7 +1150,7 @@ fn test_avoid_copying_the_body_spawn() {
#[test]
fn test_avoid_copying_the_body_spawn_listener() {
do avoid_copying_the_body |+f| {
do avoid_copying_the_body |f| {
spawn_listener(fn~(move f, _po: comm::Port<int>) {
f();
});
@ -1168,7 +1168,7 @@ fn test_avoid_copying_the_body_task_spawn() {
#[test]
fn test_avoid_copying_the_body_spawn_listener_1() {
do avoid_copying_the_body |+f| {
do avoid_copying_the_body |f| {
task().spawn_listener(fn~(move f, _po: comm::Port<int>) {
f();
});

View File

@ -488,7 +488,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
}
}
pub fn spawn_raw(opts: TaskOpts, +f: fn~()) {
pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
let (child_tg, ancestors, is_main) =
gen_child_taskgroup(opts.linked, opts.supervised);
@ -533,7 +533,7 @@ pub fn spawn_raw(opts: TaskOpts, +f: fn~()) {
fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc,
ancestors: AncestorList, is_main: bool,
notify_chan: Option<Chan<Notification>>,
+f: fn~()) -> fn~() {
f: fn~()) -> fn~() {
let child_data = ~mut Some((move child_arc, move ancestors));
return fn~(move notify_chan, move child_data, move f) {
// Agh. Get move-mode items into the closure. FIXME (#2829)

View File

@ -1,5 +1,5 @@
// NB: transitionary, de-mode-ing.
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
/**
* Concurrency-enabled mechanisms for sharing mutable and/or immutable state
* between tasks.

View File

@ -1,4 +1,4 @@
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
use vec::{to_mut, from_elem};
@ -553,7 +553,7 @@ pure fn land(w0: uint, w1: uint) -> uint { return w0 & w1; }
pure fn right(_w0: uint, w1: uint) -> uint { return w1; }
impl Bitv: ops::Index<uint,bool> {
pure fn index(+i: uint) -> bool {
pure fn index(i: uint) -> bool {
self.get(i)
}
}

View File

@ -25,6 +25,7 @@
* great care must be taken to ensure that a reference to the c_vec::t is
* still held if needed.
*/
#[forbid(deprecated_mode)];
/**
* The type representing a foreign chunk of memory
@ -111,7 +112,7 @@ pub fn get<T: Copy>(t: CVec<T>, ofs: uint) -> T {
*
* Fails if `ofs` is greater or equal to the length of the vector
*/
pub fn set<T: Copy>(t: CVec<T>, ofs: uint, +v: T) {
pub fn set<T: Copy>(t: CVec<T>, ofs: uint, v: T) {
assert ofs < len(t);
unsafe { *ptr::mut_offset((*t).base, ofs) = v };
}

View File

@ -1,4 +1,4 @@
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
/// A dynamic, mutable location.
///
/// Similar to a mutable option type, but friendlier.

View File

@ -16,11 +16,11 @@ pub struct DuplexStream<T: Send, U: Send> {
}
impl<T: Send, U: Send> DuplexStream<T, U> : Channel<T> {
fn send(+x: T) {
fn send(x: T) {
self.chan.send(move x)
}
fn try_send(+x: T) -> bool {
fn try_send(x: T) -> bool {
self.chan.try_send(move x)
}
}

View File

@ -1,4 +1,4 @@
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
//! Unsafe debugging functions for inspecting values.
use cast::reinterpret_cast;

View File

@ -1,5 +1,5 @@
//! A deque. Untested as of yet. Likely buggy
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
#[forbid(non_camel_case_types)];
use option::{Some, None};
@ -200,7 +200,7 @@ mod tests {
assert (deq.get(3) == d);
}
fn test_parameterized<T: Copy Eq Owned>(a: T, +b: T, +c: T, +d: T) {
fn test_parameterized<T: Copy Eq Owned>(a: T, b: T, c: T, d: T) {
let deq: deque::Deque<T> = deque::create::<T>();
assert (deq.size() == 0u);
deq.add_front(a);

View File

@ -1,3 +1,4 @@
#[forbid(deprecated_mode)];
// Simple Extensible Binary Markup Language (ebml) reader and writer on a
// cursor model. See the specification here:
// http://www.matroska.org/technical/specs/rfc/index.html
@ -17,7 +18,7 @@ pub type Doc = {data: @~[u8], start: uint, end: uint};
type TaggedDoc = {tag: uint, doc: Doc};
impl Doc: ops::Index<uint,Doc> {
pure fn index(+tag: uint) -> Doc {
pure fn index(tag: uint) -> Doc {
unsafe {
get_doc(self, tag)
}
@ -563,11 +564,11 @@ impl EbmlDeserializer: serialization::Deserializer {
#[test]
fn test_option_int() {
fn serialize_1<S: serialization::Serializer>(&&s: S, v: int) {
fn serialize_1<S: serialization::Serializer>(s: &S, v: int) {
s.emit_i64(v as i64);
}
fn serialize_0<S: serialization::Serializer>(&&s: S, v: Option<int>) {
fn serialize_0<S: serialization::Serializer>(s: &S, v: Option<int>) {
do s.emit_enum(~"core::option::t") {
match v {
None => s.emit_enum_variant(
@ -581,11 +582,11 @@ fn test_option_int() {
}
}
fn deserialize_1<S: serialization::Deserializer>(&&s: S) -> int {
fn deserialize_1<S: serialization::Deserializer>(s: &S) -> int {
s.read_i64() as int
}
fn deserialize_0<S: serialization::Deserializer>(&&s: S) -> Option<int> {
fn deserialize_0<S: serialization::Deserializer>(s: &S) -> Option<int> {
do s.read_enum(~"core::option::t") {
do s.read_enum_variant |i| {
match i {
@ -608,11 +609,11 @@ fn test_option_int() {
debug!("v == %?", v);
let bytes = do io::with_bytes_writer |wr| {
let ebml_w = ebml::Writer(wr);
serialize_0(ebml_w, v);
serialize_0(&ebml_w, v);
};
let ebml_doc = ebml::Doc(@bytes);
let deser = ebml_deserializer(ebml_doc);
let v1 = deserialize_0(deser);
let v1 = deserialize_0(&deser);
debug!("v1 == %?", v1);
assert v == v1;
}

View File

@ -1,3 +1,4 @@
#[forbid(deprecated_mode)];
use serialization2;
// Simple Extensible Binary Markup Language (ebml) reader and writer on a
@ -31,7 +32,7 @@ struct TaggedDoc {
}
impl Doc: ops::Index<uint,Doc> {
pure fn index(+tag: uint) -> Doc {
pure fn index(tag: uint) -> Doc {
unsafe {
get_doc(self, tag)
}

View File

@ -1,4 +1,4 @@
#[warn(deprecated_mode)];
#[forbid(deprecated_mode)];
/*!
* A functional key,value store that works on anything.
@ -26,7 +26,7 @@ enum TreeNode<K, V> {
pub fn init<K, V>() -> Treemap<K, V> { @Empty }
/// Insert a value into the map
pub fn insert<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K, +v: V)
pub fn insert<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, k: K, v: V)
-> Treemap<K, V> {
@match m {
@Empty => Node(@k, @v, @Empty, @Empty),
@ -41,7 +41,7 @@ pub fn insert<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K, +v: V)
}
/// Find a value based on the key
pub fn find<K: Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K) -> Option<V> {
pub fn find<K: Eq Ord, V: Copy>(m: Treemap<K, V>, k: K) -> Option<V> {
match *m {
Empty => None,
Node(@ref kk, @copy v, left, right) => {

View File

@ -61,8 +61,7 @@
* do_work(input, output);
* }
*/
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
use core::cmp::Eq;
use core::result::{Err, Ok};
@ -162,7 +161,7 @@ fn name_str(nm: &Name) -> ~str {
};
}
fn find_opt(opts: &[Opt], +nm: Name) -> Option<uint> {
fn find_opt(opts: &[Opt], nm: Name) -> Option<uint> {
vec::position(opts, |opt| opt.name == nm)
}
@ -214,7 +213,7 @@ pub type Result = result::Result<Matches, Fail_>;
*/
pub fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe {
let n_opts = vec::len::<Opt>(opts);
fn f(+_x: uint) -> ~[Optval] { return ~[]; }
fn f(_x: uint) -> ~[Optval] { return ~[]; }
let vals = vec::to_mut(vec::from_fn(n_opts, f));
let mut free: ~[~str] = ~[];
let l = vec::len(args);

View File

@ -1,6 +1,6 @@
// Rust JSON serialization library
// Copyright (c) 2011 Google Inc.
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
#[forbid(non_camel_case_types)];
//! json serialization
@ -399,7 +399,7 @@ priv impl Parser {
while char::is_whitespace(self.ch) { self.bump(); }
}
fn parse_ident(ident: &str, +value: Json) -> Result<Json, Error> {
fn parse_ident(ident: &str, value: Json) -> Result<Json, Error> {
if str::all(ident, |c| c == self.next_char()) {
self.bump();
Ok(move value)

View File

@ -1,5 +1,5 @@
//! A standard linked list
#[warn(deprecated_mode)];
#[forbid(deprecated_mode)];
use core::cmp::Eq;
use core::option;
@ -56,7 +56,7 @@ pub fn find<T: Copy>(ls: @List<T>, f: fn((&T)) -> bool) -> Option<T> {
}
/// Returns true if a list contains an element with the given value
pub fn has<T: Copy Eq>(ls: @List<T>, +elt: T) -> bool {
pub fn has<T: Copy Eq>(ls: @List<T>, elt: T) -> bool {
for each(ls) |e| {
if *e == elt { return true; }
}
@ -114,7 +114,7 @@ pub pure fn append<T: Copy>(l: @List<T>, m: @List<T>) -> @List<T> {
/*
/// Push one element into the front of a list, returning a new list
/// THIS VERSION DOESN'T ACTUALLY WORK
pure fn push<T: Copy>(ll: &mut @list<T>, +vv: T) {
pure fn push<T: Copy>(ll: &mut @list<T>, vv: T) {
ll = &mut @cons(vv, *ll)
}
*/

View File

@ -1,6 +1,5 @@
//! A map type
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
use io::WriterUtil;
use to_str::ToStr;
@ -28,7 +27,7 @@ pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
*
* Returns true if the key did not already exist in the map
*/
fn insert(v: K, +v: V) -> bool;
fn insert(v: K, v: V) -> bool;
/// Returns true if the map contains a value for the specified key
fn contains_key(key: K) -> bool;
@ -59,7 +58,7 @@ pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
fn clear();
/// Iterate over all the key/value pairs in the map by value
pure fn each(fn(key: K, +value: V) -> bool);
pure fn each(fn(key: K, value: V) -> bool);
/// Iterate over all the keys in the map by value
pure fn each_key(fn(key: K) -> bool);
@ -213,7 +212,7 @@ pub mod chained {
}
}
fn insert(k: K, +v: V) -> bool {
fn insert(k: K, v: V) -> bool {
let hash = k.hash_keyed(0,0) as uint;
match self.search_tbl(&k, hash) {
NotFound => {
@ -294,7 +293,7 @@ pub mod chained {
self.chains = chains(initial_capacity);
}
pure fn each(blk: fn(key: K, +value: V) -> bool) {
pure fn each(blk: fn(key: K, value: V) -> bool) {
self.each_ref(|k, v| blk(*k, *v))
}
@ -348,7 +347,7 @@ pub mod chained {
}
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: ops::Index<K, V> {
pure fn index(+k: K) -> V {
pure fn index(k: K) -> V {
unsafe {
self.get(k)
}
@ -459,7 +458,7 @@ impl<K: Eq IterBytes Hash Copy, V: Copy> @Mut<LinearMap<K, V>>:
}
}
pure fn each(op: fn(key: K, +value: V) -> bool) {
pure fn each(op: fn(key: K, value: V) -> bool) {
unsafe {
do self.borrow_imm |p| {
p.each(|k, v| op(*k, *v))

View File

@ -1,4 +1,5 @@
//! High-level interface to libuv's TCP functionality
#[warn(deprecated_mode)];
use ip = net_ip;
use uv::iotask;
@ -324,7 +325,7 @@ pub fn read_start(sock: &TcpSocket)
* * `sock` - a `net::tcp::tcp_socket` that you wish to stop reading on
*/
pub fn read_stop(sock: &TcpSocket,
+read_port: comm::Port<result::Result<~[u8], TcpErrData>>) ->
read_port: comm::Port<result::Result<~[u8], TcpErrData>>) ->
result::Result<(), TcpErrData> unsafe {
log(debug, fmt!("taking the read_port out of commission %?", read_port));
let socket_data = ptr::addr_of(&(*sock.socket_data));
@ -558,8 +559,8 @@ pub fn accept(new_conn: TcpNewConnection)
*/
pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
iotask: IoTask,
+on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
+new_connect_cb: fn~(TcpNewConnection,
on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
new_connect_cb: fn~(TcpNewConnection,
comm::Chan<Option<TcpErrData>>))
-> result::Result<(), TcpListenErrData> unsafe {
do listen_common(move host_ip, port, backlog, iotask, on_establish_cb)
@ -575,8 +576,8 @@ pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
iotask: IoTask,
+on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
+on_connect_cb: fn~(*uv::ll::uv_tcp_t))
on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
on_connect_cb: fn~(*uv::ll::uv_tcp_t))
-> result::Result<(), TcpListenErrData> unsafe {
let stream_closed_po = core::comm::Port::<()>();
let kill_po = core::comm::Port::<Option<TcpErrData>>();
@ -749,7 +750,7 @@ impl TcpSocket {
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
impl TcpSocketBuf: io::Reader {
fn read(buf: &[mut u8], +len: uint) -> uint {
fn read(buf: &[mut u8], len: uint) -> uint {
// Loop until our buffer has enough data in it for us to read from.
while self.data.buf.len() < len {
let read_result = read(&self.data.sock, 0u);
@ -785,13 +786,13 @@ impl TcpSocketBuf: io::Reader {
let mut bytes = ~[0];
if self.read(bytes, 1u) == 0 { fail } else { bytes[0] as int }
}
fn unread_byte(+amt: int) {
fn unread_byte(amt: int) {
self.data.buf.unshift(amt as u8);
}
fn eof() -> bool {
false // noop
}
fn seek(+dist: int, +seek: io::SeekStyle) {
fn seek(dist: int, seek: io::SeekStyle) {
log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek));
// noop
}
@ -813,7 +814,7 @@ impl TcpSocketBuf: io::Writer {
err_data.err_name, err_data.err_msg));
}
}
fn seek(+dist: int, +seek: io::SeekStyle) {
fn seek(dist: int, seek: io::SeekStyle) {
log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek));
// noop
}
@ -1474,7 +1475,7 @@ mod test {
str::from_bytes(new_bytes)
}
fn run_tcp_test_server(server_ip: &str, server_port: uint, +resp: ~str,
fn run_tcp_test_server(server_ip: &str, server_port: uint, resp: ~str,
server_ch: comm::Chan<~str>,
cont_ch: comm::Chan<()>,
iotask: IoTask) -> ~str {

View File

@ -1,5 +1,5 @@
//! Types/fns concerning URLs (see RFC 3986)
// tjc: forbid deprecated modes again after a snapshot
#[forbid(deprecated_mode)];
use core::cmp::Eq;
use map::HashMap;
@ -27,15 +27,15 @@ type UserInfo = {
pub type Query = ~[(~str, ~str)];
pub fn Url(scheme: ~str, +user: Option<UserInfo>, +host: ~str,
+port: Option<~str>, +path: ~str, +query: Query,
+fragment: Option<~str>) -> Url {
pub fn Url(scheme: ~str, user: Option<UserInfo>, host: ~str,
port: Option<~str>, path: ~str, query: Query,
fragment: Option<~str>) -> Url {
Url { scheme: move scheme, user: move user, host: move host,
port: move port, path: move path, query: move query,
fragment: move fragment }
}
fn UserInfo(user: ~str, +pass: Option<~str>) -> UserInfo {
fn UserInfo(user: ~str, pass: Option<~str>) -> UserInfo {
{user: move user, pass: move pass}
}
@ -726,7 +726,7 @@ impl Url : Eq {
}
impl Url: IterBytes {
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
unsafe { self.to_str() }.iter_bytes(lsb0, f)
}
}

View File

@ -1,3 +1,5 @@
#[forbid(deprecated_mode)];
use future_spawn = future::spawn;
@ -72,7 +74,7 @@ fn map_slices<A: Copy Send, B: Copy Send>(
}
/// A parallel version of map.
pub fn map<A: Copy Send, B: Copy Send>(xs: &[A], +f: fn~((&A)) -> B) -> ~[B] {
pub fn map<A: Copy Send, B: Copy Send>(xs: &[A], f: fn~((&A)) -> B) -> ~[B] {
vec::concat(map_slices(xs, || {
fn~(_base: uint, slice : &[A], copy f) -> ~[B] {
vec::map(slice, |x| f(x))
@ -82,7 +84,7 @@ pub fn map<A: Copy Send, B: Copy Send>(xs: &[A], +f: fn~((&A)) -> B) -> ~[B] {
/// A parallel version of mapi.
pub fn mapi<A: Copy Send, B: Copy Send>(xs: &[A],
+f: fn~(uint, (&A)) -> B) -> ~[B] {
f: fn~(uint, (&A)) -> B) -> ~[B] {
let slices = map_slices(xs, || {
fn~(base: uint, slice : &[A], copy f) -> ~[B] {
vec::mapi(slice, |i, x| {
@ -119,7 +121,7 @@ pub fn mapi_factory<A: Copy Send, B: Copy Send>(
}
/// Returns true if the function holds for all elements in the vector.
pub fn alli<A: Copy Send>(xs: &[A], +f: fn~(uint, (&A)) -> bool) -> bool {
pub fn alli<A: Copy Send>(xs: &[A], f: fn~(uint, (&A)) -> bool) -> bool {
do vec::all(map_slices(xs, || {
fn~(base: uint, slice : &[A], copy f) -> bool {
vec::alli(slice, |i, x| {
@ -130,7 +132,7 @@ pub fn alli<A: Copy Send>(xs: &[A], +f: fn~(uint, (&A)) -> bool) -> bool {
}
/// Returns true if the function holds for any elements in the vector.
pub fn any<A: Copy Send>(xs: &[A], +f: fn~(&(A)) -> bool) -> bool {
pub fn any<A: Copy Send>(xs: &[A], f: fn~(&(A)) -> bool) -> bool {
do vec::any(map_slices(xs, || {
fn~(_base : uint, slice: &[A], copy f) -> bool {
vec::any(slice, |x| f(x))

View File

@ -2,7 +2,7 @@
* A simple map based on a vector for small integer keys. Space requirements
* are O(highest integer key).
*/
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
use core::option;
use core::option::{Some, None};
@ -103,7 +103,7 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
pure fn find(key: uint) -> Option<V> { find(self, key) }
fn rehash() { fail }
pure fn each(it: fn(key: uint, +value: V) -> bool) {
pure fn each(it: fn(key: uint, value: V) -> bool) {
self.each_ref(|k, v| it(*k, *v))
}
pure fn each_key(it: fn(key: uint) -> bool) {
@ -131,7 +131,7 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
}
impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> {
pure fn index(+key: uint) -> V {
pure fn index(key: uint) -> V {
unsafe {
get(self, key)
}

View File

@ -20,6 +20,7 @@ not required in or otherwise suitable for the core library.
#[allow(vecs_implicitly_copyable)];
#[deny(non_camel_case_types)];
#[warn(deprecated_mode)];
#[forbid(deprecated_pattern)];
extern mod core(vers = "0.4");

View File

@ -1,5 +1,5 @@
// NB: transitionary, de-mode-ing.
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
/**
* The concurrency primitives you know and love.
*

View File

@ -5,7 +5,7 @@
// simplest interface possible for representing and running tests
// while providing a base that other test frameworks may build off of.
#[warn(deprecated_mode)];
#[forbid(deprecated_mode)];
use core::cmp::Eq;
use either::Either;

View File

@ -1,4 +1,4 @@
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
use core::cmp::Eq;
use libc::{c_char, c_int, c_long, size_t, time_t};

View File

@ -1,6 +1,6 @@
//! Utilities that leverage libuv's `uv_timer_*` API
// tjc: forbid deprecated modes again after snap
#[forbid(deprecated_mode)];
use uv = uv;
use uv::iotask;

View File

@ -5,7 +5,7 @@
* very naive algorithm, but it will probably be updated to be a
* red-black tree or something else.
*/
#[warn(deprecated_mode)];
#[forbid(deprecated_mode)];
use core::cmp::{Eq, Ord};
use core::option::{Some, None};
@ -26,7 +26,7 @@ enum TreeNode<K, V> = {
pub fn TreeMap<K, V>() -> TreeMap<K, V> { @mut None }
/// Insert a value into the map
pub fn insert<K: Copy Eq Ord, V: Copy>(m: &mut TreeEdge<K, V>, +k: K, +v: V) {
pub fn insert<K: Copy Eq Ord, V: Copy>(m: &mut TreeEdge<K, V>, k: K, v: V) {
match copy *m {
None => {
*m = Some(@TreeNode({key: k,
@ -48,7 +48,7 @@ pub fn insert<K: Copy Eq Ord, V: Copy>(m: &mut TreeEdge<K, V>, +k: K, +v: V) {
}
/// Find a value based on the key
pub fn find<K: Copy Eq Ord, V: Copy>(m: &const TreeEdge<K, V>, +k: K)
pub fn find<K: Copy Eq Ord, V: Copy>(m: &const TreeEdge<K, V>, k: K)
-> Option<V> {
match copy *m {
None => None,
@ -121,7 +121,7 @@ mod tests {
insert(m, 1, ());
let n = @mut 0;
fn t(n: @mut int, +k: int, +_v: ()) {
fn t(n: @mut int, k: int, _v: ()) {
assert (*n == k); *n += 1;
}
traverse(m, |x,y| t(n, *x, *y));

View File

@ -4,8 +4,7 @@
* The I/O task runs in its own single-threaded scheduler. By using the
* `interact` function you can execute code in a uv callback.
*/
// tjc: forbid deprecated modes again after a snapshot
#[forbid(deprecated_mode)];
use libc::c_void;
use ptr::addr_of;
@ -60,7 +59,7 @@ pub fn spawn_iotask(task: task::TaskBuilder) -> IoTask {
* via ports/chans.
*/
pub unsafe fn interact(iotask: IoTask,
+cb: fn~(*c_void)) {
cb: fn~(*c_void)) {
send_msg(iotask, Interaction(move cb));
}
@ -125,7 +124,7 @@ type IoTaskLoopData = {
};
fn send_msg(iotask: IoTask,
+msg: IoTaskMsg) unsafe {
msg: IoTaskMsg) unsafe {
iotask.op_chan.send(move msg);
ll::async_send(iotask.async_handle);
}

View File

@ -19,7 +19,7 @@
* This module's implementation will hopefully be, eventually, replaced
* with per-platform, generated source files from rust-bindgen.
*/
#[warn(deprecated_mode)];
#[allow(non_camel_case_types)]; // C types
use libc::size_t;
@ -642,7 +642,7 @@ extern mod rustrt {
fn rust_uv_addrinfo_as_sockaddr_in(input: *addrinfo) -> *sockaddr_in;
fn rust_uv_addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6;
fn rust_uv_malloc_buf_base_of(sug_size: libc::size_t) -> *u8;
fn rust_uv_free_base_of_buf(++buf: uv_buf_t);
fn rust_uv_free_base_of_buf(+buf: uv_buf_t);
fn rust_uv_get_stream_handle_from_connect_req(
connect_req: *uv_connect_t)
-> *uv_stream_t;
@ -661,8 +661,8 @@ extern mod rustrt {
fn rust_uv_get_data_for_req(req: *libc::c_void) -> *libc::c_void;
fn rust_uv_set_data_for_req(req: *libc::c_void,
data: *libc::c_void);
fn rust_uv_get_base_from_buf(++buf: uv_buf_t) -> *u8;
fn rust_uv_get_len_from_buf(++buf: uv_buf_t) -> libc::size_t;
fn rust_uv_get_base_from_buf(+buf: uv_buf_t) -> *u8;
fn rust_uv_get_len_from_buf(+buf: uv_buf_t) -> libc::size_t;
// sizeof testing helpers
fn rust_uv_helper_uv_tcp_t_size() -> libc::c_uint;
@ -1357,8 +1357,8 @@ pub mod test {
fn impl_uv_tcp_server(server_ip: &str,
server_port: int,
+kill_server_msg: ~str,
+server_resp_msg: ~str,
kill_server_msg: ~str,
server_resp_msg: ~str,
server_chan: *comm::Chan<~str>,
continue_chan: *comm::Chan<bool>) unsafe {
let test_loop = loop_new();

View File

@ -48,7 +48,6 @@ trait ext_ctxt_ast_builder {
fn ty_param(id: ast::ident, +bounds: ~[ast::ty_param_bound])
-> ast::ty_param;
fn arg(name: ident, ty: @ast::ty) -> ast::arg;
fn arg_mode(name: ident, ty: @ast::ty, mode: ast::rmode) -> ast::arg;
fn expr_block(e: @ast::expr) -> ast::blk;
fn fn_decl(+inputs: ~[ast::arg], output: @ast::ty) -> ast::fn_decl;
fn item(name: ident, span: span, +node: ast::item_) -> @ast::item;
@ -177,13 +176,6 @@ impl ext_ctxt: ext_ctxt_ast_builder {
id: self.next_id()}
}
fn arg_mode(name: ident, ty: @ast::ty, mode: ast::rmode) -> ast::arg {
{mode: ast::expl(mode),
ty: ty,
ident: name,
id: self.next_id()}
}
fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk {
let blk = {view_items: ~[],
stmts: stmts,

View File

@ -47,16 +47,15 @@ impl message: gen_send {
let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str()));
let args_ast = (arg_names, tys).map(
|n, t| cx.arg_mode(*n, *t, ast::by_copy)
|n, t| cx.arg(*n, *t)
);
let pipe_ty = cx.ty_path_ast_builder(
path(~[this.data_name()], span)
.add_tys(cx.ty_vars(this.ty_params)));
let args_ast = vec::append(
~[cx.arg_mode(cx.ident_of(~"pipe"),
pipe_ty,
ast::by_copy)],
~[cx.arg(cx.ident_of(~"pipe"),
pipe_ty)],
args_ast);
let mut body = ~"{\n";
@ -129,15 +128,14 @@ impl message: gen_send {
let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str()));
let args_ast = (arg_names, tys).map(
|n, t| cx.arg_mode(cx.ident_of(*n), *t, ast::by_copy)
|n, t| cx.arg(cx.ident_of(*n), *t)
);
let args_ast = vec::append(
~[cx.arg_mode(cx.ident_of(~"pipe"),
~[cx.arg(cx.ident_of(~"pipe"),
cx.ty_path_ast_builder(
path(~[this.data_name()], span)
.add_tys(cx.ty_vars(this.ty_params))),
ast::by_copy)],
.add_tys(cx.ty_vars(this.ty_params))))],
args_ast);
let message_args = if arg_names.len() == 0 {

View File

@ -22,15 +22,15 @@ use syntax::diagnostic;
use rustc::driver::session;
use rustc::middle::lint;
fn version(argv0: ~str) {
fn version(argv0: &str) {
let mut vers = ~"unknown version";
let env_vers = env!("CFG_VERSION");
if str::len(env_vers) != 0u { vers = env_vers; }
if env_vers.len() != 0 { vers = env_vers; }
io::println(fmt!("%s %s", argv0, vers));
io::println(fmt!("host: %s", host_triple()));
}
fn usage(argv0: ~str) {
fn usage(argv0: &str) {
io::println(fmt!("Usage: %s [options] <input>\n", argv0) +
~"
Options:
@ -86,7 +86,7 @@ fn describe_warnings() {
let lint_dict = lint::get_lint_dict();
let mut max_key = 0;
for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); }
fn padded(max: uint, s: ~str) -> ~str {
fn padded(max: uint, s: &str) -> ~str {
str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
}
io::println(fmt!("\nAvailable lint checks:\n"));
@ -117,14 +117,14 @@ fn describe_debug_flags() {
}
}
fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
fn run_compiler(args: &~[~str], demitter: diagnostic::emitter) {
// Don't display log spew by default. Can override with RUST_LOG.
logging::console_off();
let mut args = args;
let mut args = *args;
let binary = args.shift();
if vec::len(args) == 0u { usage(binary); return; }
if args.is_empty() { usage(binary); return; }
let matches =
match getopts::getopts(args, opts()) {
@ -278,9 +278,9 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
}
fn main() {
let args = os::args();
do monitor |demitter| {
run_compiler(args, demitter);
let mut args = os::args();
do monitor |move args, demitter| {
run_compiler(&args, demitter);
}
}

View File

@ -10,8 +10,6 @@
// xfail-pretty
#[legacy_modes];
extern mod std;
use option = option;
@ -70,18 +68,18 @@ fn map(f: fn~() -> word_reader, emit: map_reduce::putter<~str, int>) {
let f = f();
loop {
match f.read_word() {
Some(w) => { emit(w, 1); }
Some(w) => { emit(&w, 1); }
None => { break; }
}
}
}
fn reduce(&&word: ~str, get: map_reduce::getter<int>) {
fn reduce(word: &~str, get: map_reduce::getter<int>) {
let mut count = 0;
loop { match get() { Some(_) => { count += 1; } None => { break; } } }
io::println(fmt!("%s\t%?", word, count));
io::println(fmt!("%s\t%?", *word, count));
}
struct box<T> {
@ -116,13 +114,13 @@ mod map_reduce {
export reducer;
export map_reduce;
type putter<K: Send, V: Send> = fn(K, V);
type putter<K: Send, V: Send> = fn(&K, V);
type mapper<K1: Send, K2: Send, V: Send> = fn~(K1, putter<K2, V>);
type getter<V: Send> = fn() -> Option<V>;
type reducer<K: Copy Send, V: Copy Send> = fn~(K, getter<V>);
type reducer<K: Copy Send, V: Copy Send> = fn~(&K, getter<V>);
enum ctrl_proto<K: Copy Send, V: Copy Send> {
find_reducer(K, Chan<Chan<reduce_proto<V>>>),
@ -145,9 +143,9 @@ mod map_reduce {
fn start_mappers<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send,
V: Copy Send>(
map: mapper<K1, K2, V>,
map: &mapper<K1, K2, V>,
&ctrls: ~[ctrl_proto::server::open<K2, V>],
inputs: ~[K1])
inputs: &~[K1])
-> ~[joinable_task]
{
let mut tasks = ~[];
@ -155,7 +153,8 @@ mod map_reduce {
let (ctrl, ctrl_server) = ctrl_proto::init();
let ctrl = box(ctrl);
let i = copy *i;
tasks.push(spawn_joinable(|move i| map_task(map, ctrl, i)));
let m = copy *map;
tasks.push(spawn_joinable(|move i| map_task(m, &ctrl, i)));
ctrls.push(ctrl_server);
}
return tasks;
@ -163,20 +162,22 @@ mod map_reduce {
fn map_task<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>(
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 = map::HashMap();
let intermediates: HashMap<K2, Chan<reduce_proto<V>>>
= map::HashMap();
do map(input) |key, val| {
do map(input) |key: &K2, val| {
let mut c = None;
let found = intermediates.find(key);
let found: Option<Chan<reduce_proto<V>>>
= intermediates.find(*key);
match found {
Some(_c) => { c = Some(_c); }
None => {
do ctrl.swap |ctrl| {
let ctrl = ctrl_proto::client::find_reducer(ctrl, key);
let ctrl = ctrl_proto::client::find_reducer(ctrl, *key);
match pipes::recv(ctrl) {
ctrl_proto::reducer(c_, ctrl) => {
c = Some(c_);
@ -184,7 +185,7 @@ mod map_reduce {
}
}
}
intermediates.insert(key, c.get());
intermediates.insert(*key, c.get());
send(c.get(), addref);
}
}
@ -200,7 +201,7 @@ mod map_reduce {
}
fn reduce_task<K: Copy Send, V: Copy Send>(
reduce: reducer<K, V>,
reduce: ~reducer<K, V>,
key: K,
out: Chan<Chan<reduce_proto<V>>>)
{
@ -231,7 +232,7 @@ mod map_reduce {
return None;
}
reduce(key, || get(p, ref_count, is_done) );
(*reduce)(&key, || get(p, ref_count, is_done) );
}
fn map_reduce<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>(
@ -245,7 +246,7 @@ mod map_reduce {
// to do the rest.
let reducers = map::HashMap();
let mut tasks = start_mappers(map, ctrl, inputs);
let mut tasks = start_mappers(&map, ctrl, &inputs);
let mut num_mappers = vec::len(inputs) as int;
while num_mappers > 0 {
@ -270,7 +271,7 @@ mod map_reduce {
let p = Port();
let ch = Chan(&p);
let r = reduce, kk = k;
tasks.push(spawn_joinable(|| reduce_task(r, kk, ch) ));
tasks.push(spawn_joinable(|| reduce_task(~r, kk, ch) ));
c = recv(p);
reducers.insert(k, c);
}