mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
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
This commit is contained in:
parent
2e7ddee823
commit
ba3eebd41d
@ -50,7 +50,8 @@ pure fn capacity<T>(&&v: @[const T]) -> uint {
|
|||||||
* onto the vector being constructed.
|
* onto the vector being constructed.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[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 = @[];
|
let mut vec = @[];
|
||||||
unsafe { raw::reserve(vec, size); }
|
unsafe { raw::reserve(vec, size); }
|
||||||
builder(|+x| unsafe { raw::push(vec, move x) });
|
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.
|
* onto the vector being constructed.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[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)
|
build_sized(4, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] {
|
|||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn build_sized_opt<A>(size: Option<uint>,
|
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)
|
build_sized(size.get_default(4), builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ priv impl<A> DVec<A> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn check_out<B>(f: fn(-~[A]) -> B) -> B {
|
fn check_out<B>(f: fn(-v: ~[A]) -> B) -> B {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut data = cast::reinterpret_cast(&null::<()>());
|
let mut data = cast::reinterpret_cast(&null::<()>());
|
||||||
data <-> self.data;
|
data <-> self.data;
|
||||||
@ -126,7 +126,7 @@ impl<A> DVec<A> {
|
|||||||
* and return a new vector to replace it with.
|
* and return a new vector to replace it with.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[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)))
|
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.
|
* and return a new vector to replace it with.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[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| {
|
do self.swap |v| {
|
||||||
vec::from_mut(f(vec::to_mut(move v)))
|
vec::from_mut(f(vec::to_mut(move v)))
|
||||||
}
|
}
|
||||||
|
@ -827,7 +827,7 @@ mod fsync {
|
|||||||
// FIXME (#2004) find better way to create resources within lifetime of
|
// FIXME (#2004) find better way to create resources within lifetime of
|
||||||
// outer res
|
// outer res
|
||||||
fn FILE_res_sync(&&file: FILERes, opt_level: Option<Level>,
|
fn FILE_res_sync(&&file: FILERes, opt_level: Option<Level>,
|
||||||
blk: fn(&&Res<*libc::FILE>)) {
|
blk: fn(&&v: Res<*libc::FILE>)) {
|
||||||
blk(Res({
|
blk(Res({
|
||||||
val: file.f, opt_level: opt_level,
|
val: file.f, opt_level: opt_level,
|
||||||
fsync_fn: fn@(&&file: *libc::FILE, l: Level) -> int {
|
fsync_fn: fn@(&&file: *libc::FILE, l: Level) -> int {
|
||||||
@ -838,7 +838,7 @@ mod fsync {
|
|||||||
|
|
||||||
// fsync fd after executing blk
|
// fsync fd after executing blk
|
||||||
fn fd_res_sync(&&fd: FdRes, opt_level: Option<Level>,
|
fn fd_res_sync(&&fd: FdRes, opt_level: Option<Level>,
|
||||||
blk: fn(&&Res<fd_t>)) {
|
blk: fn(&&v: Res<fd_t>)) {
|
||||||
blk(Res({
|
blk(Res({
|
||||||
val: fd.fd, opt_level: opt_level,
|
val: fd.fd, opt_level: opt_level,
|
||||||
fsync_fn: fn@(&&fd: fd_t, l: Level) -> int {
|
fsync_fn: fn@(&&fd: fd_t, l: Level) -> int {
|
||||||
@ -852,7 +852,7 @@ mod fsync {
|
|||||||
|
|
||||||
// Call o.fsync after executing blk
|
// Call o.fsync after executing blk
|
||||||
fn obj_sync(&&o: FSyncable, opt_level: Option<Level>,
|
fn obj_sync(&&o: FSyncable, opt_level: Option<Level>,
|
||||||
blk: fn(&&Res<FSyncable>)) {
|
blk: fn(&&v: Res<FSyncable>)) {
|
||||||
blk(Res({
|
blk(Res({
|
||||||
val: o, opt_level: opt_level,
|
val: o, opt_level: opt_level,
|
||||||
fsync_fn: fn@(&&o: FSyncable, l: Level) -> int {
|
fsync_fn: fn@(&&o: FSyncable, l: Level) -> int {
|
||||||
|
@ -63,7 +63,7 @@ trait Buildable<A> {
|
|||||||
* onto the sequence being constructed.
|
* onto the sequence being constructed.
|
||||||
*/
|
*/
|
||||||
static pure fn build_sized(size: uint,
|
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) {
|
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.
|
* onto the sequence being constructed.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[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)
|
build_sized(4, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(+A))) -> B {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn build_sized_opt<A,B: Buildable<A>>(
|
pure fn build_sized_opt<A,B: Buildable<A>>(
|
||||||
size: Option<uint>,
|
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)
|
build_sized(size.get_default(4), builder)
|
||||||
}
|
}
|
||||||
|
@ -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 }
|
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
|
* As `map`, but consumes the option and gives `f` ownership to avoid
|
||||||
* copying.
|
* copying.
|
||||||
@ -107,7 +107,7 @@ pure fn or<T>(+opta: Option<T>, +optb: Option<T>) -> Option<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[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.
|
//! Applies a function zero or more times until the result is none.
|
||||||
|
|
||||||
let mut opt <- x;
|
let mut opt <- x;
|
||||||
@ -248,7 +248,7 @@ impl<T: Copy> Option<T> {
|
|||||||
*/
|
*/
|
||||||
pure fn expect(reason: ~str) -> T { expect(self, reason) }
|
pure fn expect(reason: ~str) -> T { expect(self, reason) }
|
||||||
/// Applies a function zero or more times until the result is none.
|
/// 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)]
|
#[cfg(stage0)]
|
||||||
|
@ -889,7 +889,7 @@ endpoint is passed to the new task.
|
|||||||
fn spawn_service<T: Send, Tb: Send>(
|
fn spawn_service<T: Send, Tb: Send>(
|
||||||
init: extern fn() -> (SendPacketBuffered<T, Tb>,
|
init: extern fn() -> (SendPacketBuffered<T, Tb>,
|
||||||
RecvPacketBuffered<T, Tb>),
|
RecvPacketBuffered<T, Tb>),
|
||||||
+service: fn~(+RecvPacketBuffered<T, Tb>))
|
+service: fn~(+v: RecvPacketBuffered<T, Tb>))
|
||||||
-> SendPacketBuffered<T, Tb>
|
-> SendPacketBuffered<T, Tb>
|
||||||
{
|
{
|
||||||
let (client, server) = init();
|
let (client, server) = init();
|
||||||
@ -913,7 +913,7 @@ receive state.
|
|||||||
fn spawn_service_recv<T: Send, Tb: Send>(
|
fn spawn_service_recv<T: Send, Tb: Send>(
|
||||||
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
|
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
|
||||||
SendPacketBuffered<T, Tb>),
|
SendPacketBuffered<T, Tb>),
|
||||||
+service: fn~(+SendPacketBuffered<T, Tb>))
|
+service: fn~(+v: SendPacketBuffered<T, Tb>))
|
||||||
-> RecvPacketBuffered<T, Tb>
|
-> RecvPacketBuffered<T, Tb>
|
||||||
{
|
{
|
||||||
let (client, server) = init();
|
let (client, server) = init();
|
||||||
|
@ -2109,7 +2109,8 @@ mod raw {
|
|||||||
unsafe fn from_byte(u: u8) -> ~str { raw::from_bytes([u]) }
|
unsafe fn from_byte(u: u8) -> ~str { raw::from_bytes([u]) }
|
||||||
|
|
||||||
/// Form a slice from a *u8 buffer of the given length without copying.
|
/// 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);
|
let v = (buf, len + 1);
|
||||||
assert is_utf8(::cast::reinterpret_cast(&v));
|
assert is_utf8(::cast::reinterpret_cast(&v));
|
||||||
f(::cast::transmute(move v))
|
f(::cast::transmute(move v))
|
||||||
|
@ -338,7 +338,7 @@ type TaskOpts = {
|
|||||||
// FIXME (#2585): Replace the 'consumed' bit with move mode on self
|
// FIXME (#2585): Replace the 'consumed' bit with move mode on self
|
||||||
enum TaskBuilder = {
|
enum TaskBuilder = {
|
||||||
opts: TaskOpts,
|
opts: TaskOpts,
|
||||||
gen_body: fn@(+fn~()) -> fn~(),
|
gen_body: fn@(+v: fn~()) -> fn~(),
|
||||||
can_not_copy: Option<util::NonCopyable>,
|
can_not_copy: Option<util::NonCopyable>,
|
||||||
mut consumed: bool,
|
mut consumed: bool,
|
||||||
};
|
};
|
||||||
@ -466,7 +466,7 @@ impl TaskBuilder {
|
|||||||
* # Failure
|
* # Failure
|
||||||
* Fails if a future_result was already set for this task.
|
* 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
|
// FIXME (#1087, #1857): Once linked failure and notification are
|
||||||
// handled in the library, I can imagine implementing this by just
|
// handled in the library, I can imagine implementing this by just
|
||||||
// registering an arbitrary number of task::on_exit handlers and
|
// 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
|
* generator by applying the task body which results from the
|
||||||
* existing body generator to the new body generator.
|
* 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 prev_gen_body = self.gen_body;
|
||||||
let notify_chan = if self.opts.notify_chan.is_none() {
|
let notify_chan = if self.opts.notify_chan.is_none() {
|
||||||
None
|
None
|
||||||
@ -578,7 +578,7 @@ impl TaskBuilder {
|
|||||||
spawn::spawn_raw(move opts, x.gen_body(move f));
|
spawn::spawn_raw(move opts, x.gen_body(move f));
|
||||||
}
|
}
|
||||||
/// Runs a task, while transfering ownership of one argument to the child.
|
/// 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);
|
let arg = ~mut Some(move arg);
|
||||||
do self.spawn |move arg, move f|{
|
do self.spawn |move arg, move f|{
|
||||||
f(option::swap_unwrap(arg))
|
f(option::swap_unwrap(arg))
|
||||||
@ -705,7 +705,7 @@ fn spawn_supervised(+f: fn~()) {
|
|||||||
task().supervised().spawn(move f)
|
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
|
* Runs a task, while transfering ownership of one argument to the
|
||||||
* child.
|
* child.
|
||||||
@ -1246,7 +1246,7 @@ fn test_spawn_sched_blocking() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[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 p = comm::Port::<uint>();
|
||||||
let ch = comm::Chan(p);
|
let ch = comm::Chan(p);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ use local_data_priv::{
|
|||||||
*
|
*
|
||||||
* These two cases aside, the interface is safe.
|
* 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
|
* Remove a task-local data value from the table, returning the
|
||||||
|
@ -82,7 +82,7 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) {
|
|||||||
let was_present = tasks.remove(&task);
|
let was_present = tasks.remove(&task);
|
||||||
assert was_present;
|
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))
|
tasks.each_key(|k| blk(*k))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,8 @@ pure fn with_capacity<T>(capacity: uint) -> ~[T] {
|
|||||||
* onto the vector being constructed.
|
* onto the vector being constructed.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[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);
|
let mut vec = with_capacity(size);
|
||||||
builder(|+x| unsafe { push(vec, move x) });
|
builder(|+x| unsafe { push(vec, move x) });
|
||||||
move vec
|
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.
|
* onto the vector being constructed.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[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)
|
build_sized(4, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +271,7 @@ pure fn build<A>(builder: fn(push: pure fn(+A))) -> ~[A] {
|
|||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn build_sized_opt<A>(size: Option<uint>,
|
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)
|
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| {
|
do as_imm_buf(v) |p, ln| {
|
||||||
for uint::range(0, ln) |i| {
|
for uint::range(0, ln) |i| {
|
||||||
let x <- *ptr::offset(p, 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);
|
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| {
|
do as_imm_buf(v) |p, ln| {
|
||||||
for uint::range(0, ln) |i| {
|
for uint::range(0, ln) |i| {
|
||||||
let x <- *ptr::offset(p, 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
|
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 = ~[];
|
let mut result = ~[];
|
||||||
do consume(move v) |_i, x| {
|
do consume(move v) |_i, x| {
|
||||||
vec::push(result, f(move x));
|
vec::push(result, f(move x));
|
||||||
@ -1808,7 +1809,7 @@ mod raw {
|
|||||||
* not bytes).
|
* not bytes).
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[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 pair = (p, len * sys::size_of::<T>());
|
||||||
let v : *(&blk/[T]) =
|
let v : *(&blk/[T]) =
|
||||||
::cast::reinterpret_cast(&ptr::addr_of(pair));
|
::cast::reinterpret_cast(&ptr::addr_of(pair));
|
||||||
|
@ -340,7 +340,7 @@ impl<T: Const Send> &RWARC<T> {
|
|||||||
* }
|
* }
|
||||||
* ~~~
|
* ~~~
|
||||||
*/
|
*/
|
||||||
fn write_downgrade<U>(blk: fn(+RWWriteMode<T>) -> U) -> U {
|
fn write_downgrade<U>(blk: fn(+v: RWWriteMode<T>) -> U) -> U {
|
||||||
let state = unsafe { get_shared_mutable_state(&self.x) };
|
let state = unsafe { get_shared_mutable_state(&self.x) };
|
||||||
do borrow_rwlock(state).write_downgrade |write_mode| {
|
do borrow_rwlock(state).write_downgrade |write_mode| {
|
||||||
check_poison(false, state.failed);
|
check_poison(false, state.failed);
|
||||||
|
@ -140,7 +140,7 @@ impl BigBitv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn each_storage(op: fn(&uint) -> bool) {
|
fn each_storage(op: fn(&v: uint) -> bool) {
|
||||||
for uint::range(0, self.storage.len()) |i| {
|
for uint::range(0, self.storage.len()) |i| {
|
||||||
let mut w = self.storage[i];
|
let mut w = self.storage[i];
|
||||||
let b = !op(w);
|
let b = !op(w);
|
||||||
|
@ -33,7 +33,7 @@ trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
|
|||||||
*
|
*
|
||||||
* Returns true if the key did not already exist in the map
|
* Returns true if the key did not already exist in the map
|
||||||
*/
|
*/
|
||||||
fn insert(+K, +V) -> bool;
|
fn insert(+v: K, +v: V) -> bool;
|
||||||
|
|
||||||
/// Returns true if the map contains a value for the specified key
|
/// Returns true if the map contains a value for the specified key
|
||||||
fn contains_key(+key: K) -> bool;
|
fn contains_key(+key: K) -> bool;
|
||||||
|
@ -539,7 +539,7 @@ impl &RWlock {
|
|||||||
* }
|
* }
|
||||||
* ~~~
|
* ~~~
|
||||||
*/
|
*/
|
||||||
fn write_downgrade<U>(blk: fn(+RWlockWriteMode) -> U) -> U {
|
fn write_downgrade<U>(blk: fn(+v: RWlockWriteMode) -> U) -> U {
|
||||||
// Implementation slightly different from the slicker 'write's above.
|
// Implementation slightly different from the slicker 'write's above.
|
||||||
// The exit path is conditional on whether the caller downgrades.
|
// The exit path is conditional on whether the caller downgrades.
|
||||||
let mut _release = None;
|
let mut _release = None;
|
||||||
|
@ -34,7 +34,7 @@ type spanned<T> = {node: T, span: span};
|
|||||||
/* can't import macros yet, so this is copied from token.rs. See its comment
|
/* can't import macros yet, so this is copied from token.rs. See its comment
|
||||||
* there. */
|
* there. */
|
||||||
macro_rules! interner_key (
|
macro_rules! interner_key (
|
||||||
() => (cast::transmute::<(uint, uint), &fn(+@@token::ident_interner)>(
|
() => (cast::transmute::<(uint, uint), &fn(+v: @@token::ident_interner)>(
|
||||||
(-3 as uint, 0u)))
|
(-3 as uint, 0u)))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -351,8 +351,8 @@ fn ser_variant(cx: ext_ctxt,
|
|||||||
span: span,
|
span: span,
|
||||||
-s: @ast::expr,
|
-s: @ast::expr,
|
||||||
pfn: fn(~[@ast::pat]) -> ast::pat_,
|
pfn: fn(~[@ast::pat]) -> ast::pat_,
|
||||||
bodyfn: fn(-@ast::expr, ast::blk) -> @ast::expr,
|
bodyfn: fn(-v: @ast::expr, ast::blk) -> @ast::expr,
|
||||||
argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr)
|
argfn: fn(-v: @ast::expr, uint, ast::blk) -> @ast::expr)
|
||||||
-> ast::arm {
|
-> ast::arm {
|
||||||
let vnames = do vec::from_fn(vec::len(tys)) |i| {
|
let vnames = do vec::from_fn(vec::len(tys)) |i| {
|
||||||
cx.parse_sess().interner.intern(@fmt!("__v%u", i))
|
cx.parse_sess().interner.intern(@fmt!("__v%u", i))
|
||||||
@ -535,7 +535,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
|
|||||||
fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident,
|
fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident,
|
||||||
tps: ~[ast::ty_param],
|
tps: ~[ast::ty_param],
|
||||||
f: fn(ext_ctxt, ser_tps_map,
|
f: fn(ext_ctxt, ser_tps_map,
|
||||||
-@ast::expr, -@ast::expr) -> ~[@ast::stmt])
|
-v: @ast::expr, -v: @ast::expr) -> ~[@ast::stmt])
|
||||||
-> @ast::item {
|
-> @ast::item {
|
||||||
let ext_cx = cx; // required for #ast
|
let ext_cx = cx; // required for #ast
|
||||||
|
|
||||||
@ -747,7 +747,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
|
|||||||
|
|
||||||
fn mk_deser_fn(cx: ext_ctxt, span: span,
|
fn mk_deser_fn(cx: ext_ctxt, span: span,
|
||||||
name: ast::ident, tps: ~[ast::ty_param],
|
name: ast::ident, tps: ~[ast::ty_param],
|
||||||
f: fn(ext_ctxt, deser_tps_map, -@ast::expr) -> @ast::expr)
|
f: fn(ext_ctxt, deser_tps_map, -v: @ast::expr) -> @ast::expr)
|
||||||
-> @ast::item {
|
-> @ast::item {
|
||||||
let ext_cx = cx; // required for #ast
|
let ext_cx = cx; // required for #ast
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
|
|||||||
// When we enter a module, record it, for the sake of `module!`
|
// When we enter a module, record it, for the sake of `module!`
|
||||||
fn expand_item(exts: HashMap<~str, syntax_extension>,
|
fn expand_item(exts: HashMap<~str, syntax_extension>,
|
||||||
cx: ext_ctxt, &&it: @ast::item, fld: ast_fold,
|
cx: ext_ctxt, &&it: @ast::item, fld: ast_fold,
|
||||||
orig: fn@(&&@ast::item, ast_fold) -> Option<@ast::item>)
|
orig: fn@(&&v: @ast::item, ast_fold) -> Option<@ast::item>)
|
||||||
-> Option<@ast::item>
|
-> Option<@ast::item>
|
||||||
{
|
{
|
||||||
let is_mod = match it.node {
|
let is_mod = match it.node {
|
||||||
|
@ -77,9 +77,9 @@ trait ext_ctxt_ast_builder {
|
|||||||
fn item_ty(name: ident, span: span, ty: @ast::ty) -> @ast::item;
|
fn item_ty(name: ident, span: span, ty: @ast::ty) -> @ast::item;
|
||||||
fn ty_vars(+ty_params: ~[ast::ty_param]) -> ~[@ast::ty];
|
fn ty_vars(+ty_params: ~[ast::ty_param]) -> ~[@ast::ty];
|
||||||
fn ty_field_imm(name: ident, ty: @ast::ty) -> ast::ty_field;
|
fn ty_field_imm(name: ident, ty: @ast::ty) -> ast::ty_field;
|
||||||
fn ty_rec(+~[ast::ty_field]) -> @ast::ty;
|
fn ty_rec(+v: ~[ast::ty_field]) -> @ast::ty;
|
||||||
fn field_imm(name: ident, e: @ast::expr) -> ast::field;
|
fn field_imm(name: ident, e: @ast::expr) -> ast::field;
|
||||||
fn rec(+~[ast::field]) -> @ast::expr;
|
fn rec(+v: ~[ast::field]) -> @ast::expr;
|
||||||
fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk;
|
fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk;
|
||||||
fn stmt_let(ident: ident, e: @ast::expr) -> @ast::stmt;
|
fn stmt_let(ident: ident, e: @ast::expr) -> @ast::stmt;
|
||||||
fn stmt_expr(e: @ast::expr) -> @ast::stmt;
|
fn stmt_expr(e: @ast::expr) -> @ast::stmt;
|
||||||
|
@ -20,27 +20,27 @@ export extensions;
|
|||||||
|
|
||||||
trait ast_fold {
|
trait ast_fold {
|
||||||
fn fold_crate(crate) -> crate;
|
fn fold_crate(crate) -> crate;
|
||||||
fn fold_crate_directive(&&@crate_directive) -> @crate_directive;
|
fn fold_crate_directive(&&v: @crate_directive) -> @crate_directive;
|
||||||
fn fold_view_item(&&@view_item) -> @view_item;
|
fn fold_view_item(&&v: @view_item) -> @view_item;
|
||||||
fn fold_foreign_item(&&@foreign_item) -> @foreign_item;
|
fn fold_foreign_item(&&v: @foreign_item) -> @foreign_item;
|
||||||
fn fold_item(&&@item) -> Option<@item>;
|
fn fold_item(&&v: @item) -> Option<@item>;
|
||||||
fn fold_struct_field(&&@struct_field) -> @struct_field;
|
fn fold_struct_field(&&v: @struct_field) -> @struct_field;
|
||||||
fn fold_item_underscore(item_) -> item_;
|
fn fold_item_underscore(item_) -> item_;
|
||||||
fn fold_method(&&@method) -> @method;
|
fn fold_method(&&v: @method) -> @method;
|
||||||
fn fold_block(blk) -> blk;
|
fn fold_block(blk) -> blk;
|
||||||
fn fold_stmt(&&@stmt) -> @stmt;
|
fn fold_stmt(&&v: @stmt) -> @stmt;
|
||||||
fn fold_arm(arm) -> arm;
|
fn fold_arm(arm) -> arm;
|
||||||
fn fold_pat(&&@pat) -> @pat;
|
fn fold_pat(&&v: @pat) -> @pat;
|
||||||
fn fold_decl(&&@decl) -> @decl;
|
fn fold_decl(&&v: @decl) -> @decl;
|
||||||
fn fold_expr(&&@expr) -> @expr;
|
fn fold_expr(&&v: @expr) -> @expr;
|
||||||
fn fold_ty(&&@ty) -> @ty;
|
fn fold_ty(&&v: @ty) -> @ty;
|
||||||
fn fold_mod(_mod) -> _mod;
|
fn fold_mod(_mod) -> _mod;
|
||||||
fn fold_foreign_mod(foreign_mod) -> foreign_mod;
|
fn fold_foreign_mod(foreign_mod) -> foreign_mod;
|
||||||
fn fold_variant(variant) -> variant;
|
fn fold_variant(variant) -> variant;
|
||||||
fn fold_ident(&&ident) -> ident;
|
fn fold_ident(&&v: ident) -> ident;
|
||||||
fn fold_path(&&@path) -> @path;
|
fn fold_path(&&v: @path) -> @path;
|
||||||
fn fold_local(&&@local) -> @local;
|
fn fold_local(&&v: @local) -> @local;
|
||||||
fn map_exprs(fn@(&&@expr) -> @expr, ~[@expr]) -> ~[@expr];
|
fn map_exprs(fn@(&&v: @expr) -> @expr, ~[@expr]) -> ~[@expr];
|
||||||
fn new_id(node_id) -> node_id;
|
fn new_id(node_id) -> node_id;
|
||||||
fn new_span(span) -> span;
|
fn new_span(span) -> span;
|
||||||
}
|
}
|
||||||
@ -53,11 +53,11 @@ type ast_fold_precursor = @{
|
|||||||
fold_crate_directive: fn@(crate_directive_, span,
|
fold_crate_directive: fn@(crate_directive_, span,
|
||||||
ast_fold) -> (crate_directive_, span),
|
ast_fold) -> (crate_directive_, span),
|
||||||
fold_view_item: fn@(view_item_, ast_fold) -> view_item_,
|
fold_view_item: fn@(view_item_, ast_fold) -> view_item_,
|
||||||
fold_foreign_item: fn@(&&@foreign_item, ast_fold) -> @foreign_item,
|
fold_foreign_item: fn@(&&v: @foreign_item, ast_fold) -> @foreign_item,
|
||||||
fold_item: fn@(&&@item, ast_fold) -> Option<@item>,
|
fold_item: fn@(&&v: @item, ast_fold) -> Option<@item>,
|
||||||
fold_struct_field: fn@(&&@struct_field, ast_fold) -> @struct_field,
|
fold_struct_field: fn@(&&v: @struct_field, ast_fold) -> @struct_field,
|
||||||
fold_item_underscore: fn@(item_, ast_fold) -> item_,
|
fold_item_underscore: fn@(item_, ast_fold) -> item_,
|
||||||
fold_method: fn@(&&@method, ast_fold) -> @method,
|
fold_method: fn@(&&v: @method, ast_fold) -> @method,
|
||||||
fold_block: fn@(blk_, span, ast_fold) -> (blk_, span),
|
fold_block: fn@(blk_, span, ast_fold) -> (blk_, span),
|
||||||
fold_stmt: fn@(stmt_, span, ast_fold) -> (stmt_, span),
|
fold_stmt: fn@(stmt_, span, ast_fold) -> (stmt_, span),
|
||||||
fold_arm: fn@(arm, ast_fold) -> arm,
|
fold_arm: fn@(arm, ast_fold) -> arm,
|
||||||
@ -68,10 +68,10 @@ type ast_fold_precursor = @{
|
|||||||
fold_mod: fn@(_mod, ast_fold) -> _mod,
|
fold_mod: fn@(_mod, ast_fold) -> _mod,
|
||||||
fold_foreign_mod: fn@(foreign_mod, ast_fold) -> foreign_mod,
|
fold_foreign_mod: fn@(foreign_mod, ast_fold) -> foreign_mod,
|
||||||
fold_variant: fn@(variant_, span, ast_fold) -> (variant_, span),
|
fold_variant: fn@(variant_, span, ast_fold) -> (variant_, span),
|
||||||
fold_ident: fn@(&&ident, ast_fold) -> ident,
|
fold_ident: fn@(&&v: ident, ast_fold) -> ident,
|
||||||
fold_path: fn@(path, ast_fold) -> path,
|
fold_path: fn@(path, ast_fold) -> path,
|
||||||
fold_local: fn@(local_, span, ast_fold) -> (local_, span),
|
fold_local: fn@(local_, span, ast_fold) -> (local_, span),
|
||||||
map_exprs: fn@(fn@(&&@expr) -> @expr, ~[@expr]) -> ~[@expr],
|
map_exprs: fn@(fn@(&&v: @expr) -> @expr, ~[@expr]) -> ~[@expr],
|
||||||
new_id: fn@(node_id) -> node_id,
|
new_id: fn@(node_id) -> node_id,
|
||||||
new_span: fn@(span) -> span};
|
new_span: fn@(span) -> span};
|
||||||
|
|
||||||
@ -643,7 +643,7 @@ fn noop_fold_local(l: local_, fld: ast_fold) -> local_ {
|
|||||||
|
|
||||||
/* temporarily eta-expand because of a compiler bug with using `fn<T>` as a
|
/* temporarily eta-expand because of a compiler bug with using `fn<T>` as a
|
||||||
value */
|
value */
|
||||||
fn noop_map_exprs(f: fn@(&&@expr) -> @expr, es: ~[@expr]) -> ~[@expr] {
|
fn noop_map_exprs(f: fn@(&&v: @expr) -> @expr, es: ~[@expr]) -> ~[@expr] {
|
||||||
return vec::map(es, |x| f(*x));
|
return vec::map(es, |x| f(*x));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,7 +773,7 @@ impl ast_fold_precursor: ast_fold {
|
|||||||
let (n, s) = self.fold_local(x.node, x.span, self as ast_fold);
|
let (n, s) = self.fold_local(x.node, x.span, self as ast_fold);
|
||||||
return @{node: n, span: self.new_span(s)};
|
return @{node: n, span: self.new_span(s)};
|
||||||
}
|
}
|
||||||
fn map_exprs(f: fn@(&&@expr) -> @expr, e: ~[@expr]) -> ~[@expr] {
|
fn map_exprs(f: fn@(&&v: @expr) -> @expr, e: ~[@expr]) -> ~[@expr] {
|
||||||
self.map_exprs(f, e)
|
self.map_exprs(f, e)
|
||||||
}
|
}
|
||||||
fn new_id(node_id: ast::node_id) -> node_id {
|
fn new_id(node_id: ast::node_id) -> node_id {
|
||||||
|
@ -21,7 +21,8 @@ pub enum ObsoleteSyntax {
|
|||||||
ObsoleteWith,
|
ObsoleteWith,
|
||||||
ObsoleteClassMethod,
|
ObsoleteClassMethod,
|
||||||
ObsoleteClassTraits,
|
ObsoleteClassTraits,
|
||||||
ObsoletePrivSection
|
ObsoletePrivSection,
|
||||||
|
ObsoleteModeInFnType
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(stage0)]
|
#[cfg(stage0)]
|
||||||
@ -99,6 +100,11 @@ impl parser : ObsoleteReporter {
|
|||||||
"the `priv` keyword is applied to individual items, methods, \
|
"the `priv` keyword is applied to individual items, methods, \
|
||||||
and fields"
|
and fields"
|
||||||
),
|
),
|
||||||
|
ObsoleteModeInFnType => (
|
||||||
|
"mode without identifier in fn type",
|
||||||
|
"to use a (deprecated) mode in a fn type, you should \
|
||||||
|
give the argument an explicit name (like `&&v: int`)"
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report(sp, kind, kind_str, desc);
|
self.report(sp, kind, kind_str, desc);
|
||||||
|
@ -19,7 +19,8 @@ use obsolete::{
|
|||||||
ObsoleteReporter, ObsoleteSyntax,
|
ObsoleteReporter, ObsoleteSyntax,
|
||||||
ObsoleteLowerCaseKindBounds, ObsoleteLet,
|
ObsoleteLowerCaseKindBounds, ObsoleteLet,
|
||||||
ObsoleteFieldTerminator, ObsoleteStructCtor,
|
ObsoleteFieldTerminator, ObsoleteStructCtor,
|
||||||
ObsoleteWith, ObsoleteClassMethod, ObsoleteClassTraits
|
ObsoleteWith, ObsoleteClassMethod, ObsoleteClassTraits,
|
||||||
|
ObsoleteModeInFnType
|
||||||
};
|
};
|
||||||
use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
|
use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
|
||||||
bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move,
|
bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move,
|
||||||
@ -618,6 +619,15 @@ impl parser {
|
|||||||
} else { special_idents::invalid }
|
} else { special_idents::invalid }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
match m {
|
||||||
|
expl(_) => {
|
||||||
|
if i == special_idents::invalid {
|
||||||
|
self.obsolete(copy self.span, ObsoleteModeInFnType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
let t = self.parse_ty(false);
|
let t = self.parse_ty(false);
|
||||||
|
|
||||||
{mode: m, ty: t, ident: i, id: self.get_id()}
|
{mode: m, ty: t, ident: i, id: self.get_id()}
|
||||||
@ -1585,7 +1595,7 @@ impl parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn parse_sugary_call_expr(keyword: ~str,
|
fn parse_sugary_call_expr(keyword: ~str,
|
||||||
ctor: fn(+@expr) -> expr_) -> @expr {
|
ctor: fn(+v: @expr) -> expr_) -> @expr {
|
||||||
let lo = self.last_span;
|
let lo = self.last_span;
|
||||||
// Parse the callee `foo` in
|
// Parse the callee `foo` in
|
||||||
// for foo || {
|
// for foo || {
|
||||||
@ -2400,7 +2410,7 @@ impl parser {
|
|||||||
fn(parser) -> arg_or_capture_item)
|
fn(parser) -> arg_or_capture_item)
|
||||||
-> (self_ty, fn_decl, capture_clause) {
|
-> (self_ty, fn_decl, capture_clause) {
|
||||||
|
|
||||||
fn maybe_parse_self_ty(cnstr: fn(+mutability) -> ast::self_ty_,
|
fn maybe_parse_self_ty(cnstr: fn(+v: mutability) -> ast::self_ty_,
|
||||||
p: parser) -> ast::self_ty_ {
|
p: parser) -> ast::self_ty_ {
|
||||||
// We need to make sure it isn't a mode or a type
|
// We need to make sure it isn't a mode or a type
|
||||||
if p.token_is_keyword(~"self", p.look_ahead(1)) ||
|
if p.token_is_keyword(~"self", p.look_ahead(1)) ||
|
||||||
|
@ -65,7 +65,7 @@ macro_rules! follow (
|
|||||||
)
|
)
|
||||||
|
|
||||||
fn switch<T: Send, Tb: Send, U>(+endp: pipes::RecvPacketBuffered<T, Tb>,
|
fn switch<T: Send, Tb: Send, U>(+endp: pipes::RecvPacketBuffered<T, Tb>,
|
||||||
f: fn(+Option<T>) -> U) -> U {
|
f: fn(+v: Option<T>) -> U) -> U {
|
||||||
f(pipes::try_recv(endp))
|
f(pipes::try_recv(endp))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ fn reduce(&&word: ~str, get: map_reduce::getter<int>) {
|
|||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
|
||||||
loop { match get() { Some(_) => { count += 1; } None => { break; } } }
|
loop { match get() { Some(_) => { count += 1; } None => { break; } } }
|
||||||
|
|
||||||
io::println(fmt!("%s\t%?", word, count));
|
io::println(fmt!("%s\t%?", word, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ struct box<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T> box<T> {
|
impl<T> box<T> {
|
||||||
fn swap(f: fn(+T) -> T) {
|
fn swap(f: fn(+v: T) -> T) {
|
||||||
let mut tmp = None;
|
let mut tmp = None;
|
||||||
self.contents <-> tmp;
|
self.contents <-> tmp;
|
||||||
self.contents = Some(f(option::unwrap(tmp)));
|
self.contents = Some(f(option::unwrap(tmp)));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// error-pattern: mismatched types
|
// error-pattern: mismatched types
|
||||||
|
|
||||||
fn f(&&_x: int) {}
|
fn f(&&_x: int) {}
|
||||||
fn g(_a: fn(+int)) {}
|
fn g(_a: fn(+v: int)) {}
|
||||||
fn main() { g(f); }
|
fn main() { g(f); }
|
||||||
|
@ -4,7 +4,7 @@ mod stream {
|
|||||||
mod server {
|
mod server {
|
||||||
#[legacy_exports];
|
#[legacy_exports];
|
||||||
impl<T: Send> stream<T> {
|
impl<T: Send> stream<T> {
|
||||||
fn recv() -> extern fn(+stream<T>) -> stream::stream<T> {
|
fn recv() -> extern fn(+v: stream<T>) -> stream::stream<T> {
|
||||||
// resolve really should report just one error here.
|
// resolve really should report just one error here.
|
||||||
// Change the test case when it changes.
|
// Change the test case when it changes.
|
||||||
fn recv(+pipe: stream<T>) -> stream::stream<T> { //~ ERROR attempt to use a type argument out of scope
|
fn recv(+pipe: stream<T>) -> stream::stream<T> { //~ ERROR attempt to use a type argument out of scope
|
||||||
|
@ -70,7 +70,7 @@ impl<T: Copy> cat<T> : Map<int, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn each(f: fn(+int, +T) -> bool) {
|
pure fn each(f: fn(+v: int, +v: T) -> bool) {
|
||||||
let mut n = int::abs(self.meows);
|
let mut n = int::abs(self.meows);
|
||||||
while n > 0 {
|
while n > 0 {
|
||||||
if !f(n, self.name) { break; }
|
if !f(n, self.name) { break; }
|
||||||
@ -78,10 +78,10 @@ impl<T: Copy> cat<T> : Map<int, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn each_key(&&f: fn(+int) -> bool) {
|
pure fn each_key(&&f: fn(+v: int) -> bool) {
|
||||||
for self.each |k, _v| { if !f(k) { break; } loop;};
|
for self.each |k, _v| { if !f(k) { break; } loop;};
|
||||||
}
|
}
|
||||||
pure fn each_value(&&f: fn(+T) -> bool) {
|
pure fn each_value(&&f: fn(+v: T) -> bool) {
|
||||||
for self.each |_k, v| { if !f(v) { break; } loop;};
|
for self.each |_k, v| { if !f(v) { break; } loop;};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ fn fix<A, B>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
|
|||||||
return {|a|fix_help(f, a)};
|
return {|a|fix_help(f, a)};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fact_(f: fn@(&&int) -> int, &&n: int) -> int {
|
fn fact_(f: fn@(&&v: int) -> int, &&n: int) -> int {
|
||||||
// fun fact 0 = 1
|
// fun fact 0 = 1
|
||||||
return if n == 0 { 1 } else { n * f(n - 1) };
|
return if n == 0 { 1 } else { n * f(n - 1) };
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ fn fix<A: Owned, B: Send>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
|
|||||||
return {|a|fix_help(f, a)};
|
return {|a|fix_help(f, a)};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fact_(f: fn@(&&int) -> int, &&n: int) -> int {
|
fn fact_(f: fn@(&&v: int) -> int, &&n: int) -> int {
|
||||||
// fun fact 0 = 1
|
// fun fact 0 = 1
|
||||||
return if n == 0 { 1 } else { n * f(n - 1) };
|
return if n == 0 { 1 } else { n * f(n - 1) };
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ fn f(i: int, &called: bool) {
|
|||||||
called = true;
|
called = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn g(f: extern fn(int, &bool), &called: bool) {
|
fn g(f: extern fn(int, &v: bool), &called: bool) {
|
||||||
f(10, called);
|
f(10, called);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,6 @@ fn apply<T>(produce: extern fn() -> T,
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let produce: extern fn() -> int = mk;
|
let produce: extern fn() -> int = mk;
|
||||||
let consume: extern fn(&&int) = chk;
|
let consume: extern fn(&&v: int) = chk;
|
||||||
apply::<int>(produce, consume);
|
apply::<int>(produce, consume);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ impl<A> fn@(fn(A)): iterable<A> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fn@(fn(uint)): iterable<uint> {
|
impl fn@(fn(uint)): iterable<uint> {
|
||||||
fn iter(blk: fn(&&uint)) { self( |i| blk(i) ) }
|
fn iter(blk: fn(&&v: uint)) { self( |i| blk(i) ) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn filter<A,IA:iterable<A>>(self: IA, prd: fn@(A) -> bool, blk: fn(A)) {
|
fn filter<A,IA:iterable<A>>(self: IA, prd: fn@(A) -> bool, blk: fn(A)) {
|
||||||
@ -41,7 +41,7 @@ fn range(lo: uint, hi: uint, it: fn(uint)) {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let range: fn@(fn&(uint)) = |a| range(0u, 1000u, a);
|
let range: fn@(fn&(uint)) = |a| range(0u, 1000u, a);
|
||||||
let filt: fn@(fn&(&&uint)) = |a| filter(
|
let filt: fn@(fn&(&&v: uint)) = |a| filter(
|
||||||
range,
|
range,
|
||||||
|&&n: uint| n % 3u != 0u && n % 5u != 0u,
|
|&&n: uint| n % 3u != 0u && n % 5u != 0u,
|
||||||
a);
|
a);
|
||||||
|
@ -37,7 +37,7 @@ macro_rules! move_it (
|
|||||||
)
|
)
|
||||||
|
|
||||||
fn switch<T: Send, U>(+endp: pipes::RecvPacket<T>,
|
fn switch<T: Send, U>(+endp: pipes::RecvPacket<T>,
|
||||||
f: fn(+Option<T>) -> U) -> U {
|
f: fn(+v: Option<T>) -> U) -> U {
|
||||||
f(pipes::try_recv(endp))
|
f(pipes::try_recv(endp))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ fn make_generic_record<A: Copy, B: Copy>(a: A, b: B) -> pair<A,B> {
|
|||||||
return {a: a, b: b};
|
return {a: a, b: b};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test05_start(&&f: fn~(&&float, &&~str) -> pair<float, ~str>) {
|
fn test05_start(&&f: fn~(&&v: float, &&v: ~str) -> pair<float, ~str>) {
|
||||||
let p = f(22.22f, ~"Hi");
|
let p = f(22.22f, ~"Hi");
|
||||||
log(debug, p);
|
log(debug, p);
|
||||||
assert p.a == 22.22f;
|
assert p.a == 22.22f;
|
||||||
|
@ -26,27 +26,27 @@ impl int: bool_like {
|
|||||||
// A trait for sequences that can be constructed imperatively.
|
// A trait for sequences that can be constructed imperatively.
|
||||||
trait buildable<A> {
|
trait buildable<A> {
|
||||||
static pure fn build_sized(size: uint,
|
static pure fn build_sized(size: uint,
|
||||||
builder: fn(push: pure fn(+A))) -> self;
|
builder: fn(push: pure fn(+v: A))) -> self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<A> @[A]: buildable<A> {
|
impl<A> @[A]: buildable<A> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
static pure fn build_sized(size: uint,
|
static pure fn build_sized(size: uint,
|
||||||
builder: fn(push: pure fn(+A))) -> @[A] {
|
builder: fn(push: pure fn(+v: A))) -> @[A] {
|
||||||
at_vec::build_sized(size, builder)
|
at_vec::build_sized(size, builder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<A> ~[A]: buildable<A> {
|
impl<A> ~[A]: buildable<A> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
static pure fn build_sized(size: uint,
|
static pure fn build_sized(size: uint,
|
||||||
builder: fn(push: pure fn(+A))) -> ~[A] {
|
builder: fn(push: pure fn(+v: A))) -> ~[A] {
|
||||||
vec::build_sized(size, builder)
|
vec::build_sized(size, builder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[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)
|
build_sized(4, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user