diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-09-23 04:39:27 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-09-23 13:30:13 -0500 |
| commit | ba3eebd41db384c2a46535e8db8c7b2337d55f0b (patch) | |
| tree | 0a746d1b95cd85358fa07aca67683524c8dd1f79 /src/libcore | |
| parent | 2e7ddee8239ceba5989c5dfd83e9a935775b00d1 (diff) | |
| download | rust-ba3eebd41db384c2a46535e8db8c7b2337d55f0b.tar.gz rust-ba3eebd41db384c2a46535e8db8c7b2337d55f0b.zip | |
Make it illegal to use modes in a fn signature with providing
an explicit variable name. (Step one to changing the defaults) First step to #3535
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/at_vec.rs | 7 | ||||
| -rw-r--r-- | src/libcore/dvec.rs | 6 | ||||
| -rw-r--r-- | src/libcore/io.rs | 6 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 6 | ||||
| -rw-r--r-- | src/libcore/option.rs | 6 | ||||
| -rw-r--r-- | src/libcore/pipes.rs | 4 | ||||
| -rw-r--r-- | src/libcore/str.rs | 3 | ||||
| -rw-r--r-- | src/libcore/task.rs | 12 | ||||
| -rw-r--r-- | src/libcore/task/local_data.rs | 2 | ||||
| -rw-r--r-- | src/libcore/task/spawn.rs | 2 | ||||
| -rw-r--r-- | src/libcore/vec.rs | 15 |
11 files changed, 36 insertions, 33 deletions
diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 7864983bde2..1b90e25fdc1 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -50,7 +50,8 @@ pure fn capacity<T>(&&v: @[const T]) -> uint { * onto the vector being constructed. */ #[inline(always)] -pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> @[A] { +pure fn build_sized<A>(size: uint, + builder: fn(push: pure fn(+v: A))) -> @[A] { let mut vec = @[]; unsafe { raw::reserve(vec, size); } builder(|+x| unsafe { raw::push(vec, move x) }); @@ -68,7 +69,7 @@ pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> @[A] { * onto the vector being constructed. */ #[inline(always)] -pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] { +pure fn build<A>(builder: fn(push: pure fn(+v: A))) -> @[A] { build_sized(4, builder) } @@ -86,7 +87,7 @@ pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] { */ #[inline(always)] pure fn build_sized_opt<A>(size: Option<uint>, - builder: fn(push: pure fn(+A))) -> @[A] { + builder: fn(push: pure fn(+v: A))) -> @[A] { build_sized(size.get_default(4), builder) } diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 210ddd483e6..82767112b39 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -93,7 +93,7 @@ priv impl<A> DVec<A> { } #[inline(always)] - fn check_out<B>(f: fn(-~[A]) -> B) -> B { + fn check_out<B>(f: fn(-v: ~[A]) -> B) -> B { unsafe { let mut data = cast::reinterpret_cast(&null::<()>()); data <-> self.data; @@ -126,7 +126,7 @@ impl<A> DVec<A> { * and return a new vector to replace it with. */ #[inline(always)] - fn swap(f: fn(-~[A]) -> ~[A]) { + fn swap(f: fn(-v: ~[A]) -> ~[A]) { self.check_out(|v| self.give_back(f(move v))) } @@ -136,7 +136,7 @@ impl<A> DVec<A> { * and return a new vector to replace it with. */ #[inline(always)] - fn swap_mut(f: fn(-~[mut A]) -> ~[mut A]) { + fn swap_mut(f: fn(-v: ~[mut A]) -> ~[mut A]) { do self.swap |v| { vec::from_mut(f(vec::to_mut(move v))) } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index c4fd5678ac2..bc7f2c9e666 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -827,7 +827,7 @@ mod fsync { // FIXME (#2004) find better way to create resources within lifetime of // outer res fn FILE_res_sync(&&file: FILERes, opt_level: Option<Level>, - blk: fn(&&Res<*libc::FILE>)) { + blk: fn(&&v: Res<*libc::FILE>)) { blk(Res({ val: file.f, opt_level: opt_level, fsync_fn: fn@(&&file: *libc::FILE, l: Level) -> int { @@ -838,7 +838,7 @@ mod fsync { // fsync fd after executing blk fn fd_res_sync(&&fd: FdRes, opt_level: Option<Level>, - blk: fn(&&Res<fd_t>)) { + blk: fn(&&v: Res<fd_t>)) { blk(Res({ val: fd.fd, opt_level: opt_level, fsync_fn: fn@(&&fd: fd_t, l: Level) -> int { @@ -852,7 +852,7 @@ mod fsync { // Call o.fsync after executing blk fn obj_sync(&&o: FSyncable, opt_level: Option<Level>, - blk: fn(&&Res<FSyncable>)) { + blk: fn(&&v: Res<FSyncable>)) { blk(Res({ val: o, opt_level: opt_level, fsync_fn: fn@(&&o: FSyncable, l: Level) -> int { diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index c22d3c6e664..8af4ce3d0b1 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -63,7 +63,7 @@ trait Buildable<A> { * onto the sequence being constructed. */ static pure fn build_sized(size: uint, - builder: fn(push: pure fn(+A))) -> self; + builder: fn(push: pure fn(+v: A))) -> self; } pure fn eachi<A,IA:BaseIter<A>>(self: IA, blk: fn(uint, v: &A) -> bool) { @@ -223,7 +223,7 @@ pure fn find<A: Copy,IA:BaseIter<A>>(self: IA, * onto the sequence being constructed. */ #[inline(always)] -pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(+A))) -> B { +pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(+v: A))) -> B { build_sized(4, builder) } @@ -243,7 +243,7 @@ pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(+A))) -> B { #[inline(always)] pure fn build_sized_opt<A,B: Buildable<A>>( size: Option<uint>, - builder: fn(push: pure fn(+A))) -> B { + builder: fn(push: pure fn(+v: A))) -> B { build_sized(size.get_default(4), builder) } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 0844332672a..cadafc81013 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -69,7 +69,7 @@ pure fn map_ref<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> { match *opt { Some(ref x) => Some(f(x)), None => None } } -pure fn map_consume<T, U>(+opt: Option<T>, f: fn(+T) -> U) -> Option<U> { +pure fn map_consume<T, U>(+opt: Option<T>, f: fn(+v: T) -> U) -> Option<U> { /*! * As `map`, but consumes the option and gives `f` ownership to avoid * copying. @@ -107,7 +107,7 @@ pure fn or<T>(+opta: Option<T>, +optb: Option<T>) -> Option<T> { } #[inline(always)] -pure fn while_some<T>(+x: Option<T>, blk: fn(+T) -> Option<T>) { +pure fn while_some<T>(+x: Option<T>, blk: fn(+v: T) -> Option<T>) { //! Applies a function zero or more times until the result is none. let mut opt <- x; @@ -248,7 +248,7 @@ impl<T: Copy> Option<T> { */ pure fn expect(reason: ~str) -> T { expect(self, reason) } /// Applies a function zero or more times until the result is none. - pure fn while_some(blk: fn(+T) -> Option<T>) { while_some(self, blk) } + pure fn while_some(blk: fn(+v: T) -> Option<T>) { while_some(self, blk) } } #[cfg(stage0)] diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 5b977080573..ecc1e4e8a63 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -889,7 +889,7 @@ endpoint is passed to the new task. fn spawn_service<T: Send, Tb: Send>( init: extern fn() -> (SendPacketBuffered<T, Tb>, RecvPacketBuffered<T, Tb>), - +service: fn~(+RecvPacketBuffered<T, Tb>)) + +service: fn~(+v: RecvPacketBuffered<T, Tb>)) -> SendPacketBuffered<T, Tb> { let (client, server) = init(); @@ -913,7 +913,7 @@ receive state. fn spawn_service_recv<T: Send, Tb: Send>( init: extern fn() -> (RecvPacketBuffered<T, Tb>, SendPacketBuffered<T, Tb>), - +service: fn~(+SendPacketBuffered<T, Tb>)) + +service: fn~(+v: SendPacketBuffered<T, Tb>)) -> RecvPacketBuffered<T, Tb> { let (client, server) = init(); diff --git a/src/libcore/str.rs b/src/libcore/str.rs index bc0a321360e..ab4e77895b9 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -2109,7 +2109,8 @@ mod raw { unsafe fn from_byte(u: u8) -> ~str { raw::from_bytes([u]) } /// Form a slice from a *u8 buffer of the given length without copying. - unsafe fn buf_as_slice<T>(buf: *u8, len: uint, f: fn(&& &str) -> T) -> T { + unsafe fn buf_as_slice<T>(buf: *u8, len: uint, + f: fn(&&v: &str) -> T) -> T { let v = (buf, len + 1); assert is_utf8(::cast::reinterpret_cast(&v)); f(::cast::transmute(move v)) diff --git a/src/libcore/task.rs b/src/libcore/task.rs index baabd711456..1f38a10b2e7 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -338,7 +338,7 @@ type TaskOpts = { // FIXME (#2585): Replace the 'consumed' bit with move mode on self enum TaskBuilder = { opts: TaskOpts, - gen_body: fn@(+fn~()) -> fn~(), + gen_body: fn@(+v: fn~()) -> fn~(), can_not_copy: Option<util::NonCopyable>, mut consumed: bool, }; @@ -466,7 +466,7 @@ impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - fn future_result(blk: fn(+future::Future<TaskResult>)) -> TaskBuilder { + fn future_result(blk: fn(+v: future::Future<TaskResult>)) -> TaskBuilder { // FIXME (#1087, #1857): Once linked failure and notification are // handled in the library, I can imagine implementing this by just // registering an arbitrary number of task::on_exit handlers and @@ -528,7 +528,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@(+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 @@ -578,7 +578,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~(+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)) @@ -705,7 +705,7 @@ fn spawn_supervised(+f: fn~()) { task().supervised().spawn(move f) } -fn spawn_with<A:Send>(+arg: A, +f: fn~(+A)) { +fn spawn_with<A:Send>(+arg: A, +f: fn~(+v: A)) { /*! * Runs a task, while transfering ownership of one argument to the * child. @@ -1246,7 +1246,7 @@ fn test_spawn_sched_blocking() { } #[cfg(test)] -fn avoid_copying_the_body(spawnfn: fn(+fn~())) { +fn avoid_copying_the_body(spawnfn: fn(+v: fn~())) { let p = comm::Port::<uint>(); let ch = comm::Chan(p); diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index 3a85055eb02..d91783284c0 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -43,7 +43,7 @@ use local_data_priv::{ * * These two cases aside, the interface is safe. */ -type LocalDataKey<T: Owned> = &fn(+@T); +type LocalDataKey<T: Owned> = &fn(+v: @T); /** * Remove a task-local data value from the table, returning the diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 40364acf29a..21f217d57f4 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -82,7 +82,7 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) { let was_present = tasks.remove(&task); assert was_present; } -fn taskset_each(tasks: &TaskSet, blk: fn(+*rust_task) -> bool) { +fn taskset_each(tasks: &TaskSet, blk: fn(+v: *rust_task) -> bool) { tasks.each_key(|k| blk(*k)) } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 1e3d0530fb3..1dea6dbd17c 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -235,7 +235,8 @@ pure fn with_capacity<T>(capacity: uint) -> ~[T] { * onto the vector being constructed. */ #[inline(always)] -pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> ~[A] { +pure fn build_sized<A>(size: uint, + builder: fn(push: pure fn(+v: A))) -> ~[A] { let mut vec = with_capacity(size); builder(|+x| unsafe { push(vec, move x) }); move vec @@ -252,7 +253,7 @@ pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> ~[A] { * onto the vector being constructed. */ #[inline(always)] -pure fn build<A>(builder: fn(push: pure fn(+A))) -> ~[A] { +pure fn build<A>(builder: fn(push: pure fn(+v: A))) -> ~[A] { build_sized(4, builder) } @@ -270,7 +271,7 @@ pure fn build<A>(builder: fn(push: pure fn(+A))) -> ~[A] { */ #[inline(always)] pure fn build_sized_opt<A>(size: Option<uint>, - builder: fn(push: pure fn(+A))) -> ~[A] { + builder: fn(push: pure fn(+v: A))) -> ~[A] { build_sized(size.get_default(4), builder) } @@ -506,7 +507,7 @@ fn unshift<T>(&v: ~[T], +x: T) { } } -fn consume<T>(+v: ~[T], f: fn(uint, +T)) unsafe { +fn consume<T>(+v: ~[T], f: fn(uint, +v: T)) unsafe { do as_imm_buf(v) |p, ln| { for uint::range(0, ln) |i| { let x <- *ptr::offset(p, i); @@ -517,7 +518,7 @@ fn consume<T>(+v: ~[T], f: fn(uint, +T)) unsafe { raw::set_len(v, 0); } -fn consume_mut<T>(+v: ~[mut T], f: fn(uint, +T)) unsafe { +fn consume_mut<T>(+v: ~[mut T], f: fn(uint, +v: T)) unsafe { do as_imm_buf(v) |p, ln| { for uint::range(0, ln) |i| { let x <- *ptr::offset(p, i); @@ -748,7 +749,7 @@ pure fn map<T, U>(v: &[T], f: fn(v: &T) -> U) -> ~[U] { move result } -fn map_consume<T, U>(+v: ~[T], f: fn(+T) -> U) -> ~[U] { +fn map_consume<T, U>(+v: ~[T], f: fn(+v: T) -> U) -> ~[U] { let mut result = ~[]; do consume(move v) |_i, x| { vec::push(result, f(move x)); @@ -1808,7 +1809,7 @@ mod raw { * not bytes). */ #[inline(always)] - unsafe fn form_slice<T,U>(p: *T, len: uint, f: fn(&& &[T]) -> U) -> U { + unsafe fn form_slice<T,U>(p: *T, len: uint, f: fn(&&v: &[T]) -> U) -> U { let pair = (p, len * sys::size_of::<T>()); let v : *(&blk/[T]) = ::cast::reinterpret_cast(&ptr::addr_of(pair)); |
