Skip to content

Commit ba3eebd

Browse files
committed
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
1 parent 2e7ddee commit ba3eebd

35 files changed

+111
-92
lines changed

src/libcore/at_vec.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ pure fn capacity<T>(&&v: @[const T]) -> uint {
5050
* onto the vector being constructed.
5151
*/
5252
#[inline(always)]
53-
pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> @[A] {
53+
pure fn build_sized<A>(size: uint,
54+
builder: fn(push: pure fn(+v: A))) -> @[A] {
5455
let mut vec = @[];
5556
unsafe { raw::reserve(vec, size); }
5657
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] {
6869
* onto the vector being constructed.
6970
*/
7071
#[inline(always)]
71-
pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] {
72+
pure fn build<A>(builder: fn(push: pure fn(+v: A))) -> @[A] {
7273
build_sized(4, builder)
7374
}
7475

@@ -86,7 +87,7 @@ pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] {
8687
*/
8788
#[inline(always)]
8889
pure fn build_sized_opt<A>(size: Option<uint>,
89-
builder: fn(push: pure fn(+A))) -> @[A] {
90+
builder: fn(push: pure fn(+v: A))) -> @[A] {
9091
build_sized(size.get_default(4), builder)
9192
}
9293

src/libcore/dvec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ priv impl<A> DVec<A> {
9393
}
9494

9595
#[inline(always)]
96-
fn check_out<B>(f: fn(-~[A]) -> B) -> B {
96+
fn check_out<B>(f: fn(-v: ~[A]) -> B) -> B {
9797
unsafe {
9898
let mut data = cast::reinterpret_cast(&null::<()>());
9999
data <-> self.data;
@@ -126,7 +126,7 @@ impl<A> DVec<A> {
126126
* and return a new vector to replace it with.
127127
*/
128128
#[inline(always)]
129-
fn swap(f: fn(-~[A]) -> ~[A]) {
129+
fn swap(f: fn(-v: ~[A]) -> ~[A]) {
130130
self.check_out(|v| self.give_back(f(move v)))
131131
}
132132

@@ -136,7 +136,7 @@ impl<A> DVec<A> {
136136
* and return a new vector to replace it with.
137137
*/
138138
#[inline(always)]
139-
fn swap_mut(f: fn(-~[mut A]) -> ~[mut A]) {
139+
fn swap_mut(f: fn(-v: ~[mut A]) -> ~[mut A]) {
140140
do self.swap |v| {
141141
vec::from_mut(f(vec::to_mut(move v)))
142142
}

src/libcore/io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ mod fsync {
827827
// FIXME (#2004) find better way to create resources within lifetime of
828828
// outer res
829829
fn FILE_res_sync(&&file: FILERes, opt_level: Option<Level>,
830-
blk: fn(&&Res<*libc::FILE>)) {
830+
blk: fn(&&v: Res<*libc::FILE>)) {
831831
blk(Res({
832832
val: file.f, opt_level: opt_level,
833833
fsync_fn: fn@(&&file: *libc::FILE, l: Level) -> int {
@@ -838,7 +838,7 @@ mod fsync {
838838

839839
// fsync fd after executing blk
840840
fn fd_res_sync(&&fd: FdRes, opt_level: Option<Level>,
841-
blk: fn(&&Res<fd_t>)) {
841+
blk: fn(&&v: Res<fd_t>)) {
842842
blk(Res({
843843
val: fd.fd, opt_level: opt_level,
844844
fsync_fn: fn@(&&fd: fd_t, l: Level) -> int {
@@ -852,7 +852,7 @@ mod fsync {
852852

853853
// Call o.fsync after executing blk
854854
fn obj_sync(&&o: FSyncable, opt_level: Option<Level>,
855-
blk: fn(&&Res<FSyncable>)) {
855+
blk: fn(&&v: Res<FSyncable>)) {
856856
blk(Res({
857857
val: o, opt_level: opt_level,
858858
fsync_fn: fn@(&&o: FSyncable, l: Level) -> int {

src/libcore/iter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ trait Buildable<A> {
6363
* onto the sequence being constructed.
6464
*/
6565
static pure fn build_sized(size: uint,
66-
builder: fn(push: pure fn(+A))) -> self;
66+
builder: fn(push: pure fn(+v: A))) -> self;
6767
}
6868

6969
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,
223223
* onto the sequence being constructed.
224224
*/
225225
#[inline(always)]
226-
pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(+A))) -> B {
226+
pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(+v: A))) -> B {
227227
build_sized(4, builder)
228228
}
229229

@@ -243,7 +243,7 @@ pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(+A))) -> B {
243243
#[inline(always)]
244244
pure fn build_sized_opt<A,B: Buildable<A>>(
245245
size: Option<uint>,
246-
builder: fn(push: pure fn(+A))) -> B {
246+
builder: fn(push: pure fn(+v: A))) -> B {
247247

248248
build_sized(size.get_default(4), builder)
249249
}

src/libcore/option.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pure fn map_ref<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> {
6969
match *opt { Some(ref x) => Some(f(x)), None => None }
7070
}
7171

72-
pure fn map_consume<T, U>(+opt: Option<T>, f: fn(+T) -> U) -> Option<U> {
72+
pure fn map_consume<T, U>(+opt: Option<T>, f: fn(+v: T) -> U) -> Option<U> {
7373
/*!
7474
* As `map`, but consumes the option and gives `f` ownership to avoid
7575
* copying.
@@ -107,7 +107,7 @@ pure fn or<T>(+opta: Option<T>, +optb: Option<T>) -> Option<T> {
107107
}
108108

109109
#[inline(always)]
110-
pure fn while_some<T>(+x: Option<T>, blk: fn(+T) -> Option<T>) {
110+
pure fn while_some<T>(+x: Option<T>, blk: fn(+v: T) -> Option<T>) {
111111
//! Applies a function zero or more times until the result is none.
112112
113113
let mut opt <- x;
@@ -248,7 +248,7 @@ impl<T: Copy> Option<T> {
248248
*/
249249
pure fn expect(reason: ~str) -> T { expect(self, reason) }
250250
/// Applies a function zero or more times until the result is none.
251-
pure fn while_some(blk: fn(+T) -> Option<T>) { while_some(self, blk) }
251+
pure fn while_some(blk: fn(+v: T) -> Option<T>) { while_some(self, blk) }
252252
}
253253

254254
#[cfg(stage0)]

src/libcore/pipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ endpoint is passed to the new task.
889889
fn spawn_service<T: Send, Tb: Send>(
890890
init: extern fn() -> (SendPacketBuffered<T, Tb>,
891891
RecvPacketBuffered<T, Tb>),
892-
+service: fn~(+RecvPacketBuffered<T, Tb>))
892+
+service: fn~(+v: RecvPacketBuffered<T, Tb>))
893893
-> SendPacketBuffered<T, Tb>
894894
{
895895
let (client, server) = init();
@@ -913,7 +913,7 @@ receive state.
913913
fn spawn_service_recv<T: Send, Tb: Send>(
914914
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
915915
SendPacketBuffered<T, Tb>),
916-
+service: fn~(+SendPacketBuffered<T, Tb>))
916+
+service: fn~(+v: SendPacketBuffered<T, Tb>))
917917
-> RecvPacketBuffered<T, Tb>
918918
{
919919
let (client, server) = init();

src/libcore/str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,8 @@ mod raw {
21092109
unsafe fn from_byte(u: u8) -> ~str { raw::from_bytes([u]) }
21102110

21112111
/// Form a slice from a *u8 buffer of the given length without copying.
2112-
unsafe fn buf_as_slice<T>(buf: *u8, len: uint, f: fn(&& &str) -> T) -> T {
2112+
unsafe fn buf_as_slice<T>(buf: *u8, len: uint,
2113+
f: fn(&&v: &str) -> T) -> T {
21132114
let v = (buf, len + 1);
21142115
assert is_utf8(::cast::reinterpret_cast(&v));
21152116
f(::cast::transmute(move v))

src/libcore/task.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ type TaskOpts = {
338338
// FIXME (#2585): Replace the 'consumed' bit with move mode on self
339339
enum TaskBuilder = {
340340
opts: TaskOpts,
341-
gen_body: fn@(+fn~()) -> fn~(),
341+
gen_body: fn@(+v: fn~()) -> fn~(),
342342
can_not_copy: Option<util::NonCopyable>,
343343
mut consumed: bool,
344344
};
@@ -466,7 +466,7 @@ impl TaskBuilder {
466466
* # Failure
467467
* Fails if a future_result was already set for this task.
468468
*/
469-
fn future_result(blk: fn(+future::Future<TaskResult>)) -> TaskBuilder {
469+
fn future_result(blk: fn(+v: future::Future<TaskResult>)) -> TaskBuilder {
470470
// FIXME (#1087, #1857): Once linked failure and notification are
471471
// handled in the library, I can imagine implementing this by just
472472
// registering an arbitrary number of task::on_exit handlers and
@@ -528,7 +528,7 @@ impl TaskBuilder {
528528
* generator by applying the task body which results from the
529529
* existing body generator to the new body generator.
530530
*/
531-
fn add_wrapper(wrapper: fn@(+fn~()) -> fn~()) -> TaskBuilder {
531+
fn add_wrapper(wrapper: fn@(+v: fn~()) -> fn~()) -> TaskBuilder {
532532
let prev_gen_body = self.gen_body;
533533
let notify_chan = if self.opts.notify_chan.is_none() {
534534
None
@@ -578,7 +578,7 @@ impl TaskBuilder {
578578
spawn::spawn_raw(move opts, x.gen_body(move f));
579579
}
580580
/// Runs a task, while transfering ownership of one argument to the child.
581-
fn spawn_with<A: Send>(+arg: A, +f: fn~(+A)) {
581+
fn spawn_with<A: Send>(+arg: A, +f: fn~(+v: A)) {
582582
let arg = ~mut Some(move arg);
583583
do self.spawn |move arg, move f|{
584584
f(option::swap_unwrap(arg))
@@ -705,7 +705,7 @@ fn spawn_supervised(+f: fn~()) {
705705
task().supervised().spawn(move f)
706706
}
707707
708-
fn spawn_with<A:Send>(+arg: A, +f: fn~(+A)) {
708+
fn spawn_with<A:Send>(+arg: A, +f: fn~(+v: A)) {
709709
/*!
710710
* Runs a task, while transfering ownership of one argument to the
711711
* child.
@@ -1246,7 +1246,7 @@ fn test_spawn_sched_blocking() {
12461246
}
12471247

12481248
#[cfg(test)]
1249-
fn avoid_copying_the_body(spawnfn: fn(+fn~())) {
1249+
fn avoid_copying_the_body(spawnfn: fn(+v: fn~())) {
12501250
let p = comm::Port::<uint>();
12511251
let ch = comm::Chan(p);
12521252

src/libcore/task/local_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use local_data_priv::{
4343
*
4444
* These two cases aside, the interface is safe.
4545
*/
46-
type LocalDataKey<T: Owned> = &fn(+@T);
46+
type LocalDataKey<T: Owned> = &fn(+v: @T);
4747

4848
/**
4949
* Remove a task-local data value from the table, returning the

src/libcore/task/spawn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) {
8282
let was_present = tasks.remove(&task);
8383
assert was_present;
8484
}
85-
fn taskset_each(tasks: &TaskSet, blk: fn(+*rust_task) -> bool) {
85+
fn taskset_each(tasks: &TaskSet, blk: fn(+v: *rust_task) -> bool) {
8686
tasks.each_key(|k| blk(*k))
8787
}
8888

0 commit comments

Comments
 (0)