diff --git a/doc/rust.md b/doc/rust.md index 8924ee6f4f60c..e559af62e360c 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -889,10 +889,10 @@ declared, in an angle-bracket-enclosed, comma-separated list following the function name. ~~~~ {.xfail-test} -fn iter(seq: &[T], f: fn(T)) { +fn iter(seq: &[T], f: &fn(T)) { for seq.each |elt| { f(elt); } } -fn map(seq: &[T], f: fn(T) -> U) -> ~[U] { +fn map(seq: &[T], f: &fn(T) -> U) -> ~[U] { let mut acc = ~[]; for seq.each |elt| { acc.push(f(elt)); } acc @@ -1198,7 +1198,7 @@ These appear after the trait name, using the same syntax used in [generic functi trait Seq { fn len() -> uint; fn elt_at(n: uint) -> T; - fn iter(fn(T)); + fn iter(&fn(T)); } ~~~~ @@ -2074,7 +2074,7 @@ and moving values from the environment into the lambda expression's captured env An example of a lambda expression: ~~~~ -fn ten_times(f: fn(int)) { +fn ten_times(f: &fn(int)) { let mut i = 0; while i < 10 { f(i); @@ -2177,7 +2177,7 @@ If the `expr` is a [field expression](#field-expressions), it is parsed as thoug In this example, both calls to `f` are equivalent: ~~~~ -# fn f(f: fn(int)) { } +# fn f(f: &fn(int)) { } # fn g(i: int) { } f(|j| g(j)); @@ -2755,7 +2755,7 @@ and the cast expression in `main`. Within the body of an item that has type parameter declarations, the names of its type parameters are types: ~~~~~~~ -fn map(f: fn(A) -> B, xs: &[A]) -> ~[B] { +fn map(f: &fn(A) -> B, xs: &[A]) -> ~[B] { if xs.len() == 0 { return ~[]; } let first: B = f(xs[0]); let rest: ~[B] = map(f, xs.slice(1, xs.len())); diff --git a/doc/tutorial.md b/doc/tutorial.md index 79553d5aa6ed0..e4775e1b11b4d 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -681,45 +681,6 @@ the value of `North` is 0, `East` is 1, `South` is 2, and `West` is 3. When an enum is C-like, you can apply the `as` cast operator to convert it to its discriminator value as an `int`. - - -There is a special case for enums with a single variant, which are -sometimes called "newtype-style enums" (after Haskell's "newtype" -feature). These are used to define new types in such a way that the -new name is not just a synonym for an existing type, but its own -distinct type: `type` creates a structural synonym, while this form of -`enum` creates a nominal synonym. If you say: - -~~~~ -enum GizmoId = int; -~~~~ - -That is a shorthand for this: - -~~~~ -enum GizmoId { GizmoId(int) } -~~~~ - -You can extract the contents of such an enum type with the -dereference (`*`) unary operator: - -~~~~ -# enum GizmoId = int; -let my_gizmo_id: GizmoId = GizmoId(10); -let id_int: int = *my_gizmo_id; -~~~~ - -Types like this can be useful to differentiate between data that have -the same type but must be used in different ways. - -~~~~ -enum Inches = int; -enum Centimeters = int; -~~~~ - -The above definitions allow for a simple way for programs to avoid -confusing numbers that correspond to different units. - For enum types with multiple variants, destructuring is the only way to get at their contents. All variant constructors can be used as patterns, as in this definition of `area`: @@ -789,10 +750,10 @@ match mytup { ## Tuple structs -Rust also has _nominal tuples_, which behave like both structs and tuples, -except that nominal tuple types have names -(so `Foo(1, 2)` has a different type from `Bar(1, 2)`), -and nominal tuple types' _fields_ do not have names. +Rust also has _tuple structs_, which behave like both structs and tuples, +except that, unlike tuples, tuple structs have names (so `Foo(1, 2)` has a +different type from `Bar(1, 2)`), and tuple structs' _fields_ do not have +names. For example: ~~~~ @@ -803,6 +764,37 @@ match mytup { } ~~~~ + + +There is a special case for tuple structs with a single field, which are +sometimes called "newtypes" (after Haskell's "newtype" feature). These are +used to define new types in such a way that the new name is not just a +synonym for an existing type but is rather its own distinct type. + +~~~~ +struct GizmoId(int); +~~~~ + +For convenience, you can extract the contents of such a struct with the +dereference (`*`) unary operator: + +~~~~ +# struct GizmoId(int); +let my_gizmo_id: GizmoId = GizmoId(10); +let id_int: int = *my_gizmo_id; +~~~~ + +Types like this can be useful to differentiate between data that have +the same type but must be used in different ways. + +~~~~ +struct Inches(int); +struct Centimeters(int); +~~~~ + +The above definitions allow for a simple way for programs to avoid +confusing numbers that correspond to different units. + # Functions We've already seen several function definitions. Like all other static @@ -1369,7 +1361,7 @@ the enclosing scope. ~~~~ # use println = core::io::println; -fn call_closure_with_ten(b: fn(int)) { b(10); } +fn call_closure_with_ten(b: &fn(int)) { b(10); } let captured_var = 20; let closure = |arg| println(fmt!("captured_var=%d, arg=%d", captured_var, arg)); @@ -1455,7 +1447,7 @@ should almost always declare the type of that argument as `fn()`. That way, callers may pass any kind of closure. ~~~~ -fn call_twice(f: fn()) { f(); f(); } +fn call_twice(f: &fn()) { f(); f(); } let closure = || { "I'm a closure, and it doesn't matter what type I am"; }; fn function() { "I'm a normal function"; } call_twice(closure); @@ -1475,7 +1467,7 @@ Consider this function that iterates over a vector of integers, passing in a pointer to each integer in the vector: ~~~~ -fn each(v: &[int], op: fn(v: &int)) { +fn each(v: &[int], op: &fn(v: &int)) { let mut n = 0; while n < v.len() { op(&v[n]); @@ -1496,7 +1488,7 @@ argument, we can write it in a way that has a pleasant, block-like structure. ~~~~ -# fn each(v: &[int], op: fn(v: &int)) { } +# fn each(v: &[int], op: &fn(v: &int)) { } # fn do_some_work(i: &int) { } each([1, 2, 3], |n| { do_some_work(n); @@ -1507,7 +1499,7 @@ This is such a useful pattern that Rust has a special form of function call that can be written more like a built-in control structure: ~~~~ -# fn each(v: &[int], op: fn(v: &int)) { } +# fn each(v: &[int], op: &fn(v: &int)) { } # fn do_some_work(i: &int) { } do each([1, 2, 3]) |n| { do_some_work(n); @@ -1554,7 +1546,7 @@ Consider again our `each` function, this time improved to break early when the iteratee returns `false`: ~~~~ -fn each(v: &[int], op: fn(v: &int) -> bool) { +fn each(v: &[int], op: &fn(v: &int) -> bool) { let mut n = 0; while n < v.len() { if !op(&v[n]) { @@ -1778,7 +1770,7 @@ vector consisting of the result of applying `function` to each element of `vector`: ~~~~ -fn map(vector: &[T], function: fn(v: &T) -> U) -> ~[U] { +fn map(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] { let mut accumulator = ~[]; for vec::each(vector) |element| { accumulator.push(function(element)); @@ -1977,12 +1969,12 @@ types might look like the following: ~~~~ trait Seq { fn len(&self) -> uint; - fn iter(&self, b: fn(v: &T)); + fn iter(&self, b: &fn(v: &T)); } impl Seq for ~[T] { fn len(&self) -> uint { vec::len(*self) } - fn iter(&self, b: fn(v: &T)) { + fn iter(&self, b: &fn(v: &T)) { for vec::each(*self) |elt| { b(elt); } } } @@ -2294,7 +2286,7 @@ struct level. Note that fields and methods are _public_ by default. pub mod farm { # pub type Chicken = int; # type Cow = int; -# enum Human = int; +# struct Human(int); # impl Human { fn rest(&self) { } } # pub fn make_me_a_farm() -> Farm { Farm { chickens: ~[], cows: ~[], farmer: Human(0) } } pub struct Farm { diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index daa3036687c44..7d0a4d7dcc805 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -103,7 +103,7 @@ pub fn is_test_ignored(config: config, testfile: &Path) -> bool { } } -fn iter_header(testfile: &Path, it: fn(~str) -> bool) -> bool { +fn iter_header(testfile: &Path, it: &fn(~str) -> bool) -> bool { let rdr = io::file_reader(testfile).get(); while !rdr.eof() { let ln = rdr.read_line(); diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index e0db543250d66..f95a530831b93 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -530,7 +530,7 @@ fn compose_and_run(config: config, testfile: &Path, } fn make_compile_args(config: config, props: TestProps, extras: ~[~str], - xform: fn(config, (&Path)) -> Path, + xform: &fn(config, (&Path)) -> Path, testfile: &Path) -> ProcArgs { let prog = config.rustc_path; let mut args = ~[testfile.to_str(), diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 7a2a15a5421dc..fa19e24aa0830 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -61,7 +61,7 @@ pub pure fn capacity(v: @[const T]) -> uint { */ #[inline(always)] pub pure fn build_sized(size: uint, - builder: &fn(push: pure fn(v: A))) -> @[A] { + builder: &fn(push: &pure fn(v: A))) -> @[A] { let mut vec: @[const A] = @[]; unsafe { raw::reserve(&mut vec, size); } builder(|+x| unsafe { raw::push(&mut vec, x) }); @@ -79,7 +79,7 @@ pub pure fn build_sized(size: uint, * onto the vector being constructed. */ #[inline(always)] -pub pure fn build(builder: &fn(push: pure fn(v: A))) -> @[A] { +pub pure fn build(builder: &fn(push: &pure fn(v: A))) -> @[A] { build_sized(4, builder) } @@ -97,7 +97,7 @@ pub pure fn build(builder: &fn(push: pure fn(v: A))) -> @[A] { */ #[inline(always)] pub pure fn build_sized_opt(size: Option, - builder: &fn(push: pure fn(v: A))) -> @[A] { + builder: &fn(push: &pure fn(v: A))) -> @[A] { build_sized(size.get_or_default(4), builder) } diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 13b8d0fc907fd..512855d8f86c0 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -67,7 +67,7 @@ pub pure fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } } * Iterates over all truth values by passing them to `blk` in an unspecified * order */ -pub fn all_values(blk: fn(v: bool)) { +pub fn all_values(blk: &fn(v: bool)) { blk(true); blk(false); } diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 8df0037b2afe3..91a4ded60efd6 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -54,7 +54,7 @@ pub impl Cell { } // Calls a closure with a reference to the value. - fn with_ref(&self, op: fn(v: &T) -> R) -> R { + fn with_ref(&self, op: &fn(v: &T) -> R) -> R { let v = self.take(); let r = op(&v); self.put_back(v); diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs index bf1ea5f1150a7..faa6db45df2f6 100644 --- a/src/libcore/cleanup.rs +++ b/src/libcore/cleanup.rs @@ -124,7 +124,7 @@ struct AnnihilateStats { n_bytes_freed: uint } -unsafe fn each_live_alloc(f: fn(box: *mut BoxRepr, uniq: bool) -> bool) { +unsafe fn each_live_alloc(f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) { use managed; let task: *Task = transmute(rustrt::rust_get_task()); diff --git a/src/libcore/container.rs b/src/libcore/container.rs index 36424d1bfaaa3..4f1f6004aad77 100644 --- a/src/libcore/container.rs +++ b/src/libcore/container.rs @@ -30,10 +30,10 @@ pub trait Map: Mutable { pure fn contains_key(&self, key: &K) -> bool; /// Visit all keys - pure fn each_key(&self, f: fn(&K) -> bool); + pure fn each_key(&self, f: &fn(&K) -> bool); /// Visit all values - pure fn each_value(&self, f: fn(&V) -> bool); + pure fn each_value(&self, f: &fn(&V) -> bool); /// Return the value corresponding to the key in the map pure fn find(&self, key: &K) -> Option<&self/V>; @@ -71,14 +71,14 @@ pub trait Set: Mutable { pure fn is_superset(&self, other: &Self) -> bool; /// Visit the values representing the difference - pure fn difference(&self, other: &Self, f: fn(&T) -> bool); + pure fn difference(&self, other: &Self, f: &fn(&T) -> bool); /// Visit the values representing the symmetric difference - pure fn symmetric_difference(&self, other: &Self, f: fn(&T) -> bool); + pure fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool); /// Visit the values representing the intersection - pure fn intersection(&self, other: &Self, f: fn(&T) -> bool); + pure fn intersection(&self, other: &Self, f: &fn(&T) -> bool); /// Visit the values representing the union - pure fn union(&self, other: &Self, f: fn(&T) -> bool); + pure fn union(&self, other: &Self, f: &fn(&T) -> bool); } diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 4d686c8ab33a1..db1dc1e28aa92 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -52,6 +52,7 @@ Implicitly, all crates behave as if they included the following prologue: #[deny(non_camel_case_types)]; #[allow(deprecated_mutable_fields)]; #[deny(deprecated_self)]; +#[allow(deprecated_drop)]; // On Linux, link to the runtime with -lrt. #[cfg(target_os = "linux")] diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 9cb872a0542a1..1b5d03d9eb8cd 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -399,7 +399,7 @@ pub impl DList { } /// Iterate over nodes. - pure fn each_node(@mut self, f: fn(@mut DListNode) -> bool) { + pure fn each_node(@mut self, f: &fn(@mut DListNode) -> bool) { let mut link = self.peek_n(); while link.is_some() { let nobe = link.get(); @@ -507,7 +507,7 @@ impl BaseIter for @mut DList { * allow for e.g. breadth-first search with in-place enqueues), but * removing the current node is forbidden. */ - pure fn each(&self, f: fn(v: &T) -> bool) { + pure fn each(&self, f: &fn(v: &T) -> bool) { let mut link = self.peek_n(); while option::is_some(&link) { let nobe = option::get(link); diff --git a/src/libcore/either.rs b/src/libcore/either.rs index e26f94261f9f9..e4b7bbbd99e87 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -24,8 +24,8 @@ pub enum Either { } #[inline(always)] -pub fn either(f_left: fn(&T) -> V, - f_right: fn(&U) -> V, value: &Either) -> V { +pub fn either(f_left: &fn(&T) -> V, + f_right: &fn(&U) -> V, value: &Either) -> V { /*! * Applies a function based on the given either value * @@ -148,7 +148,7 @@ pub pure fn unwrap_right(eith: Either) -> U { pub impl Either { #[inline(always)] - fn either(&self, f_left: fn(&T) -> V, f_right: fn(&U) -> V) -> V { + fn either(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V { either(f_left, f_right, self) } diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 783f96d9b9e81..2adcee495a738 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -86,7 +86,7 @@ pub mod linear { #[inline(always)] pure fn bucket_sequence(&self, hash: uint, - op: fn(uint) -> bool) -> uint { + op: &fn(uint) -> bool) -> uint { let start_idx = self.to_bucket(hash); let len_buckets = self.buckets.len(); let mut idx = start_idx; @@ -263,7 +263,7 @@ pub mod linear { } fn search(&self, hash: uint, - op: fn(x: &Option>) -> bool) { + op: &fn(x: &Option>) -> bool) { let _ = self.bucket_sequence(hash, |i| op(&self.buckets[i])); } } @@ -272,7 +272,7 @@ pub mod linear { BaseIter<(&self/K, &self/V)> for LinearMap { /// Visit all key-value pairs - pure fn each(&self, blk: fn(&(&self/K, &self/V)) -> bool) { + pure fn each(&self, blk: &fn(&(&self/K, &self/V)) -> bool) { for uint::range(0, self.buckets.len()) |i| { let mut broke = false; do self.buckets[i].map |bucket| { @@ -315,12 +315,12 @@ pub mod linear { } /// Visit all keys - pure fn each_key(&self, blk: fn(k: &K) -> bool) { + pure fn each_key(&self, blk: &fn(k: &K) -> bool) { self.each(|&(k, _)| blk(k)) } /// Visit all values - pure fn each_value(&self, blk: fn(v: &V) -> bool) { + pure fn each_value(&self, blk: &fn(v: &V) -> bool) { self.each(|&(_, v)| blk(v)) } @@ -428,7 +428,7 @@ pub mod linear { /// Return the value corresponding to the key in the map, or create, /// insert, and return a new value if it doesn't exist. - fn find_or_insert_with(&mut self, k: K, f: fn(&K) -> V) -> &self/V { + fn find_or_insert_with(&mut self, k: K, f: &fn(&K) -> V) -> &self/V { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so // that we do not resize if this call to insert is @@ -457,7 +457,7 @@ pub mod linear { } } - fn consume(&mut self, f: fn(K, V)) { + fn consume(&mut self, f: &fn(K, V)) { let mut buckets = ~[]; self.buckets <-> buckets; self.size = 0; @@ -526,7 +526,7 @@ pub mod linear { impl BaseIter for LinearSet { /// Visit all values in order - pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) } + pure fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) } pure fn size_hint(&self) -> Option { Some(self.len()) } } @@ -583,7 +583,7 @@ pub mod linear { } /// Visit the values representing the difference - pure fn difference(&self, other: &LinearSet, f: fn(&T) -> bool) { + pure fn difference(&self, other: &LinearSet, f: &fn(&T) -> bool) { for self.each |v| { if !other.contains(v) { if !f(v) { return } @@ -593,13 +593,15 @@ pub mod linear { /// Visit the values representing the symmetric difference pure fn symmetric_difference(&self, other: &LinearSet, - f: fn(&T) -> bool) { + f: &fn(&T) -> bool) { self.difference(other, f); other.difference(self, f); } /// Visit the values representing the intersection - pure fn intersection(&self, other: &LinearSet, f: fn(&T) -> bool) { + pure fn intersection(&self, + other: &LinearSet, + f: &fn(&T) -> bool) { for self.each |v| { if other.contains(v) { if !f(v) { return } @@ -608,7 +610,7 @@ pub mod linear { } /// Visit the values representing the union - pure fn union(&self, other: &LinearSet, f: fn(&T) -> bool) { + pure fn union(&self, other: &LinearSet, f: &fn(&T) -> bool) { for self.each |v| { if !f(v) { return } } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 4634eb8793d95..b04bb15f5e30b 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -118,13 +118,13 @@ pub trait ReaderUtil { fn read_whole_stream(&self) -> ~[u8]; /// Iterate over every byte until the iterator breaks or EOF. - fn each_byte(&self, it: fn(int) -> bool); + fn each_byte(&self, it: &fn(int) -> bool); /// Iterate over every char until the iterator breaks or EOF. - fn each_char(&self, it: fn(char) -> bool); + fn each_char(&self, it: &fn(char) -> bool); /// Iterate over every line until the iterator breaks or EOF. - fn each_line(&self, it: fn(&str) -> bool); + fn each_line(&self, it: &fn(&str) -> bool); /// Read n (between 1 and 8) little-endian unsigned integer bytes. fn read_le_uint_n(&self, nbytes: uint) -> u64; @@ -315,19 +315,19 @@ impl ReaderUtil for T { bytes } - fn each_byte(&self, it: fn(int) -> bool) { + fn each_byte(&self, it: &fn(int) -> bool) { while !self.eof() { if !it(self.read_byte()) { break; } } } - fn each_char(&self, it: fn(char) -> bool) { + fn each_char(&self, it: &fn(char) -> bool) { while !self.eof() { if !it(self.read_char()) { break; } } } - fn each_line(&self, it: fn(s: &str) -> bool) { + fn each_line(&self, it: &fn(s: &str) -> bool) { while !self.eof() { if !it(self.read_line()) { break; } } @@ -618,11 +618,11 @@ impl Reader for BytesReader/&self { fn tell(&self) -> uint { self.pos } } -pub pure fn with_bytes_reader(bytes: &[u8], f: fn(@Reader) -> t) -> t { +pub pure fn with_bytes_reader(bytes: &[u8], f: &fn(@Reader) -> t) -> t { f(@BytesReader { bytes: bytes, pos: 0u } as @Reader) } -pub pure fn with_str_reader(s: &str, f: fn(@Reader) -> T) -> T { +pub pure fn with_str_reader(s: &str, f: &fn(@Reader) -> T) -> T { str::byte_slice(s, |bytes| with_bytes_reader(bytes, f)) } @@ -819,7 +819,7 @@ pub fn mk_file_writer(path: &Path, flags: &[FileFlag]) } pub fn u64_to_le_bytes(n: u64, size: uint, - f: fn(v: &[u8]) -> T) -> T { + f: &fn(v: &[u8]) -> T) -> T { fail_unless!(size <= 8u); match size { 1u => f(&[n as u8]), @@ -851,7 +851,7 @@ pub fn u64_to_le_bytes(n: u64, size: uint, } pub fn u64_to_be_bytes(n: u64, size: uint, - f: fn(v: &[u8]) -> T) -> T { + f: &fn(v: &[u8]) -> T) -> T { fail_unless!(size <= 8u); match size { 1u => f(&[n as u8]), @@ -1142,14 +1142,14 @@ pub pure fn BytesWriter() -> BytesWriter { BytesWriter { bytes: ~[], mut pos: 0u } } -pub pure fn with_bytes_writer(f: fn(Writer)) -> ~[u8] { +pub pure fn with_bytes_writer(f: &fn(Writer)) -> ~[u8] { let wr = @BytesWriter(); f(wr as Writer); let @BytesWriter{bytes, _} = wr; return bytes; } -pub pure fn with_str_writer(f: fn(Writer)) -> ~str { +pub pure fn with_str_writer(f: &fn(Writer)) -> ~str { let mut v = with_bytes_writer(f); // FIXME (#3758): This should not be needed. @@ -1251,7 +1251,7 @@ pub mod fsync { // FIXME (#2004) find better way to create resources within lifetime of // outer res pub fn FILE_res_sync(file: &FILERes, opt_level: Option, - blk: fn(v: Res<*libc::FILE>)) { + blk: &fn(v: Res<*libc::FILE>)) { unsafe { blk(Res(Arg { val: file.f, opt_level: opt_level, @@ -1266,7 +1266,7 @@ pub mod fsync { // fsync fd after executing blk pub fn fd_res_sync(fd: &FdRes, opt_level: Option, - blk: fn(v: Res)) { + blk: &fn(v: Res)) { blk(Res(Arg { val: fd.fd, opt_level: opt_level, fsync_fn: |fd, l| os::fsync_fd(fd, l) as int @@ -1278,7 +1278,7 @@ pub mod fsync { // Call o.fsync after executing blk pub fn obj_sync(o: FSyncable, opt_level: Option, - blk: fn(v: Res)) { + blk: &fn(v: Res)) { blk(Res(Arg { val: o, opt_level: opt_level, fsync_fn: |o, l| o.fsync(l) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index c92f747fc9872..8931b4088263e 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -23,22 +23,22 @@ use vec; pub type InitOp = &self/fn(uint) -> T; pub trait BaseIter { - pure fn each(&self, blk: fn(v: &A) -> bool); + pure fn each(&self, blk: &fn(v: &A) -> bool); pure fn size_hint(&self) -> Option; } pub trait ReverseIter: BaseIter { - pure fn each_reverse(&self, blk: fn(&A) -> bool); + pure fn each_reverse(&self, blk: &fn(&A) -> bool); } pub trait ExtendedIter { - pure fn eachi(&self, blk: fn(uint, v: &A) -> bool); - pure fn all(&self, blk: fn(&A) -> bool) -> bool; - pure fn any(&self, blk: fn(&A) -> bool) -> bool; - pure fn foldl(&self, b0: B, blk: fn(&B, &A) -> B) -> B; - pure fn position(&self, f: fn(&A) -> bool) -> Option; - pure fn map_to_vec(&self, op: fn(&A) -> B) -> ~[B]; - pure fn flat_map_to_vec>(&self, op: fn(&A) -> IB) + pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool); + pure fn all(&self, blk: &fn(&A) -> bool) -> bool; + pure fn any(&self, blk: &fn(&A) -> bool) -> bool; + pure fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B; + pure fn position(&self, f: &fn(&A) -> bool) -> Option; + pure fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B]; + pure fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B]; } @@ -48,13 +48,13 @@ pub trait EqIter { } pub trait Times { - pure fn times(&self, it: fn() -> bool); + pure fn times(&self, it: &fn() -> bool); } pub trait CopyableIter { - pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A]; + pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A]; pure fn to_vec(&self) -> ~[A]; - pure fn find(&self, p: fn(&A) -> bool) -> Option; + pure fn find(&self, p: &fn(&A) -> bool) -> Option; } pub trait CopyableOrderedIter { @@ -86,12 +86,12 @@ pub trait Buildable { * onto the sequence being constructed. */ static pure fn build_sized(size: uint, - builder: fn(push: pure fn(A))) -> Self; + builder: &fn(push: &pure fn(A))) -> Self; } #[inline(always)] pub pure fn eachi>(self: &IA, - blk: fn(uint, &A) -> bool) { + blk: &fn(uint, &A) -> bool) { let mut i = 0; for self.each |a| { if !blk(i, a) { break; } @@ -101,7 +101,7 @@ pub pure fn eachi>(self: &IA, #[inline(always)] pub pure fn all>(self: &IA, - blk: fn(&A) -> bool) -> bool { + blk: &fn(&A) -> bool) -> bool { for self.each |a| { if !blk(a) { return false; } } @@ -110,7 +110,7 @@ pub pure fn all>(self: &IA, #[inline(always)] pub pure fn any>(self: &IA, - blk: fn(&A) -> bool) -> bool { + blk: &fn(&A) -> bool) -> bool { for self.each |a| { if blk(a) { return true; } } @@ -119,7 +119,7 @@ pub pure fn any>(self: &IA, #[inline(always)] pub pure fn filter_to_vec>( - self: &IA, prd: fn(&A) -> bool) -> ~[A] { + self: &IA, prd: &fn(&A) -> bool) -> ~[A] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { if prd(a) { push(*a); } @@ -129,7 +129,7 @@ pub pure fn filter_to_vec>( #[inline(always)] pub pure fn map_to_vec>(self: &IA, - op: fn(&A) -> B) + op: &fn(&A) -> B) -> ~[B] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { @@ -140,7 +140,7 @@ pub pure fn map_to_vec>(self: &IA, #[inline(always)] pub pure fn flat_map_to_vec,IB:BaseIter>( - self: &IA, op: fn(&A) -> IB) -> ~[B] { + self: &IA, op: &fn(&A) -> IB) -> ~[B] { do vec::build |push| { for self.each |a| { for op(a).each |&b| { @@ -152,7 +152,7 @@ pub pure fn flat_map_to_vec,IB:BaseIter>( #[inline(always)] pub pure fn foldl>(self: &IA, b0: B, - blk: fn(&B, &A) -> B) + blk: &fn(&B, &A) -> B) -> B { let mut b = b0; for self.each |a| { @@ -186,7 +186,7 @@ pub pure fn count>(self: &IA, x: &A) -> uint { } #[inline(always)] -pub pure fn position>(self: &IA, f: fn(&A) -> bool) +pub pure fn position>(self: &IA, f: &fn(&A) -> bool) -> Option { let mut i = 0; @@ -202,7 +202,7 @@ pub pure fn position>(self: &IA, f: fn(&A) -> bool) // it would have to be implemented with foldr, which is too inefficient. #[inline(always)] -pub pure fn repeat(times: uint, blk: fn() -> bool) { +pub pure fn repeat(times: uint, blk: &fn() -> bool) { let mut i = 0; while i < times { if !blk() { break } @@ -242,7 +242,7 @@ pub pure fn max>(self: &IA) -> A { #[inline(always)] pub pure fn find>(self: &IA, - f: fn(&A) -> bool) -> Option { + f: &fn(&A) -> bool) -> Option { for self.each |i| { if f(i) { return Some(*i) } } @@ -262,7 +262,7 @@ pub pure fn find>(self: &IA, * onto the sequence being constructed. */ #[inline(always)] -pub pure fn build>(builder: fn(push: pure fn(A))) +pub pure fn build>(builder: &fn(push: &pure fn(A))) -> B { Buildable::build_sized(4, builder) } @@ -283,7 +283,7 @@ pub pure fn build>(builder: fn(push: pure fn(A))) #[inline(always)] pub pure fn build_sized_opt>( size: Option, - builder: fn(push: pure fn(A))) -> B { + builder: &fn(push: &pure fn(A))) -> B { Buildable::build_sized(size.get_or_default(4), builder) } @@ -292,7 +292,7 @@ pub pure fn build_sized_opt>( /// Applies a function to each element of an iterable and returns the results. #[inline(always)] -pub fn map,U,BU: Buildable>(v: &IT, f: fn(&T) -> U) +pub fn map,U,BU: Buildable>(v: &IT, f: &fn(&T) -> U) -> BU { do build_sized_opt(v.size_hint()) |push| { for v.each() |elem| { diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 2f59b4c50de04..cef8542823a67 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -100,7 +100,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } */ #[inline(always)] /// Iterate over the range [`start`,`start`+`step`..`stop`) -pub pure fn range_step(start: T, stop: T, step: T, it: fn(T) -> bool) { +pub pure fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) { let mut i = start; if step == 0 { fail!(~"range_step called with step == 0"); @@ -119,13 +119,13 @@ pub pure fn range_step(start: T, stop: T, step: T, it: fn(T) -> bool) { #[inline(always)] /// Iterate over the range [`lo`..`hi`) -pub pure fn range(lo: T, hi: T, it: fn(T) -> bool) { +pub pure fn range(lo: T, hi: T, it: &fn(T) -> bool) { range_step(lo, hi, 1 as T, it); } #[inline(always)] /// Iterate over the range [`hi`..`lo`) -pub pure fn range_rev(hi: T, lo: T, it: fn(T) -> bool) { +pub pure fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) { range_step(hi, lo, -1 as T, it); } @@ -237,7 +237,7 @@ impl FromStrRadix for T { /// Convert to a string as a byte slice in a given base. #[inline(always)] -pub pure fn to_str_bytes(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U { +pub pure fn to_str_bytes(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, strconv::SignNeg, strconv::DigAll); f(buf) diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 11bd7dbfd3ad9..9abbfb03d7a56 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -67,7 +67,10 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } * Iterate over the range [`start`,`start`+`step`..`stop`) * */ -pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: fn(T) -> bool) { +pub pure fn range_step(start: T, + stop: T, + step: T_SIGNED, + it: &fn(T) -> bool) { let mut i = start; if step == 0 { fail!(~"range_step called with step == 0"); @@ -88,13 +91,13 @@ pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: fn(T) -> bool) { #[inline(always)] /// Iterate over the range [`lo`..`hi`) -pub pure fn range(lo: T, hi: T, it: fn(T) -> bool) { +pub pure fn range(lo: T, hi: T, it: &fn(T) -> bool) { range_step(lo, hi, 1 as T_SIGNED, it); } #[inline(always)] /// Iterate over the range [`hi`..`lo`) -pub pure fn range_rev(hi: T, lo: T, it: fn(T) -> bool) { +pub pure fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) { range_step(hi, lo, -1 as T_SIGNED, it); } @@ -200,7 +203,7 @@ impl FromStrRadix for T { /// Convert to a string as a byte slice in a given base. #[inline(always)] -pub pure fn to_str_bytes(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U { +pub pure fn to_str_bytes(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, strconv::SignNeg, strconv::DigAll); f(buf) diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index 6814b0e754199..f73ff4442ceee 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -101,7 +101,7 @@ pub mod inst { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ - pub pure fn iterate(lo: uint, hi: uint, it: fn(uint) -> bool) -> bool { + pub pure fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool { let mut i = lo; while i < hi { if (!it(i)) { return false; } @@ -122,7 +122,7 @@ pub mod inst { * use with integer literals of inferred integer-type as * the self-value (eg. `for 100.times { ... }`). */ - pure fn times(&self, it: fn() -> bool) { + pure fn times(&self, it: &fn() -> bool) { let mut i = *self; while i > 0 { if !it() { break } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 7b0e4d07b53b8..e0393fdf5e35a 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -131,7 +131,7 @@ pub pure fn get_ref(opt: &r/Option) -> &r/T { } #[inline(always)] -pub pure fn map(opt: &r/Option, f: fn(x: &r/T) -> U) -> Option { +pub pure fn map(opt: &r/Option, f: &fn(x: &r/T) -> U) -> Option { //! Maps a `some` value by reference from one type to another match *opt { Some(ref x) => Some(f(x)), None => None } @@ -139,7 +139,7 @@ pub pure fn map(opt: &r/Option, f: fn(x: &r/T) -> U) -> Option { #[inline(always)] pub pure fn map_consume(opt: Option, - f: fn(v: T) -> U) -> Option { + f: &fn(v: T) -> U) -> Option { /*! * As `map`, but consumes the option and gives `f` ownership to avoid * copying. @@ -149,7 +149,7 @@ pub pure fn map_consume(opt: Option, #[inline(always)] pub pure fn chain(opt: Option, - f: fn(t: T) -> Option) -> Option { + f: &fn(t: T) -> Option) -> Option { /*! * Update an optional value by optionally running its content through a * function that returns an option. @@ -163,7 +163,7 @@ pub pure fn chain(opt: Option, #[inline(always)] pub pure fn chain_ref(opt: &Option, - f: fn(x: &T) -> Option) -> Option { + f: &fn(x: &T) -> Option) -> Option { /*! * Update an optional value by optionally running its content by reference * through a function that returns an option. @@ -184,7 +184,7 @@ pub pure fn or(opta: Option, optb: Option) -> Option { } #[inline(always)] -pub pure fn while_some(x: Option, blk: fn(v: T) -> Option) { +pub pure fn while_some(x: Option, blk: &fn(v: T) -> Option) { //! Applies a function zero or more times until the result is none. let mut opt = x; @@ -223,7 +223,7 @@ pub pure fn get_or_default(opt: Option, def: T) -> T { #[inline(always)] pub pure fn map_default(opt: &r/Option, def: U, - f: fn(&r/T) -> U) -> U { + f: &fn(&r/T) -> U) -> U { //! Applies a function to the contained value or returns a default match *opt { None => def, Some(ref t) => f(t) } @@ -279,7 +279,7 @@ pub pure fn expect(opt: Option, reason: &str) -> T { impl BaseIter for Option { /// Performs an operation on the contained value by reference #[inline(always)] - pure fn each(&self, f: fn(x: &self/T) -> bool) { + pure fn each(&self, f: &fn(x: &self/T) -> bool) { match *self { None => (), Some(ref t) => { f(t); } } } @@ -303,43 +303,43 @@ pub impl Option { * through a function that returns an option. */ #[inline(always)] - pure fn chain_ref(&self, f: fn(x: &T) -> Option) -> Option { + pure fn chain_ref(&self, f: &fn(x: &T) -> Option) -> Option { chain_ref(self, f) } /// Maps a `some` value from one type to another by reference #[inline(always)] - pure fn map(&self, f: fn(&self/T) -> U) -> Option { map(self, f) } + pure fn map(&self, f: &fn(&self/T) -> U) -> Option { map(self, f) } /// As `map`, but consumes the option and gives `f` ownership to avoid /// copying. #[inline(always)] - pure fn map_consume(self, f: fn(v: T) -> U) -> Option { + pure fn map_consume(self, f: &fn(v: T) -> U) -> Option { map_consume(self, f) } /// Applies a function to the contained value or returns a default #[inline(always)] - pure fn map_default(&self, def: U, f: fn(&self/T) -> U) -> U { + pure fn map_default(&self, def: U, f: &fn(&self/T) -> U) -> U { map_default(self, def, f) } /// As `map_default`, but consumes the option and gives `f` /// ownership to avoid copying. #[inline(always)] - pure fn map_consume_default(self, def: U, f: fn(v: T) -> U) -> U { + pure fn map_consume_default(self, def: U, f: &fn(v: T) -> U) -> U { match self { None => def, Some(v) => f(v) } } /// Apply a function to the contained value or do nothing - fn mutate(&mut self, f: fn(T) -> T) { + fn mutate(&mut self, f: &fn(T) -> T) { if self.is_some() { *self = Some(f(self.swap_unwrap())); } } /// Apply a function to the contained value or set it to a default - fn mutate_default(&mut self, def: T, f: fn(T) -> T) { + fn mutate_default(&mut self, def: T, f: &fn(T) -> T) { if self.is_some() { *self = Some(f(self.swap_unwrap())); } else { @@ -420,7 +420,7 @@ pub impl Option { /// Applies a function zero or more times until the result is none. #[inline(always)] - pure fn while_some(self, blk: fn(v: T) -> Option) { + pure fn while_some(self, blk: &fn(v: T) -> Option) { while_some(self, blk) } } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 5c73e45364be7..ba16c14a85add 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -75,11 +75,11 @@ pub fn getcwd() -> Path { } } -pub fn as_c_charp(s: &str, f: fn(*c_char) -> T) -> T { +pub fn as_c_charp(s: &str, f: &fn(*c_char) -> T) -> T { str::as_c_str(s, |b| f(b as *c_char)) } -pub fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool) +pub fn fill_charp_buf(f: &fn(*mut c_char, size_t) -> bool) -> Option<~str> { let mut buf = vec::from_elem(TMPBUF_SZ, 0u8 as c_char); do vec::as_mut_buf(buf) |b, sz| { @@ -103,7 +103,7 @@ pub mod win32 { use os::TMPBUF_SZ; use libc::types::os::arch::extra::DWORD; - pub fn fill_utf16_buf_and_decode(f: fn(*mut u16, DWORD) -> DWORD) + pub fn fill_utf16_buf_and_decode(f: &fn(*mut u16, DWORD) -> DWORD) -> Option<~str> { unsafe { let mut n = TMPBUF_SZ as DWORD; @@ -133,7 +133,7 @@ pub mod win32 { } } - pub fn as_utf16_p(s: &str, f: fn(*u16) -> T) -> T { + pub fn as_utf16_p(s: &str, f: &fn(*u16) -> T) -> T { let mut t = str::to_utf16(s); // Null terminate before passing on. t += ~[0u16]; @@ -518,11 +518,11 @@ pub fn tmpdir() -> Path { } } /// Recursively walk a directory structure -pub fn walk_dir(p: &Path, f: fn(&Path) -> bool) { +pub fn walk_dir(p: &Path, f: &fn(&Path) -> bool) { walk_dir_(p, f); - fn walk_dir_(p: &Path, f: fn(&Path) -> bool) -> bool { + fn walk_dir_(p: &Path, f: &fn(&Path) -> bool) -> bool { let mut keepgoing = true; do list_dir(p).each |q| { let path = &p.push(*q); diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index afb7aef25a3a0..fd823e9dda0d7 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -246,7 +246,7 @@ pub fn packet() -> *Packet { #[doc(hidden)] pub fn entangle_buffer( buffer: ~Buffer, - init: fn(*libc::c_void, x: &T) -> *Packet) + init: &fn(*libc::c_void, x: &T) -> *Packet) -> (SendPacketBuffered, RecvPacketBuffered) { let p = init(unsafe { reinterpret_cast(&buffer) }, &buffer.data); diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index ebf41dc48f405..b66c1c4696fcf 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -82,7 +82,7 @@ pub unsafe fn buf_len(buf: **T) -> uint { /// Return the first offset `i` such that `f(buf[i]) == true`. #[inline(always)] -pub unsafe fn position(buf: *T, f: fn(&T) -> bool) -> uint { +pub unsafe fn position(buf: *T, f: &fn(&T) -> bool) -> uint { let mut i = 0; loop { if f(&(*offset(buf, i))) { return i; } diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index f29447ef53e33..30c46cd3e35d1 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -26,7 +26,7 @@ use vec; * then build a MovePtrAdaptor wrapped around your struct. */ pub trait MovePtr { - fn move_ptr(&self, adjustment: fn(*c_void) -> *c_void); + fn move_ptr(&self, adjustment: &fn(*c_void) -> *c_void); fn push_ptr(&self); fn pop_ptr(&self); } diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index e9122754eb42a..ad85c5e5ceff4 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -159,7 +159,7 @@ pub fn ReprVisitor(ptr: *c_void, writer: @Writer) -> ReprVisitor { impl MovePtr for ReprVisitor { #[inline(always)] - fn move_ptr(&self, adjustment: fn(*c_void) -> *c_void) { + fn move_ptr(&self, adjustment: &fn(*c_void) -> *c_void) { self.ptr = adjustment(self.ptr); } fn push_ptr(&self) { @@ -175,7 +175,7 @@ pub impl ReprVisitor { // Various helpers for the TyVisitor impl #[inline(always)] - fn get(&self, f: fn(&T)) -> bool { + fn get(&self, f: &fn(&T)) -> bool { unsafe { f(transmute::<*c_void,&T>(copy self.ptr)); } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index dd9b55e672580..e3fd279a99609 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -122,7 +122,7 @@ pub pure fn to_either(res: &Result) * } */ #[inline(always)] -pub pure fn chain(res: Result, op: fn(T) +pub pure fn chain(res: Result, op: &fn(T) -> Result) -> Result { match res { Ok(t) => op(t), @@ -141,7 +141,7 @@ pub pure fn chain(res: Result, op: fn(T) #[inline(always)] pub pure fn chain_err( res: Result, - op: fn(t: V) -> Result) + op: &fn(t: V) -> Result) -> Result { match res { Ok(t) => Ok(t), @@ -164,7 +164,7 @@ pub pure fn chain_err( * } */ #[inline(always)] -pub pure fn iter(res: &Result, f: fn(&T)) { +pub pure fn iter(res: &Result, f: &fn(&T)) { match *res { Ok(ref t) => f(t), Err(_) => () @@ -180,7 +180,7 @@ pub pure fn iter(res: &Result, f: fn(&T)) { * handling an error. */ #[inline(always)] -pub pure fn iter_err(res: &Result, f: fn(&E)) { +pub pure fn iter_err(res: &Result, f: &fn(&E)) { match *res { Ok(_) => (), Err(ref e) => f(e) @@ -202,7 +202,7 @@ pub pure fn iter_err(res: &Result, f: fn(&E)) { * } */ #[inline(always)] -pub pure fn map(res: &Result, op: fn(&T) -> U) +pub pure fn map(res: &Result, op: &fn(&T) -> U) -> Result { match *res { Ok(ref t) => Ok(op(t)), @@ -219,7 +219,7 @@ pub pure fn map(res: &Result, op: fn(&T) -> U) * successful result while handling an error. */ #[inline(always)] -pub pure fn map_err(res: &Result, op: fn(&E) -> F) +pub pure fn map_err(res: &Result, op: &fn(&E) -> F) -> Result { match *res { Ok(copy t) => Ok(t), @@ -238,10 +238,10 @@ pub impl Result { pure fn is_err(&self) -> bool { is_err(self) } #[inline(always)] - pure fn iter(&self, f: fn(&T)) { iter(self, f) } + pure fn iter(&self, f: &fn(&T)) { iter(self, f) } #[inline(always)] - pure fn iter_err(&self, f: fn(&E)) { iter_err(self, f) } + pure fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) } #[inline(always)] pure fn unwrap(self) -> T { unwrap(self) } @@ -250,12 +250,12 @@ pub impl Result { pure fn unwrap_err(self) -> E { unwrap_err(self) } #[inline(always)] - pure fn chain(self, op: fn(T) -> Result) -> Result { + pure fn chain(self, op: &fn(T) -> Result) -> Result { chain(self, op) } #[inline(always)] - pure fn chain_err(self, op: fn(E) -> Result) -> Result { + pure fn chain_err(self, op: &fn(E) -> Result) -> Result { chain_err(self, op) } } @@ -265,7 +265,7 @@ pub impl Result { pure fn get(&self) -> T { get(self) } #[inline(always)] - pure fn map_err(&self, op: fn(&E) -> F) -> Result { + pure fn map_err(&self, op: &fn(&E) -> F) -> Result { map_err(self, op) } } @@ -275,7 +275,7 @@ pub impl Result { pure fn get_err(&self) -> E { get_err(self) } #[inline(always)] - pure fn map(&self, op: fn(&T) -> U) -> Result { + pure fn map(&self, op: &fn(&T) -> U) -> Result { map(self, op) } } @@ -299,7 +299,7 @@ pub impl Result { */ #[inline(always)] pub fn map_vec( - ts: &[T], op: fn(&T) -> Result) -> Result<~[V],U> { + ts: &[T], op: &fn(&T) -> Result) -> Result<~[V],U> { let mut vs: ~[V] = vec::with_capacity(vec::len(ts)); for vec::each(ts) |t| { @@ -313,7 +313,7 @@ pub fn map_vec( #[inline(always)] pub fn map_opt( - o_t: &Option, op: fn(&T) -> Result) -> Result,U> { + o_t: &Option, op: &fn(&T) -> Result) -> Result,U> { match *o_t { None => Ok(None), @@ -335,7 +335,7 @@ pub fn map_opt( */ #[inline(always)] pub fn map_vec2(ss: &[S], ts: &[T], - op: fn(&S,&T) -> Result) -> Result<~[V],U> { + op: &fn(&S,&T) -> Result) -> Result<~[V],U> { fail_unless!(vec::same_length(ss, ts)); let n = vec::len(ts); @@ -358,7 +358,7 @@ pub fn map_vec2(ss: &[S], ts: &[T], */ #[inline(always)] pub fn iter_vec2(ss: &[S], ts: &[T], - op: fn(&S,&T) -> Result<(),U>) -> Result<(),U> { + op: &fn(&S,&T) -> Result<(),U>) -> Result<(),U> { fail_unless!(vec::same_length(ss, ts)); let n = vec::len(ts); diff --git a/src/libcore/run.rs b/src/libcore/run.rs index bebcc909dc658..a9d96d891c944 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -102,7 +102,7 @@ pub fn spawn_process(prog: &str, args: &[~str], } fn with_argv(prog: &str, args: &[~str], - cb: fn(**libc::c_char) -> T) -> T { + cb: &fn(**libc::c_char) -> T) -> T { let mut argptrs = str::as_c_str(prog, |b| ~[b]); let mut tmps = ~[]; for vec::each(args) |arg| { @@ -116,7 +116,7 @@ fn with_argv(prog: &str, args: &[~str], #[cfg(unix)] fn with_envp(env: &Option<~[(~str,~str)]>, - cb: fn(*c_void) -> T) -> T { + cb: &fn(*c_void) -> T) -> T { // On posixy systems we can pass a char** for envp, which is // a null-terminated array of "k=v\n" strings. match *env { @@ -141,7 +141,7 @@ fn with_envp(env: &Option<~[(~str,~str)]>, #[cfg(windows)] fn with_envp(env: &Option<~[(~str,~str)]>, - cb: fn(*c_void) -> T) -> T { + cb: &fn(*c_void) -> T) -> T { // On win32 we pass an "environment block" which is not a char**, but // rather a concatenation of null-terminated k=v\0 sequences, with a final // \0 to terminate. @@ -165,7 +165,7 @@ fn with_envp(env: &Option<~[(~str,~str)]>, } fn with_dirp(d: &Option<~str>, - cb: fn(*libc::c_char) -> T) -> T { + cb: &fn(*libc::c_char) -> T) -> T { match *d { Some(ref dir) => str::as_c_str(*dir, cb), None => cb(ptr::null()) diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index 107e52b245e37..955e486649b99 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -24,7 +24,7 @@ pub fn Frame(fp: *Word) -> Frame { } } -pub fn walk_stack(visit: fn(Frame) -> bool) { +pub fn walk_stack(visit: &fn(Frame) -> bool) { debug!("beginning stack walk"); @@ -80,7 +80,7 @@ fn breakpoint() { } } -fn frame_address(f: fn(++x: *u8)) { +fn frame_address(f: &fn(++x: *u8)) { unsafe { rusti::frame_address(f) } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 6a0673878e0e2..ae778cb7649b7 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -382,7 +382,7 @@ pub pure fn to_bytes(s: &str) -> ~[u8] { /// Work with the string as a byte slice, not including trailing null. #[inline(always)] -pub pure fn byte_slice(s: &str, f: fn(v: &[u8]) -> T) -> T { +pub pure fn byte_slice(s: &str, f: &fn(v: &[u8]) -> T) -> T { do as_buf(s) |p,n| { unsafe { vec::raw::buf_as_slice(p, n-1u, f) } } @@ -483,7 +483,7 @@ pure fn split_char_inner(s: &str, sep: char, count: uint, allow_empty: bool) /// Splits a string into substrings using a character function -pub pure fn split(s: &str, sepfn: fn(char) -> bool) -> ~[~str] { +pub pure fn split(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { split_inner(s, sepfn, len(s), true) } @@ -491,16 +491,19 @@ pub pure fn split(s: &str, sepfn: fn(char) -> bool) -> ~[~str] { * Splits a string into substrings using a character function, cutting at * most `count` times. */ -pub pure fn splitn(s: &str, sepfn: fn(char) -> bool, count: uint) -> ~[~str] { +pub pure fn splitn(s: &str, + sepfn: &fn(char) -> bool, + count: uint) + -> ~[~str] { split_inner(s, sepfn, count, true) } /// Like `split`, but omits empty strings from the returned vector -pub pure fn split_nonempty(s: &str, sepfn: fn(char) -> bool) -> ~[~str] { +pub pure fn split_nonempty(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { split_inner(s, sepfn, len(s), false) } -pure fn split_inner(s: &str, sepfn: fn(cc: char) -> bool, count: uint, +pure fn split_inner(s: &str, sepfn: &fn(cc: char) -> bool, count: uint, allow_empty: bool) -> ~[~str] { let l = len(s); let mut result = ~[], i = 0u, start = 0u, done = 0u; @@ -526,7 +529,7 @@ pure fn split_inner(s: &str, sepfn: fn(cc: char) -> bool, count: uint, } // See Issue #1932 for why this is a naive search -pure fn iter_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { +pure fn iter_matches(s: &a/str, sep: &b/str, f: &fn(uint, uint)) { let sep_len = len(sep), l = len(s); fail_unless!(sep_len > 0u); let mut i = 0u, match_start = 0u, match_i = 0u; @@ -553,7 +556,7 @@ pure fn iter_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { } } -pure fn iter_between_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { +pure fn iter_between_matches(s: &a/str, sep: &b/str, f: &fn(uint, uint)) { let mut last_end = 0u; do iter_matches(s, sep) |from, to| { f(last_end, from); @@ -912,7 +915,7 @@ Section: Iterating through strings * Return true if a predicate matches all characters or if the string * contains no characters */ -pub pure fn all(s: &str, it: fn(char) -> bool) -> bool { +pub pure fn all(s: &str, it: &fn(char) -> bool) -> bool { all_between(s, 0u, len(s), it) } @@ -920,12 +923,12 @@ pub pure fn all(s: &str, it: fn(char) -> bool) -> bool { * Return true if a predicate matches any character (and false if it * matches none or there are no characters) */ -pub pure fn any(ss: &str, pred: fn(char) -> bool) -> bool { +pub pure fn any(ss: &str, pred: &fn(char) -> bool) -> bool { !all(ss, |cc| !pred(cc)) } /// Apply a function to each character -pub pure fn map(ss: &str, ff: fn(char) -> char) -> ~str { +pub pure fn map(ss: &str, ff: &fn(char) -> char) -> ~str { let mut result = ~""; unsafe { reserve(&mut result, len(ss)); @@ -937,7 +940,7 @@ pub pure fn map(ss: &str, ff: fn(char) -> char) -> ~str { } /// Iterate over the bytes in a string -pub pure fn bytes_each(ss: &str, it: fn(u8) -> bool) { +pub pure fn bytes_each(ss: &str, it: &fn(u8) -> bool) { let mut pos = 0u; let len = len(ss); @@ -949,13 +952,13 @@ pub pure fn bytes_each(ss: &str, it: fn(u8) -> bool) { /// Iterate over the bytes in a string #[inline(always)] -pub pure fn each(s: &str, it: fn(u8) -> bool) { +pub pure fn each(s: &str, it: &fn(u8) -> bool) { eachi(s, |_i, b| it(b) ) } /// Iterate over the bytes in a string, with indices #[inline(always)] -pub pure fn eachi(s: &str, it: fn(uint, u8) -> bool) { +pub pure fn eachi(s: &str, it: &fn(uint, u8) -> bool) { let mut i = 0u, l = len(s); while (i < l) { if !it(i, s[i]) { break; } @@ -965,13 +968,13 @@ pub pure fn eachi(s: &str, it: fn(uint, u8) -> bool) { /// Iterates over the chars in a string #[inline(always)] -pub pure fn each_char(s: &str, it: fn(char) -> bool) { +pub pure fn each_char(s: &str, it: &fn(char) -> bool) { each_chari(s, |_i, c| it(c)) } /// Iterates over the chars in a string, with indices #[inline(always)] -pub pure fn each_chari(s: &str, it: fn(uint, char) -> bool) { +pub pure fn each_chari(s: &str, it: &fn(uint, char) -> bool) { let mut pos = 0u, ch_pos = 0u; let len = len(s); while pos < len { @@ -983,7 +986,7 @@ pub pure fn each_chari(s: &str, it: fn(uint, char) -> bool) { } /// Iterate over the characters in a string -pub pure fn chars_each(s: &str, it: fn(char) -> bool) { +pub pure fn chars_each(s: &str, it: &fn(char) -> bool) { let mut pos = 0u; let len = len(s); while (pos < len) { @@ -994,7 +997,7 @@ pub pure fn chars_each(s: &str, it: fn(char) -> bool) { } /// Apply a function to each substring after splitting by character -pub pure fn split_char_each(ss: &str, cc: char, ff: fn(v: &str) -> bool) { +pub pure fn split_char_each(ss: &str, cc: char, ff: &fn(v: &str) -> bool) { vec::each(split_char(ss, cc), |s| ff(*s)) } @@ -1003,19 +1006,19 @@ pub pure fn split_char_each(ss: &str, cc: char, ff: fn(v: &str) -> bool) { * `count` times */ pub pure fn splitn_char_each(ss: &str, sep: char, count: uint, - ff: fn(v: &str) -> bool) { + ff: &fn(v: &str) -> bool) { vec::each(splitn_char(ss, sep, count), |s| ff(*s)) } /// Apply a function to each word -pub pure fn words_each(ss: &str, ff: fn(v: &str) -> bool) { +pub pure fn words_each(ss: &str, ff: &fn(v: &str) -> bool) { vec::each(words(ss), |s| ff(*s)) } /** * Apply a function to each line (by '\n') */ -pub pure fn lines_each(ss: &str, ff: fn(v: &str) -> bool) { +pub pure fn lines_each(ss: &str, ff: &fn(v: &str) -> bool) { vec::each(lines(ss), |s| ff(*s)) } @@ -1195,7 +1198,7 @@ pub pure fn rfind_char_between(s: &str, c: char, start: uint, end: uint) * An `option` containing the byte index of the first matching character * or `none` if there is no match */ -pub pure fn find(s: &str, f: fn(char) -> bool) -> Option { +pub pure fn find(s: &str, f: &fn(char) -> bool) -> Option { find_between(s, 0u, len(s), f) } @@ -1219,7 +1222,7 @@ pub pure fn find(s: &str, f: fn(char) -> bool) -> Option { * `start` must be less than or equal to `len(s)`. `start` must be the * index of a character boundary, as defined by `is_char_boundary`. */ -pub pure fn find_from(s: &str, start: uint, f: fn(char) +pub pure fn find_from(s: &str, start: uint, f: &fn(char) -> bool) -> Option { find_between(s, start, len(s), f) } @@ -1246,8 +1249,11 @@ pub pure fn find_from(s: &str, start: uint, f: fn(char) * or equal to `len(s)`. `start` must be the index of a character * boundary, as defined by `is_char_boundary`. */ -pub pure fn find_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) - -> Option { +pub pure fn find_between(s: &str, + start: uint, + end: uint, + f: &fn(char) -> bool) + -> Option { fail_unless!(start <= end); fail_unless!(end <= len(s)); fail_unless!(is_char_boundary(s, start)); @@ -1274,7 +1280,7 @@ pub pure fn find_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) * An option containing the byte index of the last matching character * or `none` if there is no match */ -pub pure fn rfind(s: &str, f: fn(char) -> bool) -> Option { +pub pure fn rfind(s: &str, f: &fn(char) -> bool) -> Option { rfind_between(s, len(s), 0u, f) } @@ -1298,7 +1304,7 @@ pub pure fn rfind(s: &str, f: fn(char) -> bool) -> Option { * `start` must be less than or equal to `len(s)', `start` must be the * index of a character boundary, as defined by `is_char_boundary` */ -pub pure fn rfind_from(s: &str, start: uint, f: fn(char) -> bool) +pub pure fn rfind_from(s: &str, start: uint, f: &fn(char) -> bool) -> Option { rfind_between(s, start, 0u, f) } @@ -1326,7 +1332,7 @@ pub pure fn rfind_from(s: &str, start: uint, f: fn(char) -> bool) * boundary, as defined by `is_char_boundary` */ pub pure fn rfind_between(s: &str, start: uint, end: uint, - f: fn(char) -> bool) + f: &fn(char) -> bool) -> Option { fail_unless!(start >= end); fail_unless!(start <= len(s)); @@ -1589,7 +1595,7 @@ pub pure fn to_utf16(s: &str) -> ~[u16] { u } -pub pure fn utf16_chars(v: &[u16], f: fn(char)) { +pub pure fn utf16_chars(v: &[u16], f: &fn(char)) { let len = vec::len(v); let mut i = 0u; while (i < len && v[i] != 0u16) { @@ -1815,7 +1821,7 @@ pure fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { * that is if `it` returned `false` at any point. */ pub pure fn all_between(s: &str, start: uint, end: uint, - it: fn(char) -> bool) -> bool { + it: &fn(char) -> bool) -> bool { fail_unless!(is_char_boundary(s, start)); let mut i = start; while i < end { @@ -1848,7 +1854,7 @@ pub pure fn all_between(s: &str, start: uint, end: uint, * `true` if `it` returns `true` for any character */ pub pure fn any_between(s: &str, start: uint, end: uint, - it: fn(char) -> bool) -> bool { + it: &fn(char) -> bool) -> bool { !all_between(s, start, end, |c| !it(c)) } @@ -1886,7 +1892,7 @@ pub const nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8]; * let i = str::as_bytes("Hello World") { |bytes| vec::len(bytes) }; * ~~~ */ -pub pure fn as_bytes(s: &const ~str, f: fn(&~[u8]) -> T) -> T { +pub pure fn as_bytes(s: &const ~str, f: &fn(&~[u8]) -> T) -> T { unsafe { let v: *~[u8] = cast::transmute(copy s); f(&*v) @@ -1921,7 +1927,7 @@ pub pure fn as_bytes_slice(s: &a/str) -> &a/[u8] { * let s = str::as_c_str("PATH", { |path| libc::getenv(path) }); * ~~~ */ -pub pure fn as_c_str(s: &str, f: fn(*libc::c_char) -> T) -> T { +pub pure fn as_c_str(s: &str, f: &fn(*libc::c_char) -> T) -> T { do as_buf(s) |buf, len| { // NB: len includes the trailing null. fail_unless!(len > 0); @@ -1943,7 +1949,7 @@ pub pure fn as_c_str(s: &str, f: fn(*libc::c_char) -> T) -> T { * to full strings, or suffixes of them. */ #[inline(always)] -pub pure fn as_buf(s: &str, f: fn(*u8, uint) -> T) -> T { +pub pure fn as_buf(s: &str, f: &fn(*u8, uint) -> T) -> T { unsafe { let v : *(*u8,uint) = ::cast::reinterpret_cast(&ptr::addr_of(&s)); let (buf,len) = *v; @@ -2088,7 +2094,7 @@ pub mod raw { /// Form a slice from a *u8 buffer of the given length without copying. pub unsafe fn buf_as_slice(buf: *u8, len: uint, - f: fn(v: &str) -> T) -> T { + f: &fn(v: &str) -> T) -> T { let v = (buf, len + 1); fail_unless!(is_utf8(::cast::reinterpret_cast(&v))); f(::cast::transmute(v)) @@ -2238,21 +2244,21 @@ pub mod traits { pub mod traits {} pub trait StrSlice { - pure fn all(&self, it: fn(char) -> bool) -> bool; - pure fn any(&self, it: fn(char) -> bool) -> bool; + pure fn all(&self, it: &fn(char) -> bool) -> bool; + pure fn any(&self, it: &fn(char) -> bool) -> bool; pure fn contains(&self, needle: &a/str) -> bool; pure fn contains_char(&self, needle: char) -> bool; - pure fn each(&self, it: fn(u8) -> bool); - pure fn eachi(&self, it: fn(uint, u8) -> bool); - pure fn each_char(&self, it: fn(char) -> bool); - pure fn each_chari(&self, it: fn(uint, char) -> bool); + pure fn each(&self, it: &fn(u8) -> bool); + pure fn eachi(&self, it: &fn(uint, u8) -> bool); + pure fn each_char(&self, it: &fn(char) -> bool); + pure fn each_chari(&self, it: &fn(uint, char) -> bool); pure fn ends_with(&self, needle: &str) -> bool; pure fn is_empty(&self) -> bool; pure fn is_whitespace(&self) -> bool; pure fn is_alphanumeric(&self) -> bool; pure fn len(&self) -> uint; pure fn slice(&self, begin: uint, end: uint) -> ~str; - pure fn split(&self, sepfn: fn(char) -> bool) -> ~[~str]; + pure fn split(&self, sepfn: &fn(char) -> bool) -> ~[~str]; pure fn split_char(&self, sep: char) -> ~[~str]; pure fn split_str(&self, sep: &a/str) -> ~[~str]; pure fn starts_with(&self, needle: &a/str) -> bool; @@ -2276,13 +2282,13 @@ impl StrSlice for &self/str { * contains no characters */ #[inline] - pure fn all(&self, it: fn(char) -> bool) -> bool { all(*self, it) } + pure fn all(&self, it: &fn(char) -> bool) -> bool { all(*self, it) } /** * Return true if a predicate matches any character (and false if it * matches none or there are no characters) */ #[inline] - pure fn any(&self, it: fn(char) -> bool) -> bool { any(*self, it) } + pure fn any(&self, it: &fn(char) -> bool) -> bool { any(*self, it) } /// Returns true if one string contains another #[inline] pure fn contains(&self, needle: &a/str) -> bool { @@ -2295,16 +2301,16 @@ impl StrSlice for &self/str { } /// Iterate over the bytes in a string #[inline] - pure fn each(&self, it: fn(u8) -> bool) { each(*self, it) } + pure fn each(&self, it: &fn(u8) -> bool) { each(*self, it) } /// Iterate over the bytes in a string, with indices #[inline] - pure fn eachi(&self, it: fn(uint, u8) -> bool) { eachi(*self, it) } + pure fn eachi(&self, it: &fn(uint, u8) -> bool) { eachi(*self, it) } /// Iterate over the chars in a string #[inline] - pure fn each_char(&self, it: fn(char) -> bool) { each_char(*self, it) } + pure fn each_char(&self, it: &fn(char) -> bool) { each_char(*self, it) } /// Iterate over the chars in a string, with indices #[inline] - pure fn each_chari(&self, it: fn(uint, char) -> bool) { + pure fn each_chari(&self, it: &fn(uint, char) -> bool) { each_chari(*self, it) } /// Returns true if one string ends with another @@ -2345,7 +2351,7 @@ impl StrSlice for &self/str { } /// Splits a string into substrings using a character function #[inline] - pure fn split(&self, sepfn: fn(char) -> bool) -> ~[~str] { + pure fn split(&self, sepfn: &fn(char) -> bool) -> ~[~str] { split(*self, sepfn) } /** diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index d4db61f4519c3..179a33ae43ea3 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -227,7 +227,7 @@ pub mod tests { pub fn synthesize_closure() { unsafe { let x = 10; - let f: fn(int) -> int = |y| x + y; + let f: &fn(int) -> int = |y| x + y; fail_unless!(f(20) == 30); @@ -241,7 +241,7 @@ pub mod tests { env: environment }; - let new_f: fn(int) -> int = cast::transmute(new_closure); + let new_f: &fn(int) -> int = cast::transmute(new_closure); fail_unless!(new_f(20) == 30); } } diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index 72c328d4613bc..690b3aedc5a49 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -79,7 +79,7 @@ pub unsafe fn local_data_set( */ pub unsafe fn local_data_modify( key: LocalDataKey, - modify_fn: fn(Option<@T>) -> Option<@T>) { + modify_fn: &fn(Option<@T>) -> Option<@T>) { local_modify(rt::rust_get_task(), key, modify_fn) } diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index f035916f59423..bb05520e1a363 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -176,7 +176,7 @@ pub unsafe fn local_set( pub unsafe fn local_modify( task: *rust_task, key: LocalDataKey, - modify_fn: fn(Option<@T>) -> Option<@T>) { + modify_fn: &fn(Option<@T>) -> Option<@T>) { // Could be more efficient by doing the lookup work, but this is easy. let newdata = modify_fn(local_pop(task, key)); diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 065feaebb5169..31c44531efec0 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -295,7 +295,7 @@ pub impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - fn future_result(&self, blk: fn(v: Port)) -> TaskBuilder { + fn future_result(&self, blk: &fn(v: Port)) -> TaskBuilder { // FIXME (#3725): 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 @@ -572,7 +572,7 @@ pub fn get_scheduler() -> Scheduler { * } * ~~~ */ -pub unsafe fn unkillable(f: fn() -> U) -> U { +pub unsafe fn unkillable(f: &fn() -> U) -> U { struct AllowFailure { t: *rust_task, drop { @@ -597,7 +597,7 @@ pub unsafe fn unkillable(f: fn() -> U) -> U { } /// The inverse of unkillable. Only ever to be used nested in unkillable(). -pub unsafe fn rekillable(f: fn() -> U) -> U { +pub unsafe fn rekillable(f: &fn() -> U) -> U { struct DisallowFailure { t: *rust_task, drop { @@ -625,7 +625,7 @@ pub unsafe fn rekillable(f: fn() -> U) -> U { * A stronger version of unkillable that also inhibits scheduling operations. * For use with exclusive ARCs, which use pthread mutexes directly. */ -pub unsafe fn atomically(f: fn() -> U) -> U { +pub unsafe fn atomically(f: &fn() -> U) -> U { struct DeferInterrupts { t: *rust_task, drop { diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 7b7ec769fa9a7..a0db252544156 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -108,7 +108,7 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) { let was_present = tasks.remove(&task); fail_unless!(was_present); } -pub fn taskset_each(tasks: &TaskSet, blk: fn(v: *rust_task) -> bool) { +pub fn taskset_each(tasks: &TaskSet, blk: &fn(v: *rust_task) -> bool) { tasks.each(|k| blk(*k)) } @@ -151,17 +151,17 @@ struct AncestorNode { mut ancestors: AncestorList, } -enum AncestorList = Option>; +struct AncestorList(Option>); // Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety. #[inline(always)] -fn access_group(x: &TaskGroupArc, blk: fn(TaskGroupInner) -> U) -> U { +fn access_group(x: &TaskGroupArc, blk: &fn(TaskGroupInner) -> U) -> U { unsafe { x.with(blk) } } #[inline(always)] fn access_ancestors(x: &unstable::Exclusive, - blk: fn(x: &mut AncestorNode) -> U) -> U { + blk: &fn(x: &mut AncestorNode) -> U) -> U { unsafe { x.with(blk) } } @@ -175,7 +175,7 @@ fn access_ancestors(x: &unstable::Exclusive, // allocations. Once that bug is fixed, changing the sigil should suffice. fn each_ancestor(list: &mut AncestorList, bail_opt: Option<@fn(TaskGroupInner)>, - forward_blk: fn(TaskGroupInner) -> bool) + forward_blk: &fn(TaskGroupInner) -> bool) -> bool { // "Kickoff" call - there was no last generation. return !coalesce(list, bail_opt, forward_blk, uint::max_value); @@ -184,7 +184,7 @@ fn each_ancestor(list: &mut AncestorList, // whether or not unwinding is needed (i.e., !successful iteration). fn coalesce(list: &mut AncestorList, bail_opt: Option<@fn(TaskGroupInner)>, - forward_blk: fn(TaskGroupInner) -> bool, + forward_blk: &fn(TaskGroupInner) -> bool, last_generation: uint) -> bool { // Need to swap the list out to use it, to appease borrowck. let tmp_list = util::replace(&mut *list, AncestorList(None)); @@ -288,7 +288,7 @@ fn each_ancestor(list: &mut AncestorList, // Wrapper around exclusive::with that appeases borrowck. fn with_parent_tg(parent_group: &mut Option, - blk: fn(TaskGroupInner) -> U) -> U { + blk: &fn(TaskGroupInner) -> U) -> U { // If this trips, more likely the problem is 'blk' failed inside. let tmp_arc = option::swap_unwrap(&mut *parent_group); let result = do access_group(&tmp_arc) |tg_opt| { blk(tg_opt) }; diff --git a/src/libcore/trie.rs b/src/libcore/trie.rs index 395772df57179..7dc85cba297f1 100644 --- a/src/libcore/trie.rs +++ b/src/libcore/trie.rs @@ -32,7 +32,7 @@ pub struct TrieMap { impl BaseIter<(uint, &'self T)> for TrieMap { /// Visit all key-value pairs in order #[inline(always)] - pure fn each(&self, f: fn(&(uint, &self/T)) -> bool) { + pure fn each(&self, f: &fn(&(uint, &self/T)) -> bool) { self.root.each(f); } #[inline(always)] @@ -42,7 +42,7 @@ impl BaseIter<(uint, &'self T)> for TrieMap { impl ReverseIter<(uint, &'self T)> for TrieMap { /// Visit all key-value pairs in reverse order #[inline(always)] - pure fn each_reverse(&self, f: fn(&(uint, &self/T)) -> bool) { + pure fn each_reverse(&self, f: &fn(&(uint, &self/T)) -> bool) { self.root.each_reverse(f); } } @@ -75,13 +75,16 @@ impl Map for TrieMap { /// Visit all keys in order #[inline(always)] - pure fn each_key(&self, f: fn(&uint) -> bool) { + pure fn each_key(&self, f: &fn(&uint) -> bool) { self.each(|&(k, _)| f(&k)) } /// Visit all values in order #[inline(always)] - pure fn each_value(&self, f: fn(&T) -> bool) { self.each(|&(_, v)| f(v)) } + pure fn each_value(&self, + f: &fn(&T) -> bool) { + self.each(|&(_, v)| f(v)) + } /// Return the value corresponding to the key in the map #[inline(hint)] @@ -138,18 +141,18 @@ impl TrieMap { impl TrieMap { /// Visit all keys in reverse order #[inline(always)] - pure fn each_key_reverse(&self, f: fn(&uint) -> bool) { + pure fn each_key_reverse(&self, f: &fn(&uint) -> bool) { self.each_reverse(|&(k, _)| f(&k)) } /// Visit all values in reverse order #[inline(always)] - pure fn each_value_reverse(&self, f: fn(&T) -> bool) { + pure fn each_value_reverse(&self, f: &fn(&T) -> bool) { self.each_reverse(|&(_, v)| f(v)) } /// Iterate over the map and mutate the contained values - fn mutate_values(&mut self, f: fn(uint, &mut T) -> bool) { + fn mutate_values(&mut self, f: &fn(uint, &mut T) -> bool) { self.root.mutate_values(f); } } @@ -160,13 +163,13 @@ pub struct TrieSet { impl BaseIter for TrieSet { /// Visit all values in order - pure fn each(&self, f: fn(&uint) -> bool) { self.map.each_key(f) } + pure fn each(&self, f: &fn(&uint) -> bool) { self.map.each_key(f) } pure fn size_hint(&self) -> Option { Some(self.len()) } } impl ReverseIter for TrieSet { /// Visit all values in reverse order - pure fn each_reverse(&self, f: fn(&uint) -> bool) { + pure fn each_reverse(&self, f: &fn(&uint) -> bool) { self.map.each_key_reverse(f) } } @@ -223,7 +226,7 @@ impl TrieNode { } impl TrieNode { - pure fn each(&self, f: fn(&(uint, &self/T)) -> bool) -> bool { + pure fn each(&self, f: &fn(&(uint, &self/T)) -> bool) -> bool { for uint::range(0, self.children.len()) |idx| { match self.children[idx] { Internal(ref x) => if !x.each(f) { return false }, @@ -234,7 +237,7 @@ impl TrieNode { true } - pure fn each_reverse(&self, f: fn(&(uint, &self/T)) -> bool) -> bool { + pure fn each_reverse(&self, f: &fn(&(uint, &self/T)) -> bool) -> bool { for uint::range_rev(self.children.len(), 0) |idx| { match self.children[idx - 1] { Internal(ref x) => if !x.each_reverse(f) { return false }, @@ -245,7 +248,7 @@ impl TrieNode { true } - fn mutate_values(&mut self, f: fn(uint, &mut T) -> bool) -> bool { + fn mutate_values(&mut self, f: &fn(uint, &mut T) -> bool) -> bool { for vec::each_mut(self.children) |child| { match *child { Internal(ref mut x) => if !x.mutate_values(f) { diff --git a/src/libcore/unstable.rs b/src/libcore/unstable.rs index 96cd732d815d5..4f45535d0f856 100644 --- a/src/libcore/unstable.rs +++ b/src/libcore/unstable.rs @@ -232,7 +232,7 @@ fn LittleLock() -> LittleLock { pub impl LittleLock { #[inline(always)] - unsafe fn lock(&self, f: fn() -> T) -> T { + unsafe fn lock(&self, f: &fn() -> T) -> T { struct Unlock { l: rust_little_lock, drop { @@ -284,7 +284,7 @@ pub impl Exclusive { // accessing the provided condition variable) are prohibited while inside // the exclusive. Supporting that is a work in progress. #[inline(always)] - unsafe fn with(&self, f: fn(x: &mut T) -> U) -> U { + unsafe fn with(&self, f: &fn(x: &mut T) -> U) -> U { unsafe { let rec = get_shared_mutable_state(&self.x); do (*rec).lock.lock { @@ -301,7 +301,7 @@ pub impl Exclusive { } #[inline(always)] - unsafe fn with_imm(&self, f: fn(x: &T) -> U) -> U { + unsafe fn with_imm(&self, f: &fn(x: &T) -> U) -> U { do self.with |x| { f(cast::transmute_immut(x)) } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 655db1c83d063..aed98f3573e71 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -175,7 +175,7 @@ pub pure fn with_capacity(capacity: uint) -> ~[T] { */ #[inline(always)] pub pure fn build_sized(size: uint, - builder: fn(push: pure fn(v: A))) -> ~[A] { + builder: &fn(push: &pure fn(v: A))) -> ~[A] { let mut vec = with_capacity(size); builder(|x| unsafe { vec.push(x) }); vec @@ -192,7 +192,7 @@ pub pure fn build_sized(size: uint, * onto the vector being constructed. */ #[inline(always)] -pub pure fn build(builder: fn(push: pure fn(v: A))) -> ~[A] { +pub pure fn build(builder: &fn(push: &pure fn(v: A))) -> ~[A] { build_sized(4, builder) } @@ -210,7 +210,7 @@ pub pure fn build(builder: fn(push: pure fn(v: A))) -> ~[A] { */ #[inline(always)] pub pure fn build_sized_opt(size: Option, - builder: fn(push: pure fn(v: A))) -> ~[A] { + builder: &fn(push: &pure fn(v: A))) -> ~[A] { build_sized(size.get_or_default(4), builder) } @@ -305,7 +305,7 @@ pub pure fn const_slice(v: &r/[const T], /// Copies /// Split the vector `v` by applying each element against the predicate `f`. -pub fn split(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn split(v: &[T], f: &fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -328,7 +328,7 @@ pub fn split(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { * Split the vector `v` by applying each element against the predicate `f` up * to `n` times. */ -pub fn splitn(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn splitn(v: &[T], n: uint, f: &fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -354,7 +354,7 @@ pub fn splitn(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { * Reverse split the vector `v` by applying each element against the predicate * `f`. */ -pub fn rsplit(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn rsplit(v: &[T], f: &fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0) { return ~[] } @@ -378,7 +378,7 @@ pub fn rsplit(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { * Reverse split the vector `v` by applying each element against the predicate * `f` up to `n times. */ -pub fn rsplitn(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn rsplitn(v: &[T], n: uint, f: &fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -405,7 +405,7 @@ pub fn rsplitn(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { * Partitions a vector into two new vectors: those that satisfies the * predicate, and those that do not. */ -pub fn partition(v: ~[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { +pub fn partition(v: ~[T], f: &fn(&T) -> bool) -> (~[T], ~[T]) { let mut lefts = ~[]; let mut rights = ~[]; @@ -426,7 +426,7 @@ pub fn partition(v: ~[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { * Partitions a vector into two new vectors: those that satisfies the * predicate, and those that do not. */ -pub pure fn partitioned(v: &[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { +pub pure fn partitioned(v: &[T], f: &fn(&T) -> bool) -> (~[T], ~[T]) { let mut lefts = ~[]; let mut rights = ~[]; @@ -535,7 +535,7 @@ pub fn remove(v: &mut ~[T], i: uint) -> T { v.pop() } -pub fn consume(mut v: ~[T], f: fn(uint, v: T)) { +pub fn consume(mut v: ~[T], f: &fn(uint, v: T)) { unsafe { do as_mut_buf(v) |p, ln| { for uint::range(0, ln) |i| { @@ -780,7 +780,7 @@ pub fn grow_set(v: &mut ~[T], index: uint, initval: &T, val: T) { // Functional utilities /// Apply a function to each element of a vector and return the results -pub pure fn map(v: &[T], f: fn(t: &T) -> U) -> ~[U] { +pub pure fn map(v: &[T], f: &fn(t: &T) -> U) -> ~[U] { let mut result = with_capacity(len(v)); for each(v) |elem| { unsafe { @@ -790,7 +790,7 @@ pub pure fn map(v: &[T], f: fn(t: &T) -> U) -> ~[U] { result } -pub fn map_consume(v: ~[T], f: fn(v: T) -> U) -> ~[U] { +pub fn map_consume(v: ~[T], f: &fn(v: T) -> U) -> ~[U] { let mut result = ~[]; do consume(v) |_i, x| { result.push(f(x)); @@ -799,7 +799,7 @@ pub fn map_consume(v: ~[T], f: fn(v: T) -> U) -> ~[U] { } /// Apply a function to each element of a vector and return the results -pub pure fn mapi(v: &[T], f: fn(uint, t: &T) -> U) -> ~[U] { +pub pure fn mapi(v: &[T], f: &fn(uint, t: &T) -> U) -> ~[U] { let mut i = 0; do map(v) |e| { i += 1; @@ -811,7 +811,7 @@ pub pure fn mapi(v: &[T], f: fn(uint, t: &T) -> U) -> ~[U] { * Apply a function to each element of a vector and return a concatenation * of each result vector */ -pub pure fn flat_map(v: &[T], f: fn(t: &T) -> ~[U]) -> ~[U] { +pub pure fn flat_map(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] { let mut result = ~[]; for each(v) |elem| { unsafe{ result.push_all_move(f(elem)); } } result @@ -819,7 +819,7 @@ pub pure fn flat_map(v: &[T], f: fn(t: &T) -> ~[U]) -> ~[U] { /// Apply a function to each pair of elements and return the results pub pure fn map2(v0: &[T], v1: &[U], - f: fn(t: &T, v: &U) -> V) -> ~[V] { + f: &fn(t: &T, v: &U) -> V) -> ~[V] { let v0_len = len(v0); if v0_len != len(v1) { fail!(); } let mut u: ~[V] = ~[]; @@ -833,7 +833,7 @@ pub pure fn map2(v0: &[T], v1: &[U], pub fn filter_map( v: ~[T], - f: fn(t: T) -> Option) -> ~[U] + f: &fn(t: T) -> Option) -> ~[U] { /*! * @@ -854,7 +854,7 @@ pub fn filter_map( pub pure fn filter_mapped( v: &[T], - f: fn(t: &T) -> Option) -> ~[U] + f: &fn(t: &T) -> Option) -> ~[U] { /*! * @@ -879,7 +879,7 @@ pub pure fn filter_mapped( * Apply function `f` to each element of `v` and return a vector containing * only those elements for which `f` returned true. */ -pub fn filter(v: ~[T], f: fn(t: &T) -> bool) -> ~[T] { +pub fn filter(v: ~[T], f: &fn(t: &T) -> bool) -> ~[T] { let mut result = ~[]; // FIXME (#4355 maybe): using v.consume here crashes // do v.consume |_, elem| { @@ -896,7 +896,7 @@ pub fn filter(v: ~[T], f: fn(t: &T) -> bool) -> ~[T] { * Apply function `f` to each element of `v` and return a vector containing * only those elements for which `f` returned true. */ -pub pure fn filtered(v: &[T], f: fn(t: &T) -> bool) -> ~[T] { +pub pure fn filtered(v: &[T], f: &fn(t: &T) -> bool) -> ~[T] { let mut result = ~[]; for each(v) |elem| { if f(elem) { unsafe { result.push(*elem); } } @@ -907,7 +907,7 @@ pub pure fn filtered(v: &[T], f: fn(t: &T) -> bool) -> ~[T] { /** * Like `filter()`, but in place. Preserves order of `v`. Linear time. */ -pub fn retain(v: &mut ~[T], f: pure fn(t: &T) -> bool) { +pub fn retain(v: &mut ~[T], f: &pure fn(t: &T) -> bool) { let len = v.len(); let mut deleted: uint = 0; @@ -963,7 +963,7 @@ pub pure fn connect(v: &[~[T]], sep: &T) -> ~[T] { * ~~~ * */ -pub pure fn foldl(z: T, v: &[U], p: fn(t: T, u: &U) -> T) -> T { +pub pure fn foldl(z: T, v: &[U], p: &fn(t: T, u: &U) -> T) -> T { let mut accum = z; let mut i = 0; let l = v.len(); @@ -995,7 +995,7 @@ pub pure fn foldl(z: T, v: &[U], p: fn(t: T, u: &U) -> T) -> T { * ~~~ * */ -pub pure fn foldr(v: &[T], z: U, p: fn(t: &T, u: U) -> U) -> U { +pub pure fn foldr(v: &[T], z: U, p: &fn(t: &T, u: U) -> U) -> U { let mut accum = z; for rev_each(v) |elt| { accum = p(elt, accum); @@ -1008,7 +1008,7 @@ pub pure fn foldr(v: &[T], z: U, p: fn(t: &T, u: U) -> U) -> U { * * If the vector contains no elements then false is returned. */ -pub pure fn any(v: &[T], f: fn(t: &T) -> bool) -> bool { +pub pure fn any(v: &[T], f: &fn(t: &T) -> bool) -> bool { for each(v) |elem| { if f(elem) { return true; } } false } @@ -1019,7 +1019,7 @@ pub pure fn any(v: &[T], f: fn(t: &T) -> bool) -> bool { * If the vectors contains no elements then false is returned. */ pub pure fn any2(v0: &[T], v1: &[U], - f: fn(a: &T, b: &U) -> bool) -> bool { + f: &fn(a: &T, b: &U) -> bool) -> bool { let v0_len = len(v0); let v1_len = len(v1); let mut i = 0u; @@ -1035,7 +1035,7 @@ pub pure fn any2(v0: &[T], v1: &[U], * * If the vector contains no elements then true is returned. */ -pub pure fn all(v: &[T], f: fn(t: &T) -> bool) -> bool { +pub pure fn all(v: &[T], f: &fn(t: &T) -> bool) -> bool { for each(v) |elem| { if !f(elem) { return false; } } true } @@ -1045,7 +1045,7 @@ pub pure fn all(v: &[T], f: fn(t: &T) -> bool) -> bool { * * If the vector contains no elements then true is returned. */ -pub pure fn alli(v: &[T], f: fn(uint, t: &T) -> bool) -> bool { +pub pure fn alli(v: &[T], f: &fn(uint, t: &T) -> bool) -> bool { for eachi(v) |i, elem| { if !f(i, elem) { return false; } } true } @@ -1056,7 +1056,7 @@ pub pure fn alli(v: &[T], f: fn(uint, t: &T) -> bool) -> bool { * If the vectors are not the same size then false is returned. */ pub pure fn all2(v0: &[T], v1: &[U], - f: fn(t: &T, u: &U) -> bool) -> bool { + f: &fn(t: &T, u: &U) -> bool) -> bool { let v0_len = len(v0); if v0_len != len(v1) { return false; } let mut i = 0u; @@ -1084,7 +1084,7 @@ pub pure fn count(v: &[T], x: &T) -> uint { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -pub pure fn find(v: &[T], f: fn(t: &T) -> bool) -> Option { +pub pure fn find(v: &[T], f: &fn(t: &T) -> bool) -> Option { find_between(v, 0u, len(v), f) } @@ -1096,7 +1096,7 @@ pub pure fn find(v: &[T], f: fn(t: &T) -> bool) -> Option { * the element is returned. If `f` matches no elements then none is returned. */ pub pure fn find_between(v: &[T], start: uint, end: uint, - f: fn(t: &T) -> bool) -> Option { + f: &fn(t: &T) -> bool) -> Option { position_between(v, start, end, f).map(|i| v[*i]) } @@ -1107,7 +1107,7 @@ pub pure fn find_between(v: &[T], start: uint, end: uint, * `f` returns true then an option containing the element is returned. If `f` * matches no elements then none is returned. */ -pub pure fn rfind(v: &[T], f: fn(t: &T) -> bool) -> Option { +pub pure fn rfind(v: &[T], f: &fn(t: &T) -> bool) -> Option { rfind_between(v, 0u, len(v), f) } @@ -1119,7 +1119,7 @@ pub pure fn rfind(v: &[T], f: fn(t: &T) -> bool) -> Option { * the element is returned. If `f` matches no elements then none is return. */ pub pure fn rfind_between(v: &[T], start: uint, end: uint, - f: fn(t: &T) -> bool) -> Option { + f: &fn(t: &T) -> bool) -> Option { rposition_between(v, start, end, f).map(|i| v[*i]) } @@ -1135,7 +1135,7 @@ pub pure fn position_elem(v: &[T], x: &T) -> Option { * then an option containing the index is returned. If `f` matches no elements * then none is returned. */ -pub pure fn position(v: &[T], f: fn(t: &T) -> bool) -> Option { +pub pure fn position(v: &[T], f: &fn(t: &T) -> bool) -> Option { position_between(v, 0u, len(v), f) } @@ -1147,7 +1147,7 @@ pub pure fn position(v: &[T], f: fn(t: &T) -> bool) -> Option { * the index is returned. If `f` matches no elements then none is returned. */ pub pure fn position_between(v: &[T], start: uint, end: uint, - f: fn(t: &T) -> bool) -> Option { + f: &fn(t: &T) -> bool) -> Option { fail_unless!(start <= end); fail_unless!(end <= len(v)); let mut i = start; @@ -1167,7 +1167,7 @@ pure fn rposition_elem(v: &[T], x: &T) -> Option { * `f` returns true then an option containing the index is returned. If `f` * matches no elements then none is returned. */ -pub pure fn rposition(v: &[T], f: fn(t: &T) -> bool) -> Option { +pub pure fn rposition(v: &[T], f: &fn(t: &T) -> bool) -> Option { rposition_between(v, 0u, len(v), f) } @@ -1180,7 +1180,7 @@ pub pure fn rposition(v: &[T], f: fn(t: &T) -> bool) -> Option { * returned. */ pub pure fn rposition_between(v: &[T], start: uint, end: uint, - f: fn(t: &T) -> bool) -> Option { + f: &fn(t: &T) -> bool) -> Option { fail_unless!(start <= end); fail_unless!(end <= len(v)); let mut i = end; @@ -1334,7 +1334,7 @@ pub pure fn reversed(v: &[const T]) -> ~[T] { * ~~~ */ #[inline(always)] -pub pure fn each(v: &r/[T], f: fn(&r/T) -> bool) { +pub pure fn each(v: &r/[T], f: &fn(&r/T) -> bool) { // ^^^^ // NB---this CANNOT be &[const T]! The reason // is that you are passing it to `f()` using @@ -1358,7 +1358,7 @@ pub pure fn each(v: &r/[T], f: fn(&r/T) -> bool) { /// a vector with mutable contents and you would like /// to mutate the contents as you iterate. #[inline(always)] -pub fn each_mut(v: &mut [T], f: fn(elem: &mut T) -> bool) { +pub fn each_mut(v: &mut [T], f: &fn(elem: &mut T) -> bool) { let mut i = 0; let n = v.len(); while i < n { @@ -1372,7 +1372,7 @@ pub fn each_mut(v: &mut [T], f: fn(elem: &mut T) -> bool) { /// Like `each()`, but for the case where you have a vector that *may or may /// not* have mutable contents. #[inline(always)] -pub pure fn each_const(v: &[const T], f: fn(elem: &const T) -> bool) { +pub pure fn each_const(v: &[const T], f: &fn(elem: &const T) -> bool) { let mut i = 0; let n = v.len(); while i < n { @@ -1389,7 +1389,7 @@ pub pure fn each_const(v: &[const T], f: fn(elem: &const T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn eachi(v: &r/[T], f: fn(uint, v: &r/T) -> bool) { +pub pure fn eachi(v: &r/[T], f: &fn(uint, v: &r/T) -> bool) { let mut i = 0; for each(v) |p| { if !f(i, p) { return; } @@ -1403,7 +1403,7 @@ pub pure fn eachi(v: &r/[T], f: fn(uint, v: &r/T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn rev_each(v: &r/[T], blk: fn(v: &r/T) -> bool) { +pub pure fn rev_each(v: &r/[T], blk: &fn(v: &r/T) -> bool) { rev_eachi(v, |_i, v| blk(v)) } @@ -1413,7 +1413,7 @@ pub pure fn rev_each(v: &r/[T], blk: fn(v: &r/T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn rev_eachi(v: &r/[T], blk: fn(i: uint, v: &r/T) -> bool) { +pub pure fn rev_eachi(v: &r/[T], blk: &fn(i: uint, v: &r/T) -> bool) { let mut i = v.len(); while i > 0 { i -= 1; @@ -1431,7 +1431,7 @@ pub pure fn rev_eachi(v: &r/[T], blk: fn(i: uint, v: &r/T) -> bool) { * Both vectors must have the same length */ #[inline] -pub pure fn each2(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) { +pub pure fn each2(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) { fail_unless!(len(v1) == len(v2)); for uint::range(0u, len(v1)) |i| { if !f(&v1[i], &v2[i]) { @@ -1450,7 +1450,7 @@ pub pure fn each2(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) { * The total number of permutations produced is `len(v)!`. If `v` contains * repeated elements, then some permutations are repeated. */ -pub pure fn each_permutation(v: &[T], put: fn(ts: &[T]) -> bool) { +pub pure fn each_permutation(v: &[T], put: &fn(ts: &[T]) -> bool) { let ln = len(v); if ln <= 1 { put(v); @@ -1497,7 +1497,7 @@ pub pure fn windowed(nn: uint, xx: &[TT]) -> ~[~[TT]] { #[inline(always)] pub pure fn as_imm_buf(s: &[T], /* NB---this CANNOT be const, see below */ - f: fn(*T, uint) -> U) -> U { + f: &fn(*T, uint) -> U) -> U { // NB---Do not change the type of s to `&[const T]`. This is // unsound. The reason is that we are going to create immutable pointers @@ -1516,7 +1516,7 @@ pub pure fn as_imm_buf(s: &[T], /// Similar to `as_imm_buf` but passing a `*const T` #[inline(always)] pub pure fn as_const_buf(s: &[const T], - f: fn(*const T, uint) -> U) -> U { + f: &fn(*const T, uint) -> U) -> U { unsafe { let v : *(*const T,uint) = @@ -1529,7 +1529,7 @@ pub pure fn as_const_buf(s: &[const T], /// Similar to `as_imm_buf` but passing a `*mut T` #[inline(always)] pub pure fn as_mut_buf(s: &mut [T], - f: fn(*mut T, uint) -> U) -> U { + f: &fn(*mut T, uint) -> U) -> U { unsafe { let v : *(*mut T,uint) = @@ -1721,13 +1721,13 @@ pub trait ImmutableVector { pure fn initn(&self, n: uint) -> &self/[T]; pure fn last(&self) -> &self/T; pure fn last_opt(&self) -> Option<&self/T>; - pure fn foldr(&self, z: U, p: fn(t: &T, u: U) -> U) -> U; - pure fn map(&self, f: fn(t: &T) -> U) -> ~[U]; - pure fn mapi(&self, f: fn(uint, t: &T) -> U) -> ~[U]; - fn map_r(&self, f: fn(x: &T) -> U) -> ~[U]; - pure fn alli(&self, f: fn(uint, t: &T) -> bool) -> bool; - pure fn flat_map(&self, f: fn(t: &T) -> ~[U]) -> ~[U]; - pure fn filter_mapped(&self, f: fn(t: &T) -> Option) -> ~[U]; + pure fn foldr(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U; + pure fn map(&self, f: &fn(t: &T) -> U) -> ~[U]; + pure fn mapi(&self, f: &fn(uint, t: &T) -> U) -> ~[U]; + fn map_r(&self, f: &fn(x: &T) -> U) -> ~[U]; + pure fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool; + pure fn flat_map(&self, f: &fn(t: &T) -> ~[U]) -> ~[U]; + pure fn filter_mapped(&self, f: &fn(t: &T) -> Option) -> ~[U]; } /// Extension methods for vectors @@ -1772,24 +1772,24 @@ impl ImmutableVector for &self/[T] { /// Reduce a vector from right to left #[inline] - pure fn foldr(&self, z: U, p: fn(t: &T, u: U) -> U) -> U { + pure fn foldr(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U { foldr(*self, z, p) } /// Apply a function to each element of a vector and return the results #[inline] - pure fn map(&self, f: fn(t: &T) -> U) -> ~[U] { map(*self, f) } + pure fn map(&self, f: &fn(t: &T) -> U) -> ~[U] { map(*self, f) } /** * Apply a function to the index and value of each element in the vector * and return the results */ - pure fn mapi(&self, f: fn(uint, t: &T) -> U) -> ~[U] { + pure fn mapi(&self, f: &fn(uint, t: &T) -> U) -> ~[U] { mapi(*self, f) } #[inline] - fn map_r(&self, f: fn(x: &T) -> U) -> ~[U] { + fn map_r(&self, f: &fn(x: &T) -> U) -> ~[U] { let mut r = ~[]; let mut i = 0; while i < self.len() { @@ -1804,7 +1804,7 @@ impl ImmutableVector for &self/[T] { * * If the vector is empty, true is returned. */ - pure fn alli(&self, f: fn(uint, t: &T) -> bool) -> bool { + pure fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool { alli(*self, f) } /** @@ -1812,7 +1812,7 @@ impl ImmutableVector for &self/[T] { * of each result vector */ #[inline] - pure fn flat_map(&self, f: fn(t: &T) -> ~[U]) -> ~[U] { + pure fn flat_map(&self, f: &fn(t: &T) -> ~[U]) -> ~[U] { flat_map(*self, f) } /** @@ -1822,15 +1822,15 @@ impl ImmutableVector for &self/[T] { * the resulting vector. */ #[inline] - pure fn filter_mapped(&self, f: fn(t: &T) -> Option) -> ~[U] { + pure fn filter_mapped(&self, f: &fn(t: &T) -> Option) -> ~[U] { filter_mapped(*self, f) } } pub trait ImmutableEqVector { - pure fn position(&self, f: fn(t: &T) -> bool) -> Option; + pure fn position(&self, f: &fn(t: &T) -> bool) -> Option; pure fn position_elem(&self, t: &T) -> Option; - pure fn rposition(&self, f: fn(t: &T) -> bool) -> Option; + pure fn rposition(&self, f: &fn(t: &T) -> bool) -> Option; pure fn rposition_elem(&self, t: &T) -> Option; } @@ -1843,7 +1843,7 @@ impl ImmutableEqVector for &self/[T] { * elements then none is returned. */ #[inline] - pure fn position(&self, f: fn(t: &T) -> bool) -> Option { + pure fn position(&self, f: &fn(t: &T) -> bool) -> Option { position(*self, f) } @@ -1861,7 +1861,7 @@ impl ImmutableEqVector for &self/[T] { * returned. If `f` matches no elements then none is returned. */ #[inline] - pure fn rposition(&self, f: fn(t: &T) -> bool) -> Option { + pure fn rposition(&self, f: &fn(t: &T) -> bool) -> Option { rposition(*self, f) } @@ -1873,9 +1873,9 @@ impl ImmutableEqVector for &self/[T] { } pub trait ImmutableCopyableVector { - pure fn filtered(&self, f: fn(&T) -> bool) -> ~[T]; - pure fn rfind(&self, f: fn(t: &T) -> bool) -> Option; - pure fn partitioned(&self, f: fn(&T) -> bool) -> (~[T], ~[T]); + pure fn filtered(&self, f: &fn(&T) -> bool) -> ~[T]; + pure fn rfind(&self, f: &fn(t: &T) -> bool) -> Option; + pure fn partitioned(&self, f: &fn(&T) -> bool) -> (~[T], ~[T]); } /// Extension methods for vectors @@ -1888,7 +1888,7 @@ impl ImmutableCopyableVector for &self/[T] { * containing only those elements for which `f` returned true. */ #[inline] - pure fn filtered(&self, f: fn(t: &T) -> bool) -> ~[T] { + pure fn filtered(&self, f: &fn(t: &T) -> bool) -> ~[T] { filtered(*self, f) } @@ -1900,7 +1900,7 @@ impl ImmutableCopyableVector for &self/[T] { * returned. If `f` matches no elements then none is returned. */ #[inline] - pure fn rfind(&self, f: fn(t: &T) -> bool) -> Option { + pure fn rfind(&self, f: &fn(t: &T) -> bool) -> Option { rfind(*self, f) } @@ -1909,7 +1909,7 @@ impl ImmutableCopyableVector for &self/[T] { * those that do not. */ #[inline] - pure fn partitioned(&self, f: fn(&T) -> bool) -> (~[T], ~[T]) { + pure fn partitioned(&self, f: &fn(&T) -> bool) -> (~[T], ~[T]) { partitioned(*self, f) } } @@ -1924,10 +1924,10 @@ pub trait OwnedVector { fn remove(&mut self, i: uint) -> T; fn swap_remove(&mut self, index: uint) -> T; fn truncate(&mut self, newlen: uint); - fn retain(&mut self, f: pure fn(t: &T) -> bool); - fn consume(self, f: fn(uint, v: T)); - fn filter(self, f: fn(t: &T) -> bool) -> ~[T]; - fn partition(self, f: pure fn(&T) -> bool) -> (~[T], ~[T]); + fn retain(&mut self, f: &pure fn(t: &T) -> bool); + fn consume(self, f: &fn(uint, v: T)); + fn filter(self, f: &fn(t: &T) -> bool) -> ~[T]; + fn partition(self, f: &pure fn(&T) -> bool) -> (~[T], ~[T]); fn grow_fn(&mut self, n: uint, op: iter::InitOp); } @@ -1978,17 +1978,17 @@ impl OwnedVector for ~[T] { } #[inline] - fn retain(&mut self, f: pure fn(t: &T) -> bool) { + fn retain(&mut self, f: &pure fn(t: &T) -> bool) { retain(self, f); } #[inline] - fn consume(self, f: fn(uint, v: T)) { + fn consume(self, f: &fn(uint, v: T)) { consume(self, f) } #[inline] - fn filter(self, f: fn(&T) -> bool) -> ~[T] { + fn filter(self, f: &fn(&T) -> bool) -> ~[T] { filter(self, f) } @@ -1997,7 +1997,7 @@ impl OwnedVector for ~[T] { * those that do not. */ #[inline] - fn partition(self, f: fn(&T) -> bool) -> (~[T], ~[T]) { + fn partition(self, f: &fn(&T) -> bool) -> (~[T], ~[T]) { partition(self, f) } @@ -2138,7 +2138,7 @@ pub mod raw { #[inline(always)] pub unsafe fn buf_as_slice(p: *T, len: uint, - f: fn(v: &[T]) -> U) -> U { + f: &fn(v: &[T]) -> U) -> U { let pair = (p, len * sys::nonzero_size_of::()); let v : *(&blk/[T]) = ::cast::reinterpret_cast(&addr_of(&pair)); @@ -2270,7 +2270,9 @@ pub mod bytes { impl iter::BaseIter for &self/[A] { #[inline(always)] - pure fn each(&self, blk: fn(v: &'self A) -> bool) { each(*self, blk) } + pub pure fn each(&self, blk: &fn(v: &'self A) -> bool) { + each(*self, blk) + } #[inline(always)] pure fn size_hint(&self) -> Option { Some(self.len()) } } @@ -2278,7 +2280,7 @@ impl iter::BaseIter for &self/[A] { // FIXME(#4148): This should be redundant impl iter::BaseIter for ~[A] { #[inline(always)] - pure fn each(&self, blk: fn(v: &'self A) -> bool) { each(*self, blk) } + pure fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } #[inline(always)] pure fn size_hint(&self) -> Option { Some(self.len()) } } @@ -2286,31 +2288,31 @@ impl iter::BaseIter for ~[A] { // FIXME(#4148): This should be redundant impl iter::BaseIter for @[A] { #[inline(always)] - pure fn each(&self, blk: fn(v: &'self A) -> bool) { each(*self, blk) } + pure fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } #[inline(always)] pure fn size_hint(&self) -> Option { Some(self.len()) } } impl iter::ExtendedIter for &self/[A] { - pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { + pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } - pub pure fn all(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } - pub pure fn any(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } - pub pure fn foldl(&self, b0: B, blk: fn(&B, &A) -> B) -> B { + pub pure fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } - pub pure fn position(&self, f: fn(&A) -> bool) -> Option { + pub pure fn position(&self, f: &fn(&A) -> bool) -> Option { iter::position(self, f) } - pure fn map_to_vec(&self, op: fn(&A) -> B) -> ~[B] { + pure fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } - pure fn flat_map_to_vec>(&self, op: fn(&A) -> IB) + pure fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } @@ -2318,25 +2320,25 @@ impl iter::ExtendedIter for &self/[A] { // FIXME(#4148): This should be redundant impl iter::ExtendedIter for ~[A] { - pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { + pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } - pub pure fn all(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } - pub pure fn any(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } - pub pure fn foldl(&self, b0: B, blk: fn(&B, &A) -> B) -> B { + pub pure fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } - pub pure fn position(&self, f: fn(&A) -> bool) -> Option { + pub pure fn position(&self, f: &fn(&A) -> bool) -> Option { iter::position(self, f) } - pure fn map_to_vec(&self, op: fn(&A) -> B) -> ~[B] { + pure fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } - pure fn flat_map_to_vec>(&self, op: fn(&A) -> IB) + pure fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } @@ -2344,25 +2346,25 @@ impl iter::ExtendedIter for ~[A] { // FIXME(#4148): This should be redundant impl iter::ExtendedIter for @[A] { - pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { + pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } - pub pure fn all(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } - pub pure fn any(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } - pub pure fn foldl(&self, b0: B, blk: fn(&B, &A) -> B) -> B { + pub pure fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } - pub pure fn position(&self, f: fn(&A) -> bool) -> Option { + pub pure fn position(&self, f: &fn(&A) -> bool) -> Option { iter::position(self, f) } - pure fn map_to_vec(&self, op: fn(&A) -> B) -> ~[B] { + pure fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } - pure fn flat_map_to_vec>(&self, op: fn(&A) -> IB) + pure fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } @@ -2386,33 +2388,33 @@ impl iter::EqIter for @[A] { } impl iter::CopyableIter for &self/[A] { - pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { + pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } - pub pure fn find(&self, f: fn(&A) -> bool) -> Option { + pub pure fn find(&self, f: &fn(&A) -> bool) -> Option { iter::find(self, f) } } // FIXME(#4148): This should be redundant impl iter::CopyableIter for ~[A] { - pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { + pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } - pub pure fn find(&self, f: fn(&A) -> bool) -> Option { + pub pure fn find(&self, f: &fn(&A) -> bool) -> Option { iter::find(self, f) } } // FIXME(#4148): This should be redundant impl iter::CopyableIter for @[A] { - pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { + pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } - pub pure fn find(&self, f: fn(&A) -> bool) -> Option { + pub pure fn find(&self, f: &fn(&A) -> bool) -> Option { iter::find(self, f) } } @@ -2435,7 +2437,7 @@ impl iter::CopyableOrderedIter for @[A] { } impl iter::CopyableNonstrictIter for &self/[A] { - pure fn each_val(&const self, f: fn(A) -> bool) { + pure fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { if !f(copy self[i]) { break; } @@ -2446,7 +2448,7 @@ impl iter::CopyableNonstrictIter for &self/[A] { // FIXME(#4148): This should be redundant impl iter::CopyableNonstrictIter for ~[A] { - pure fn each_val(&const self, f: fn(A) -> bool) { + pure fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { if !f(copy self[i]) { break; } @@ -2457,7 +2459,7 @@ impl iter::CopyableNonstrictIter for ~[A] { // FIXME(#4148): This should be redundant impl iter::CopyableNonstrictIter for @[A] { - pure fn each_val(&const self, f: fn(A) -> bool) { + pure fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { if !f(copy self[i]) { break; } diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index f21029a8a4f0f..90ada832327f4 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -247,7 +247,7 @@ pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty, *crate2 } -pub fn under(n: uint, it: fn(uint)) { +pub fn under(n: uint, it: &fn(uint)) { let mut i: uint = 0u; while i < n { it(i); i += 1u; } } diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index eaac7dd1a0b54..fec3f77668137 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -153,7 +153,7 @@ pub mod jit { code: entry, env: ptr::null() }; - let func: fn(++argv: ~[~str]) = cast::transmute(closure); + let func: &fn(++argv: ~[~str]) = cast::transmute(closure); func(~[/*bad*/copy sess.opts.binary]); } diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index e7e29ec6c72d5..2b61c9480457d 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -164,7 +164,7 @@ pub fn parse_input(sess: Session, +cfg: ast::crate_cfg, input: input) } } -pub fn time(do_it: bool, what: ~str, thunk: fn() -> T) -> T { +pub fn time(do_it: bool, what: ~str, thunk: &fn() -> T) -> T { if !do_it { return thunk(); } let start = std::time::precise_time_s(); let rv = thunk(); diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 52426401d7927..d2d0ceff6331d 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -306,7 +306,7 @@ pub fn basic_options() -> @options { // Seems out of place, but it uses session, so I'm putting it here pub fn expect(sess: Session, opt: Option, - msg: fn() -> ~str) + msg: &fn() -> ~str) -> T { diagnostic::expect(sess.diagnostic(), opt, msg) } diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index 00cb977b50c83..47ee477210b78 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -155,7 +155,7 @@ pub fn get_static_methods_if_impl(cstore: @mut cstore::CStore, pub fn get_item_attrs(cstore: @mut cstore::CStore, def_id: ast::def_id, - f: fn(~[@ast::meta_item])) { + f: &fn(~[@ast::meta_item])) { let cdata = cstore::get_crate_data(cstore, def_id.crate); decoder::get_item_attrs(cdata, def_id.node, f) } diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 2f82d99420c1a..0909a4437369d 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -88,7 +88,7 @@ pub fn have_crate_data(cstore: @mut CStore, cnum: ast::crate_num) -> bool { } pub fn iter_crate_data(cstore: @mut CStore, - i: fn(ast::crate_num, @crate_metadata)) { + i: &fn(ast::crate_num, @crate_metadata)) { let metas = cstore.metas; for metas.each |&k, &v| { i(k, v); diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 4fe708d1020cd..2643012d30ae2 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -48,7 +48,7 @@ type cmd = @crate_metadata; // what crate that's in and give us a def_id that makes sense for the current // build. -fn lookup_hash(d: ebml::Doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) -> +fn lookup_hash(d: ebml::Doc, eq_fn: &fn(x:&[u8]) -> bool, hash: uint) -> Option { let index = reader::get_doc(d, tag_index); let table = reader::get_doc(index, tag_index_table); @@ -193,7 +193,7 @@ fn item_def_id(d: ebml::Doc, cdata: cmd) -> ast::def_id { |d| parse_def_id(d))); } -fn each_reexport(d: ebml::Doc, f: fn(ebml::Doc) -> bool) { +fn each_reexport(d: ebml::Doc, f: &fn(ebml::Doc) -> bool) { for reader::tagged_docs(d, tag_items_data_item_reexport) |reexport_doc| { if !f(reexport_doc) { return; @@ -451,7 +451,7 @@ pub fn each_lang_item(cdata: cmd, f: &fn(ast::node_id, uint) -> bool) { /// Iterates over all the paths in the given crate. pub fn each_path(intr: @ident_interner, cdata: cmd, get_crate_data: GetCrateDataCb, - f: fn(&str, def_like) -> bool) { + f: &fn(&str, def_like) -> bool) { let root = reader::Doc(cdata.data); let items = reader::get_doc(root, tag_items); let items_data = reader::get_doc(items, tag_items_data); @@ -855,7 +855,7 @@ pub fn get_static_methods_if_impl(intr: @ident_interner, pub fn get_item_attrs(cdata: cmd, node_id: ast::node_id, - f: fn(~[@ast::meta_item])) { + f: &fn(~[@ast::meta_item])) { let item = lookup_item(node_id, cdata.data); for reader::tagged_docs(item, tag_attributes) |attributes| { @@ -1093,7 +1093,7 @@ pub fn get_crate_vers(data: @~[u8]) -> @~str { fn iter_crate_items(intr: @ident_interner, cdata: cmd, get_crate_data: GetCrateDataCb, - proc: fn(path: &str, ast::def_id)) { + proc: &fn(path: &str, ast::def_id)) { for each_path(intr, cdata, get_crate_data) |path_string, def_like| { match def_like { dl_impl(*) | dl_field => {} diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 414aa035b5497..fc42ac2ffedb9 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1054,7 +1054,7 @@ fn create_index(index: ~[entry]) -> } fn encode_index(ebml_w: writer::Encoder, buckets: ~[@~[entry]], - write_fn: fn(io::Writer, T)) { + write_fn: &fn(io::Writer, T)) { let writer = ebml_w.writer; ebml_w.start_tag(tag_index); let mut bucket_locs: ~[uint] = ~[]; diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 08b9facf48613..63b14cc51be1c 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -217,7 +217,7 @@ fn parse_region(st: @mut PState) -> ty::Region { } } -fn parse_opt(st: @mut PState, f: fn() -> T) -> Option { +fn parse_opt(st: @mut PState, f: &fn() -> T) -> Option { match next(st) { 'n' => None, 's' => Some(f()), diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index caad6335ce512..b9cb0b1d4b5a3 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -122,7 +122,7 @@ fn enc_mt(w: io::Writer, cx: @ctxt, mt: ty::mt) { enc_ty(w, cx, mt.ty); } -fn enc_opt(w: io::Writer, t: Option, enc_f: fn(T)) { +fn enc_opt(w: io::Writer, t: Option, enc_f: &fn(T)) { match &t { &None => w.write_char('n'), &Some(ref v) => { diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 48fddec00797a..c1a8f79b9b131 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -795,12 +795,12 @@ impl ebml_writer_helpers for writer::Encoder { } trait write_tag_and_id { - fn tag(&self, tag_id: c::astencode_tag, f: fn()); + fn tag(&self, tag_id: c::astencode_tag, f: &fn()); fn id(&self, id: ast::node_id); } impl write_tag_and_id for writer::Encoder { - fn tag(&self, tag_id: c::astencode_tag, f: fn()) { + fn tag(&self, tag_id: c::astencode_tag, f: &fn()) { do self.wr_tag(tag_id as uint) { f() } } diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 5462ec87014e2..3e63707162417 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -510,7 +510,7 @@ pub impl BorrowckCtxt { method_map: self.method_map} } - fn cat_pattern(&self, cmt: cmt, pat: @ast::pat, op: fn(cmt, @ast::pat)) { + fn cat_pattern(&self, cmt: cmt, pat: @ast::pat, op: &fn(cmt, @ast::pat)) { let mc = self.mc_ctxt(); mc.cat_pattern(cmt, pat, op); } diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 84de194915ad0..48d136ce65f36 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -95,7 +95,7 @@ type check_fn = @fn(Context, @freevar_entry); // Yields the appropriate function to check the kind of closed over // variables. `id` is the node_id for some expression that creates the // closure. -fn with_appropriate_checker(cx: Context, id: node_id, b: fn(check_fn)) { +fn with_appropriate_checker(cx: Context, id: node_id, b: &fn(check_fn)) { fn check_for_uniq(cx: Context, fv: @freevar_entry) { // all captured data must be owned, regardless of whether it is // moved in or copied in. diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 2bd08f109812f..93f0557028eae 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -77,6 +77,7 @@ pub enum lint { default_methods, deprecated_self, deprecated_mutable_fields, + deprecated_drop, managed_heap_memory, owned_heap_memory, @@ -251,6 +252,13 @@ pub fn get_lint_dict() -> LintDict { default: deny }), + (@~"deprecated_drop", + @LintSpec { + lint: deprecated_drop, + desc: "deprecated \"drop\" notation for the destructor", + default: deny + }), + /* FIXME(#3266)--make liveness warnings lintable (@~"unused_variable", @LintSpec { @@ -342,7 +350,7 @@ pub impl Context { * current lint context, call the provided function, then reset the * lints in effect to their previous state. */ - fn with_lint_attrs(&self, attrs: ~[ast::attribute], f: fn(Context)) { + fn with_lint_attrs(&self, attrs: ~[ast::attribute], f: &fn(Context)) { let mut new_ctxt = *self; let mut triples = ~[]; @@ -483,6 +491,7 @@ fn check_item(i: @ast::item, cx: ty::ctxt) { check_item_default_methods(cx, i); check_item_deprecated_self(cx, i); check_item_deprecated_mutable_fields(cx, i); + check_item_deprecated_drop(cx, i); } // Take a visitor, and modify it so that it will not proceed past subitems. @@ -720,6 +729,26 @@ fn check_item_deprecated_mutable_fields(cx: ty::ctxt, item: @ast::item) { } } +fn check_item_deprecated_drop(cx: ty::ctxt, item: @ast::item) { + match item.node { + ast::item_struct(struct_def, _) => { + match struct_def.dtor { + None => {} + Some(ref dtor) => { + cx.sess.span_lint(deprecated_drop, + item.id, + item.id, + dtor.span, + ~"`drop` notation for destructors is \ + deprecated; implement the `Drop` \ + trait instead"); + } + } + } + _ => {} + } +} + fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id, diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 068327dc74167..0c17b371694c4 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -137,8 +137,8 @@ use syntax::{visit, ast_util}; // if it detects an outstanding loan (that is, the addr is taken). pub type last_use_map = HashMap; -enum Variable = uint; -enum LiveNode = uint; +struct Variable(uint); +struct LiveNode(uint); impl cmp::Eq for Variable { pure fn eq(&self, other: &Variable) -> bool { *(*self) == *(*other) } @@ -735,7 +735,7 @@ pub impl Liveness { } } - fn pat_bindings(&self, pat: @pat, f: fn(LiveNode, Variable, span)) { + fn pat_bindings(&self, pat: @pat, f: &fn(LiveNode, Variable, span)) { let def_map = self.tcx.def_map; do pat_util::pat_bindings(def_map, pat) |_bm, p_id, sp, _n| { let ln = self.live_node(p_id, sp); @@ -745,7 +745,7 @@ pub impl Liveness { } fn arm_pats_bindings(&self, - pats: &[@pat], f: fn(LiveNode, Variable, span)) { + pats: &[@pat], f: &fn(LiveNode, Variable, span)) { // only consider the first pattern; any later patterns must have // the same bindings, and we also consider the first pattern to be // the "authoratative" set of ids @@ -809,15 +809,14 @@ pub impl Liveness { self.assigned_on_entry(copy self.successors[*ln], var) } - fn indices(&self, ln: LiveNode, op: fn(uint)) { + fn indices(&self, ln: LiveNode, op: &fn(uint)) { let node_base_idx = self.idx(ln, Variable(0)); for uint::range(0, self.ir.num_vars) |var_idx| { op(node_base_idx + var_idx) } } - fn indices2(&self, ln: LiveNode, succ_ln: LiveNode, - op: fn(uint, uint)) { + fn indices2(&self, ln: LiveNode, succ_ln: LiveNode, op: &fn(uint, uint)) { let node_base_idx = self.idx(ln, Variable(0u)); let succ_base_idx = self.idx(succ_ln, Variable(0u)); for uint::range(0u, self.ir.num_vars) |var_idx| { @@ -827,7 +826,7 @@ pub impl Liveness { fn write_vars(&self, wr: io::Writer, ln: LiveNode, - test: fn(uint) -> LiveNode) { + test: &fn(uint) -> LiveNode) { let node_base_idx = self.idx(ln, Variable(0)); for uint::range(0, self.ir.num_vars) |var_idx| { let idx = node_base_idx + var_idx; @@ -1510,7 +1509,7 @@ pub impl Liveness { fn with_loop_nodes(&self, loop_node_id: node_id, break_ln: LiveNode, cont_ln: LiveNode, - f: fn() -> R) -> R { + f: &fn() -> R) -> R { debug!("with_loop_nodes: %d %u", loop_node_id, *break_ln); self.loop_scope.push(loop_node_id); self.break_ln.insert(loop_node_id, break_ln); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 85ff970be1cac..9e0ecb5a21859 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -856,7 +856,7 @@ pub impl mem_categorization_ctxt { fn cat_pattern(&self, cmt: cmt, pat: @ast::pat, - op: fn(cmt, @ast::pat)) + op: &fn(cmt, @ast::pat)) { // Here, `cmt` is the categorization for the value being // matched and pat is the pattern it is being matched against. diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index 77ad7df531978..4522977a4ab12 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -72,7 +72,7 @@ pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @pat) -> bool { } pub fn pat_bindings(dm: resolve::DefMap, pat: @pat, - it: fn(binding_mode, node_id, span, @path)) { + it: &fn(binding_mode, node_id, span, @path)) { do walk_pat(pat) |p| { match p.node { pat_ident(binding_mode, pth, _) if pat_is_binding(dm, p) => { diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index d1e35f7a19df2..7ac559161af4f 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -3241,7 +3241,7 @@ pub impl Resolver { // generate a fake "implementation scope" containing all the // implementations thus found, for compatibility with old resolve pass. - fn with_scope(@mut self, name: Option, f: fn()) { + fn with_scope(@mut self, name: Option, f: &fn()) { let orig_module = self.current_module; // Move down in the graph. @@ -3661,7 +3661,7 @@ pub impl Resolver { fn with_type_parameter_rib(@mut self, type_parameters: TypeParameters, - f: fn()) { + f: &fn()) { match type_parameters { HasTypeParameters(generics, node_id, initial_index, rib_kind) => { @@ -3702,13 +3702,13 @@ pub impl Resolver { } } - fn with_label_rib(@mut self, f: fn()) { + fn with_label_rib(@mut self, f: &fn()) { self.label_ribs.push(@Rib(NormalRibKind)); f(); self.label_ribs.pop(); } - fn with_constant_rib(@mut self, f: fn()) { + fn with_constant_rib(@mut self, f: &fn()) { self.value_ribs.push(@Rib(ConstantItemRibKind)); f(); self.value_ribs.pop(); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 7af1fcc7e779b..d4ed0004c8f9b 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -728,8 +728,8 @@ pub fn cast_shift_const_rhs(op: ast::binop, pub fn cast_shift_rhs(op: ast::binop, lhs: ValueRef, rhs: ValueRef, - trunc: fn(ValueRef, TypeRef) -> ValueRef, - zext: fn(ValueRef, TypeRef) -> ValueRef) + trunc: &fn(ValueRef, TypeRef) -> ValueRef, + zext: &fn(ValueRef, TypeRef) -> ValueRef) -> ValueRef { // Shifts may have any size int on the rhs unsafe { @@ -863,7 +863,7 @@ pub fn have_cached_lpad(bcx: block) -> bool { return res; } -pub fn in_lpad_scope_cx(bcx: block, f: fn(+si: &mut scope_info)) { +pub fn in_lpad_scope_cx(bcx: block, f: &fn(+si: &mut scope_info)) { let mut bcx = bcx; loop { { @@ -1326,7 +1326,7 @@ pub fn leave_block(bcx: block, out_of: block) -> block { pub fn with_scope(bcx: block, opt_node_info: Option, +name: ~str, - f: fn(block) -> block) -> block { + f: &fn(block) -> block) -> block { let _icx = bcx.insn_ctxt("with_scope"); debug!("with_scope(bcx=%s, opt_node_info=%?, name=%s)", @@ -1341,7 +1341,7 @@ pub fn with_scope(bcx: block, pub fn with_scope_result(bcx: block, opt_node_info: Option, +name: ~str, - f: fn(block) -> Result) -> Result { + f: &fn(block) -> Result) -> Result { let _icx = bcx.insn_ctxt("with_scope_result"); let scope_cx = scope_block(bcx, opt_node_info, name); Br(bcx, scope_cx.llbb); @@ -1350,7 +1350,7 @@ pub fn with_scope_result(bcx: block, } pub fn with_scope_datumblock(bcx: block, opt_node_info: Option, - +name: ~str, f: fn(block) -> datum::DatumBlock) + +name: ~str, f: &fn(block) -> datum::DatumBlock) -> datum::DatumBlock { use middle::trans::datum::DatumBlock; @@ -1361,7 +1361,7 @@ pub fn with_scope_datumblock(bcx: block, opt_node_info: Option, DatumBlock {bcx: leave_block(bcx, scope_cx), datum: datum} } -pub fn block_locals(b: &ast::blk, it: fn(@ast::local)) { +pub fn block_locals(b: &ast::blk, it: &fn(@ast::local)) { for vec::each(b.node.stmts) |s| { match s.node { ast::stmt_decl(d, _) => { @@ -1401,7 +1401,7 @@ pub fn alloc_local(cx: block, local: @ast::local) -> block { } -pub fn with_cond(bcx: block, val: ValueRef, f: fn(block) -> block) -> block { +pub fn with_cond(bcx: block, val: ValueRef, f: &fn(block) -> block) -> block { let _icx = bcx.insn_ctxt("with_cond"); let next_cx = base::sub_block(bcx, ~"next"); let cond_cx = base::sub_block(bcx, ~"cond"); @@ -1742,8 +1742,8 @@ pub fn trans_closure(ccx: @CrateContext, param_substs: Option<@param_substs>, id: ast::node_id, impl_id: Option, - maybe_load_env: fn(fn_ctxt), - finish: fn(block)) { + maybe_load_env: &fn(fn_ctxt), + finish: &fn(block)) { ccx.stats.n_closures += 1; let _icx = ccx.insn_ctxt("trans_closure"); set_uwtable(llfndecl); diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs index 1d7314f751870..7e159ef606242 100644 --- a/src/librustc/middle/trans/cabi.rs +++ b/src/librustc/middle/trans/cabi.rs @@ -37,7 +37,7 @@ pub struct FnType { } pub impl FnType { - fn decl_fn(&self, decl: fn(fnty: TypeRef) -> ValueRef) -> ValueRef { + fn decl_fn(&self, decl: &fn(fnty: TypeRef) -> ValueRef) -> ValueRef { let atys = vec::map(self.arg_tys, |t| t.ty); let rty = self.ret_ty.ty; let fnty = T_fn(atys, rty); diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 54b10e2ad5c62..d5877ec563123 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -346,7 +346,7 @@ fn x86_64_tys(atys: &[TypeRef], } fn x86_64_ty(ty: TypeRef, - is_mem_cls: fn(cls: &[x86_64_reg_class]) -> bool, + is_mem_cls: &fn(cls: &[x86_64_reg_class]) -> bool, attr: Attribute) -> (LLVMType, Option) { let mut cast = false; let mut ty_attr = option::None; diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index d4ff0d74a47b7..9e38252dc9a8a 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -438,7 +438,7 @@ pub fn trans_call_inner( call_info: Option, fn_expr_ty: ty::t, ret_ty: ty::t, - get_callee: fn(block) -> Callee, + get_callee: &fn(block) -> Callee, args: CallArgs, dest: expr::Dest, autoref_arg: AutorefArg) -> block { diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 556c15c446d2f..11d3e1552028f 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -515,7 +515,7 @@ pub impl Datum { fn get_element(&self, bcx: block, ty: ty::t, source: DatumCleanup, - gep: fn(ValueRef) -> ValueRef) -> Datum { + gep: &fn(ValueRef) -> ValueRef) -> Datum { let base_val = self.to_ref_llval(bcx); Datum { val: gep(base_val), diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 02b68afff4a82..af54d4734314c 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -190,7 +190,7 @@ fn md_from_metadata(val: debug_metadata) -> T { fn cached_metadata(cache: metadata_cache, mdtag: int, - eq_fn: fn(md: T) -> bool) + eq_fn: &fn(md: T) -> bool) -> Option { unsafe { if cache.contains_key(&mdtag) { diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index b7942fa66dbbd..e38b0be7bccba 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -1135,7 +1135,7 @@ pub fn trans_local_var(bcx: block, def: ast::def) -> Datum { pub fn with_field_tys(tcx: ty::ctxt, ty: ty::t, node_id_opt: Option, - op: fn(int, (&[ty::field])) -> R) -> R { + op: &fn(int, (&[ty::field])) -> R) -> R { match ty::get(ty).sty { ty::ty_struct(did, ref substs) => { op(0, struct_mutable_fields(tcx, did, substs)) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 978b1ed16d841..b4ef87491a8a3 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -582,18 +582,20 @@ pub enum param_bound { } #[deriving_eq] -pub enum TyVid = uint; +pub struct TyVid(uint); #[deriving_eq] -pub enum IntVid = uint; +pub struct IntVid(uint); #[deriving_eq] -pub enum FloatVid = uint; +pub struct FloatVid(uint); #[deriving_eq] #[auto_encode] #[auto_decode] -pub enum RegionVid = uint; +pub struct RegionVid { + id: uint +} #[deriving_eq] pub enum InferTy { @@ -687,11 +689,11 @@ impl ToStr for FloatVid { } impl Vid for RegionVid { - pure fn to_uint(&self) -> uint { **self } + pure fn to_uint(&self) -> uint { self.id } } impl ToStr for RegionVid { - pure fn to_str(&self) -> ~str { fmt!("%?", self) } + pure fn to_str(&self) -> ~str { fmt!("%?", self.id) } } impl ToStr for FnSig { @@ -1138,11 +1140,11 @@ pub fn encl_region(cx: ctxt, id: ast::node_id) -> ty::Region { } } -pub fn walk_ty(ty: t, f: fn(t)) { +pub fn walk_ty(ty: t, f: &fn(t)) { maybe_walk_ty(ty, |t| { f(t); true }); } -pub fn maybe_walk_ty(ty: t, f: fn(t) -> bool) { +pub fn maybe_walk_ty(ty: t, f: &fn(t) -> bool) { if !f(ty) { return; } match /*bad*/copy get(ty).sty { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | @@ -1170,11 +1172,11 @@ pub fn maybe_walk_ty(ty: t, f: fn(t) -> bool) { } } -pub fn fold_sty_to_ty(tcx: ty::ctxt, sty: &sty, foldop: fn(t) -> t) -> t { +pub fn fold_sty_to_ty(tcx: ty::ctxt, sty: &sty, foldop: &fn(t) -> t) -> t { mk_t(tcx, fold_sty(sty, foldop)) } -pub fn fold_sig(sig: &FnSig, fldop: fn(t) -> t) -> FnSig { +pub fn fold_sig(sig: &FnSig, fldop: &fn(t) -> t) -> FnSig { let args = do sig.inputs.map |arg| { arg { mode: arg.mode, ty: fldop(arg.ty) } }; @@ -1185,8 +1187,8 @@ pub fn fold_sig(sig: &FnSig, fldop: fn(t) -> t) -> FnSig { } } -fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty { - fn fold_substs(substs: &substs, fldop: fn(t) -> t) -> substs { +fn fold_sty(sty: &sty, fldop: &fn(t) -> t) -> sty { + fn fold_substs(substs: &substs, fldop: &fn(t) -> t) -> substs { substs {self_r: substs.self_r, self_ty: substs.self_ty.map(|t| fldop(*t)), tps: substs.tps.map(|t| fldop(*t))} @@ -1241,7 +1243,7 @@ fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty { } // Folds types from the bottom up. -pub fn fold_ty(cx: ctxt, t0: t, fldop: fn(t) -> t) -> t { +pub fn fold_ty(cx: ctxt, t0: t, fldop: &fn(t) -> t) -> t { let sty = fold_sty(&get(t0).sty, |t| fold_ty(cx, fldop(t), fldop)); fldop(mk_t(cx, sty)) } @@ -1249,8 +1251,8 @@ pub fn fold_ty(cx: ctxt, t0: t, fldop: fn(t) -> t) -> t { pub fn walk_regions_and_ty( cx: ctxt, ty: t, - walkr: fn(r: Region), - walkt: fn(t: t) -> bool) { + walkr: &fn(r: Region), + walkt: &fn(t: t) -> bool) { if (walkt(ty)) { fold_regions_and_ty( @@ -1264,14 +1266,14 @@ pub fn walk_regions_and_ty( pub fn fold_regions_and_ty( cx: ctxt, ty: t, - fldr: fn(r: Region) -> Region, - fldfnt: fn(t: t) -> t, - fldt: fn(t: t) -> t) -> t { + fldr: &fn(r: Region) -> Region, + fldfnt: &fn(t: t) -> t, + fldt: &fn(t: t) -> t) -> t { fn fold_substs( substs: &substs, - fldr: fn(r: Region) -> Region, - fldt: fn(t: t) -> t) + fldr: &fn(r: Region) -> Region, + fldt: &fn(t: t) -> t) -> substs { substs { self_r: substs.self_r.map(|r| fldr(*r)), @@ -1325,9 +1327,9 @@ pub fn fold_regions_and_ty( pub fn fold_regions( cx: ctxt, ty: t, - fldr: fn(r: Region, in_fn: bool) -> Region) -> t { + fldr: &fn(r: Region, in_fn: bool) -> Region) -> t { fn do_fold(cx: ctxt, ty: t, in_fn: bool, - fldr: fn(Region, bool) -> Region) -> t { + fldr: &fn(Region, bool) -> Region) -> t { debug!("do_fold(ty=%s, in_fn=%b)", ty_to_str(cx, ty), in_fn); if !type_has_regions(ty) { return ty; } fold_regions_and_ty( @@ -2274,7 +2276,7 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool { pub fn type_structurally_contains(cx: ctxt, ty: t, - test: fn(x: &sty) -> bool) + test: &fn(x: &sty) -> bool) -> bool { let sty = &get(ty).sty; debug!("type_structurally_contains: %s", @@ -4008,7 +4010,7 @@ pub fn struct_fields(cx: ctxt, fn struct_item_fields(cx:ctxt, did: ast::def_id, substs: &substs, - frob_mutability: fn(struct_mutability) -> mutability) + frob_mutability: &fn(struct_mutability) -> mutability) -> ~[field] { do lookup_struct_fields(cx, did).map |f| { // consider all instance vars mut, because the diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 8152200bf0476..6c27decc28345 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -36,7 +36,7 @@ * scopes and (b) the default region may change. To understand case (a), * consider something like: * - * type foo = { x: &a.int, y: fn(&a.int) } + * type foo = { x: &a.int, y: &fn(&a.int) } * * The type of `x` is an error because there is no region `a` in scope. * In the type of `y`, however, region `a` is considered a bound region @@ -224,7 +224,7 @@ pub fn ast_ty_to_ty( rscope: &RS, a_seq_ty: ast::mt, vst: ty::vstore, - constr: fn(ty::mt) -> ty::t) -> ty::t + constr: &fn(ty::mt) -> ty::t) -> ty::t { let tcx = self.tcx(); diff --git a/src/librustc/middle/typeck/check/demand.rs b/src/librustc/middle/typeck/check/demand.rs index a3fac8b4e1cde..1bb71c156c3dc 100644 --- a/src/librustc/middle/typeck/check/demand.rs +++ b/src/librustc/middle/typeck/check/demand.rs @@ -33,7 +33,7 @@ pub fn subtype(fcx: @mut FnCtxt, sp: span, expected: ty::t, actual: ty::t) { pub fn suptype_with_fn(fcx: @mut FnCtxt, sp: span, b_is_expected: bool, ty_a: ty::t, ty_b: ty::t, - handle_err: fn(span, ty::t, ty::t, &ty::type_err)) { + handle_err: &fn(span, ty::t, ty::t, &ty::type_err)) { // n.b.: order of actual, expected is reversed match infer::mk_subty(fcx.infcx(), b_is_expected, sp, ty_b, ty_a) { diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 3395d9b445146..d6060c1ae316d 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -105,17 +105,24 @@ use syntax::ast::{m_const, m_mutbl, m_imm}; use syntax::ast; use syntax::ast_map; +#[deriving_eq] +pub enum CheckTraitsFlag { + CheckTraitsOnly, + CheckTraitsAndInherentMethods, +} + pub fn lookup( fcx: @mut FnCtxt, // In a call `a.b::(...)`: - expr: @ast::expr, // The expression `a.b`. - self_expr: @ast::expr, // The expression `a`. - callee_id: node_id, // Where to store the type of `a.b` - m_name: ast::ident, // The ident `b`. - self_ty: ty::t, // The type of `a`. - supplied_tps: &[ty::t], // The list of types X, Y, ... . - deref_args: check::DerefArgs) // Whether we autopointer first. + expr: @ast::expr, // The expression `a.b`. + self_expr: @ast::expr, // The expression `a`. + callee_id: node_id, // Where to store the type of `a.b` + m_name: ast::ident, // The ident `b`. + self_ty: ty::t, // The type of `a`. + supplied_tps: &[ty::t], // The list of types X, Y, ... . + deref_args: check::DerefArgs, // Whether we autopointer first. + check_traits: CheckTraitsFlag) // Whether we check traits only. -> Option { let lcx = LookupContext { @@ -129,6 +136,7 @@ pub fn lookup( inherent_candidates: @mut ~[], extension_candidates: @mut ~[], deref_args: deref_args, + check_traits: check_traits, }; let mme = lcx.do_lookup(self_ty); debug!("method lookup for %s yielded %?", @@ -147,6 +155,7 @@ pub struct LookupContext { inherent_candidates: @mut ~[Candidate], extension_candidates: @mut ~[Candidate], deref_args: check::DerefArgs, + check_traits: CheckTraitsFlag, } /** @@ -299,7 +308,9 @@ pub impl LookupContext/&self { self_ty, self_did, &substs); } ty_enum(did, _) | ty_struct(did, _) => { - self.push_inherent_impl_candidates_for_type(did); + if self.check_traits == CheckTraitsAndInherentMethods { + self.push_inherent_impl_candidates_for_type(did); + } } _ => { /* No inherent methods in these types */ } } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index cdc1f258cb544..6617fa3b27c91 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -89,7 +89,8 @@ use middle::typeck::astconv::{AstConv, ast_path_to_ty}; use middle::typeck::astconv::{ast_region_to_region, ast_ty_to_ty}; use middle::typeck::astconv; use middle::typeck::check::_match::pat_ctxt; -use middle::typeck::check::method::TransformTypeNormally; +use middle::typeck::check::method::{CheckTraitsAndInherentMethods}; +use middle::typeck::check::method::{CheckTraitsOnly, TransformTypeNormally}; use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_sig; use middle::typeck::check::vtable::{LocationInfo, VtableContext}; use middle::typeck::CrateCtxt; @@ -1142,7 +1143,7 @@ pub fn break_here() { pub fn check_expr_with_unifier(fcx: @mut FnCtxt, expr: @ast::expr, expected: Option, - unifier: fn()) -> bool { + unifier: &fn()) -> bool { debug!(">> typechecking %s", fcx.expr_to_str(expr)); // A generic function to factor out common logic from call and @@ -1371,7 +1372,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, method_name, expr_t, tps, - DontDerefArgs) { + DontDerefArgs, + CheckTraitsAndInherentMethods) { Some(ref entry) => { let method_map = fcx.ccx.method_map; method_map.insert(expr.id, (*entry)); @@ -1453,9 +1455,15 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, +args: ~[@ast::expr], +deref_args: DerefArgs) -> Option<(ty::t, bool)> { - match method::lookup(fcx, op_ex, self_ex, - op_ex.callee_id, opname, self_t, ~[], - deref_args) { + match method::lookup(fcx, + op_ex, + self_ex, + op_ex.callee_id, + opname, + self_t, + ~[], + deref_args, + CheckTraitsOnly) { Some(ref origin) => { let method_ty = fcx.node_ty(op_ex.callee_id); let method_map = fcx.ccx.method_map; @@ -1602,7 +1610,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, // returns `none`. fn unpack_expected(fcx: @mut FnCtxt, expected: Option, - unpack: fn(&ty::sty) -> Option) + unpack: &fn(&ty::sty) -> Option) -> Option { match expected { Some(t) => { @@ -1732,7 +1740,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, field, expr_t, tps, - DontDerefArgs) { + DontDerefArgs, + CheckTraitsAndInherentMethods) { Some(ref entry) => { let method_map = fcx.ccx.method_map; method_map.insert(expr.id, (*entry)); diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs index a5c64e7c8736b..98f49e48c0849 100644 --- a/src/librustc/middle/typeck/check/regionmanip.rs +++ b/src/librustc/middle/typeck/check/regionmanip.rs @@ -30,7 +30,7 @@ pub fn replace_bound_regions_in_fn_sig( isr: isr_alist, self_info: Option, fn_sig: &ty::FnSig, - mapf: fn(ty::bound_region) -> ty::Region) -> + mapf: &fn(ty::bound_region) -> ty::Region) -> (isr_alist, Option, ty::FnSig) { // Take self_info apart; the self_ty part is the only one we want // to update here. @@ -96,7 +96,7 @@ pub fn replace_bound_regions_in_fn_sig( tcx: ty::ctxt, isr: isr_alist, tys: ~[ty::t], - to_r: fn(ty::bound_region) -> ty::Region) -> isr_alist { + to_r: &fn(ty::bound_region) -> ty::Region) -> isr_alist { // Takes `isr` (described above), `to_r` (described above), // and `r`, a region. If `r` is anything other than a bound @@ -106,7 +106,7 @@ pub fn replace_bound_regions_in_fn_sig( // updated isr_alist that now contains a mapping from `r` to // the result of calling `to_r` on it. fn append_isr(isr: isr_alist, - to_r: fn(ty::bound_region) -> ty::Region, + to_r: &fn(ty::bound_region) -> ty::Region, r: ty::Region) -> isr_alist { match r { ty::re_free(_, _) | ty::re_static | ty::re_scope(_) | diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index 2390e73f16f9a..91c987acc6aa7 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -84,7 +84,7 @@ use syntax::ast; // Note: Coerce is not actually a combiner, in that it does not // conform to the same interface, though it performs a similar // function. -pub enum Coerce = CombineFields; +pub struct Coerce(CombineFields); pub impl Coerce { fn tys(&self, a: ty::t, b: ty::t) -> CoerceResult { diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index dd9bf9cac64bf..bba35f02b0c1e 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -29,7 +29,7 @@ use util::ppaux::mt_to_str; use std::list; -pub enum Glb = CombineFields; // "greatest lower bound" (common subtype) +pub struct Glb(CombineFields); // "greatest lower bound" (common subtype) impl Combine for Glb { fn infcx(&self) -> @mut InferCtxt { self.infcx } @@ -228,7 +228,7 @@ impl Combine for Glb { // NB---I do not believe this algorithm computes // (necessarily) the GLB. As written it can // spuriously fail. In particular, if there is a case - // like: fn(fn(&a)) and fn(fn(&b)), where a and b are + // like: &fn(fn(&a)) and fn(fn(&b)), where a and b are // free, it will return fn(&c) where c = GLB(a,b). If // however this GLB is not defined, then the result is // an error, even though something like diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 83cbd4c745c0c..3a12fb31a1a6f 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -29,7 +29,7 @@ use syntax::ast::{pure_fn, ret_style, return_val, unsafe_fn}; use syntax::ast::{Onceness, purity}; use syntax::codemap::span; -pub enum Lub = CombineFields; // least-upper-bound: common supertype +pub struct Lub(CombineFields); // least-upper-bound: common supertype pub impl Lub { fn bot_ty(&self, b: ty::t) -> cres { Ok(b) } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index a334ba57e6e04..f68a0db63870b 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -481,12 +481,12 @@ fn resolve_borrowings(cx: @mut InferCtxt) { */ trait then { - fn then(&self, f: fn() -> Result) + fn then(&self, f: &fn() -> Result) -> Result; } impl then for ures { - fn then(&self, f: fn() -> Result) + fn then(&self, f: &fn() -> Result) -> Result { self.chain(|_i| f()) } @@ -506,11 +506,11 @@ impl ToUres for cres { } trait CresCompare { - fn compare(&self, t: T, f: fn() -> ty::type_err) -> cres; + fn compare(&self, t: T, f: &fn() -> ty::type_err) -> cres; } impl CresCompare for cres { - fn compare(&self, t: T, f: fn() -> ty::type_err) -> cres { + fn compare(&self, t: T, f: &fn() -> ty::type_err) -> cres { do self.chain |s| { if s == t { *self @@ -584,7 +584,7 @@ pub impl @mut InferCtxt { } /// Execute `f` and commit the bindings if successful - fn commit(&self, f: fn() -> Result) -> Result { + fn commit(&self, f: &fn() -> Result) -> Result { fail_unless!(!self.in_snapshot()); debug!("commit()"); @@ -599,7 +599,7 @@ pub impl @mut InferCtxt { } /// Execute `f`, unroll bindings on failure - fn try(&self, f: fn() -> Result) -> Result { + fn try(&self, f: &fn() -> Result) -> Result { debug!("try()"); do indent { let snapshot = self.start_snapshot(); @@ -613,7 +613,7 @@ pub impl @mut InferCtxt { } /// Execute `f` then unroll any bindings it creates - fn probe(&self, f: fn() -> Result) -> Result { + fn probe(&self, f: &fn() -> Result) -> Result { debug!("probe()"); do indent { let snapshot = self.start_snapshot(); @@ -706,7 +706,7 @@ pub impl @mut InferCtxt { } } - fn type_error_message(&self, sp: span, mk_msg: fn(~str) -> ~str, + fn type_error_message(&self, sp: span, mk_msg: &fn(~str) -> ~str, actual_ty: ty::t, err: Option<&ty::type_err>) { let actual_ty = self.resolve_type_vars_if_possible(actual_ty); diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 35c901c7528de..33e953b6218d9 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -153,7 +153,7 @@ The problem we are addressing is that there is a kind of subtyping between functions with bound region parameters. Consider, for example, whether the following relation holds: - fn(&a/int) <: fn(&b/int)? (Yes, a => b) + fn(&a/int) <: &fn(&b/int)? (Yes, a => b) The answer is that of course it does. These two types are basically the same, except that in one we used the name `a` and one we used @@ -170,7 +170,7 @@ Now let's consider two more function types. Here, we assume that the `self` lifetime is defined somewhere outside and hence is not a lifetime parameter bound by the function type (it "appears free"): - fn(&a/int) <: fn(&self/int)? (Yes, a => self) + fn(&a/int) <: &fn(&self/int)? (Yes, a => self) This subtyping relation does in fact hold. To see why, you have to consider what subtyping means. One way to look at `T1 <: T2` is to @@ -187,7 +187,7 @@ to the same thing: a function that accepts pointers with any lifetime So, what if we reverse the order of the two function types, like this: - fn(&self/int) <: fn(&a/int)? (No) + fn(&self/int) <: &fn(&a/int)? (No) Does the subtyping relationship still hold? The answer of course is no. In this case, the function accepts *only the lifetime `&self`*, @@ -196,8 +196,8 @@ accepted any lifetime. What about these two examples: - fn(&a/int, &b/int) <: fn(&a/int, &a/int)? (Yes) - fn(&a/int, &a/int) <: fn(&a/int, &b/int)? (No) + fn(&a/int, &b/int) <: &fn(&a/int, &a/int)? (Yes) + fn(&a/int, &a/int) <: &fn(&a/int, &b/int)? (No) Here, it is true that functions which take two pointers with any two lifetimes can be treated as if they only accepted two pointers with @@ -221,12 +221,12 @@ Let's walk through some examples and see how this algorithm plays out. We'll start with the first example, which was: - 1. fn(&a/T) <: fn(&b/T)? Yes: a -> b + 1. fn(&a/T) <: &fn(&b/T)? Yes: a -> b After steps 1 and 2 of the algorithm we will have replaced the types like so: - 1. fn(&A/T) <: fn(&x/T)? + 1. fn(&A/T) <: &fn(&x/T)? Here the upper case `&A` indicates a *region variable*, that is, a region whose value is being inferred by the system. I also replaced @@ -255,12 +255,12 @@ So far we have encountered no error, so the subtype check succeeds. Now let's look first at the third example, which was: - 3. fn(&self/T) <: fn(&b/T)? No! + 3. fn(&self/T) <: &fn(&b/T)? No! After steps 1 and 2 of the algorithm we will have replaced the types like so: - 3. fn(&self/T) <: fn(&x/T)? + 3. fn(&self/T) <: &fn(&x/T)? This looks pretty much the same as before, except that on the LHS `&self` was not bound, and hence was left as-is and not replaced with @@ -275,7 +275,7 @@ You may be wondering about that mysterious last step in the algorithm. So far it has not been relevant. The purpose of that last step is to catch something like *this*: - fn() -> fn(&a/T) <: fn() -> fn(&b/T)? No. + fn() -> fn(&a/T) <: &fn() -> fn(&b/T)? No. Here the function types are the same but for where the binding occurs. The subtype returns a function that expects a value in precisely one @@ -289,15 +289,15 @@ So let's step through what happens when we perform this subtype check. We first replace the bound regions in the subtype (the supertype has no bound regions). This gives us: - fn() -> fn(&A/T) <: fn() -> fn(&b/T)? + fn() -> fn(&A/T) <: &fn() -> fn(&b/T)? Now we compare the return types, which are covariant, and hence we have: - fn(&A/T) <: fn(&b/T)? + fn(&A/T) <: &fn(&b/T)? Here we skolemize the bound region in the supertype to yield: - fn(&A/T) <: fn(&x/T)? + fn(&A/T) <: &fn(&x/T)? And then proceed to compare the argument types: @@ -314,7 +314,7 @@ The difference between this example and the first one is that the variable `A` already existed at the point where the skolemization occurred. In the first example, you had two functions: - fn(&a/T) <: fn(&b/T) + fn(&a/T) <: &fn(&b/T) and hence `&A` and `&x` were created "together". In general, the intention of the skolemized names is that they are supposed to be @@ -700,7 +700,7 @@ pub impl RegionVarBindings { match undo_item { Snapshot => {} AddVar(vid) => { - fail_unless!(self.var_spans.len() == *vid + 1); + fail_unless!(self.var_spans.len() == vid.to_uint() + 1); self.var_spans.pop(); } AddConstraint(ref constraint) => { @@ -720,7 +720,7 @@ pub impl RegionVarBindings { fn new_region_var(&mut self, span: span) -> RegionVid { let id = self.num_vars(); self.var_spans.push(span); - let vid = RegionVid(id); + let vid = RegionVid { id: id }; if self.in_snapshot() { self.undo_log.push(AddVar(vid)); } @@ -863,15 +863,15 @@ pub impl RegionVarBindings { } fn resolve_var(&mut self, rid: RegionVid) -> ty::Region { - debug!("RegionVarBindings: resolve_var(%?=%u)", rid, *rid); + debug!("RegionVarBindings: resolve_var(%?=%u)", rid, rid.to_uint()); if self.values.is_empty() { self.tcx.sess.span_bug( - self.var_spans[*rid], + self.var_spans[rid.to_uint()], fmt!("Attempt to resolve region variable before values have \ been computed!")); } - let v = self.values.with_ref(|values| values[*rid]); + let v = self.values.with_ref(|values| values[rid.to_uint()]); match v { Value(r) => r, @@ -886,13 +886,13 @@ pub impl RegionVarBindings { // should ultimately have some bounds. self.tcx.sess.span_err( - self.var_spans[*rid], - fmt!("Unconstrained region variable #%u", *rid)); + self.var_spans[rid.to_uint()], + fmt!("Unconstrained region variable #%u", rid.to_uint())); // Touch of a hack: to suppress duplicate messages, // replace the NoValue entry with ErrorValue. let mut values = self.values.take(); - values[*rid] = ErrorValue; + values[rid.to_uint()] = ErrorValue; self.values.put_back(values); re_static } @@ -1049,7 +1049,7 @@ priv impl RegionVarBindings { (re_infer(ReVar(v_id)), _) | (_, re_infer(ReVar(v_id))) => { self.tcx.sess.span_bug( - self.var_spans[*v_id], + self.var_spans[v_id.to_uint()], fmt!("lub_concrete_regions invoked with \ non-concrete regions: %?, %?", a, b)); } @@ -1111,7 +1111,7 @@ priv impl RegionVarBindings { (re_infer(ReVar(v_id)), _) | (_, re_infer(ReVar(v_id))) => { self.tcx.sess.span_bug( - self.var_spans[*v_id], + self.var_spans[v_id.to_uint()], fmt!("glb_concrete_regions invoked with \ non-concrete regions: %?, %?", a, b)); } @@ -1275,8 +1275,8 @@ pub impl RegionVarBindings { edge_idx: uint) { let edge_dir = edge_dir as uint; graph.edges[edge_idx].next_edge[edge_dir] = - graph.nodes[*node_id].head_edge[edge_dir]; - graph.nodes[*node_id].head_edge[edge_dir] = + graph.nodes[node_id.to_uint()].head_edge[edge_dir]; + graph.nodes[node_id.to_uint()].head_edge[edge_dir] = edge_idx; } } @@ -1285,14 +1285,14 @@ pub impl RegionVarBindings { do iterate_until_fixed_point(~"Expansion", graph) |nodes, edge| { match edge.constraint { ConstrainRegSubVar(a_region, b_vid) => { - let b_node = &mut nodes[*b_vid]; + let b_node = &mut nodes[b_vid.to_uint()]; self.expand_node(a_region, b_vid, b_node) } ConstrainVarSubVar(a_vid, b_vid) => { - match nodes[*a_vid].value { + match nodes[a_vid.to_uint()].value { NoValue | ErrorValue => false, Value(a_region) => { - let b_node = &mut nodes[*b_vid]; + let b_node = &mut nodes[b_vid.to_uint()]; self.expand_node(a_region, b_vid, b_node) } } @@ -1349,16 +1349,16 @@ pub impl RegionVarBindings { false } ConstrainVarSubVar(a_vid, b_vid) => { - match nodes[*b_vid].value { + match nodes[b_vid.to_uint()].value { NoValue | ErrorValue => false, Value(b_region) => { - let a_node = &mut nodes[*a_vid]; + let a_node = &mut nodes[a_vid.to_uint()]; self.contract_node(a_vid, a_node, b_region) } } } ConstrainVarSubReg(a_vid, b_region) => { - let a_node = &mut nodes[*a_vid]; + let a_node = &mut nodes[a_vid.to_uint()]; self.contract_node(a_vid, a_node, b_region) } } @@ -1474,7 +1474,7 @@ pub impl RegionVarBindings { that is not used is not a problem, so if this rule starts to create problems we'll have to revisit this portion of the code and think hard about it. =) */ - let node_vid = RegionVid(idx); + let node_vid = RegionVid { id: idx }; match node.classification { Expanding => { self.report_error_for_expanding_node( @@ -1525,7 +1525,7 @@ pub impl RegionVarBindings { } self.tcx.sess.span_err( - self.var_spans[*node_idx], + self.var_spans[node_idx.to_uint()], fmt!("cannot infer an appropriate lifetime \ due to conflicting requirements")); @@ -1578,7 +1578,7 @@ pub impl RegionVarBindings { } self.tcx.sess.span_err( - self.var_spans[*node_idx], + self.var_spans[node_idx.to_uint()], fmt!("cannot infer an appropriate lifetime \ due to conflicting requirements")); @@ -1616,7 +1616,7 @@ pub impl RegionVarBindings { -> ~[SpannedRegion] { let set = HashMap(); let mut stack = ~[orig_node_idx]; - set.insert(*orig_node_idx, ()); + set.insert(orig_node_idx.to_uint(), ()); let mut result = ~[]; while !vec::is_empty(stack) { let node_idx = stack.pop(); @@ -1627,7 +1627,7 @@ pub impl RegionVarBindings { Incoming => from_vid, Outgoing => to_vid }; - if set.insert(*vid, ()) { + if set.insert(vid.to_uint(), ()) { stack.push(vid); } } @@ -1657,8 +1657,9 @@ pub impl RegionVarBindings { graph: &Graph, node_idx: RegionVid, dir: Direction, - op: fn(edge: &GraphEdge) -> bool) { - let mut edge_idx = graph.nodes[*node_idx].head_edge[dir as uint]; + op: &fn(edge: &GraphEdge) -> bool) { + let mut edge_idx = + graph.nodes[node_idx.to_uint()].head_edge[dir as uint]; while edge_idx != uint::max_value { let edge_ptr = &graph.edges[edge_idx]; if !op(edge_ptr) { diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index f209116696e10..b4d8905a93627 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -29,7 +29,7 @@ use syntax::ast::{Onceness, m_const, purity, ret_style}; use syntax::codemap::span; -pub enum Sub = CombineFields; // "subtype", "subregion" etc +pub struct Sub(CombineFields); // "subtype", "subregion" etc impl Combine for Sub { fn infcx(&self) -> @mut InferCtxt { self.infcx } diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 61f1ceeabaec5..abaf658a1a43e 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -225,7 +225,7 @@ pub fn require_same_types( span: span, t1: ty::t, t2: ty::t, - msg: fn() -> ~str) -> bool { + msg: &fn() -> ~str) -> bool { let l_tcx, l_infcx; match maybe_infcx { diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index f0fc173101f2f..f74a0960f6674 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -74,7 +74,8 @@ impl region_scope for MethodRscope { } } -pub enum type_rscope = Option; +pub struct type_rscope(Option); + impl type_rscope { priv fn replacement(&self) -> ty::Region { if self.is_some() { diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index d3ffd2deb8141..c7945f74f55a5 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -17,7 +17,7 @@ use syntax::visit; use core::str; use std::oldmap::HashMap; -pub fn indent(op: fn() -> R) -> R { +pub fn indent(op: &fn() -> R) -> R { // Use in conjunction with the log post-processor like `src/etc/indenter` // to make debug output more readable. debug!(">>"); diff --git a/src/librustdoc/extract.rs b/src/librustdoc/extract.rs index fc784722b256e..5e5c843da26da 100644 --- a/src/librustdoc/extract.rs +++ b/src/librustdoc/extract.rs @@ -322,8 +322,7 @@ fn structdoc_from_struct( fields: do struct_def.fields.map |field| { match field.node.kind { ast::named_field(ident, _, _) => to_str(ident), - ast::unnamed_field => fail!( - ~"what is an unnamed struct field?") + ast::unnamed_field => ~"(unnamed)", } }, sig: None diff --git a/src/librustdoc/rustdoc.rc b/src/librustdoc/rustdoc.rc index f17f7ffd9cf4a..f5cf98759b375 100644 --- a/src/librustdoc/rustdoc.rc +++ b/src/librustdoc/rustdoc.rc @@ -143,7 +143,7 @@ fn run(config: Config) { } } -pub fn time(what: ~str, f: fn() -> T) -> T { +pub fn time(what: ~str, f: &fn() -> T) -> T { let start = std::time::precise_time_s(); let rv = f(); let end = std::time::precise_time_s(); diff --git a/src/librusti/rusti.rc b/src/librusti/rusti.rc index 6674885a6e28a..0367a771ffbd1 100644 --- a/src/librusti/rusti.rc +++ b/src/librusti/rusti.rc @@ -59,7 +59,7 @@ enum CmdAction { /// A utility function that hands off a pretty printer to a callback. fn with_pp(intr: @token::ident_interner, - cb: fn(@pprust::ps, io::Writer)) -> ~str { + cb: &fn(@pprust::ps, io::Writer)) -> ~str { do io::with_str_writer |writer| { let pp = pprust::rust_printer(writer, intr); diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index b63a0a92e6c15..7d2b8eccd6c0e 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -260,7 +260,7 @@ pub fn hash(data: ~str) -> ~str { hasher.result_str() } -pub fn temp_change_dir(dir: &Path, cb: fn() -> T) { +pub fn temp_change_dir(dir: &Path, cb: &fn() -> T) { let cwd = os::getcwd(); os::change_dir(dir); diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index e7503f0082c2e..d7d878fa192dd 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -176,7 +176,7 @@ pub impl MutexARC { * blocked on the mutex) will also fail immediately. */ #[inline(always)] - unsafe fn access(&self, blk: fn(x: &mut T) -> U) -> U { + unsafe fn access(&self, blk: &fn(x: &mut T) -> U) -> U { unsafe { let state = get_shared_mutable_state(&self.x); // Borrowck would complain about this if the function were @@ -301,7 +301,7 @@ pub impl RWARC { * poison the ARC, so subsequent readers and writers will both also fail. */ #[inline(always)] - fn write(&self, blk: fn(x: &mut T) -> U) -> U { + fn write(&self, blk: &fn(x: &mut T) -> U) -> U { unsafe { let state = get_shared_mutable_state(&self.x); do (*borrow_rwlock(state)).write { @@ -313,7 +313,7 @@ pub impl RWARC { } /// As write(), but with a condvar, as sync::rwlock.write_cond(). #[inline(always)] - fn write_cond(&self, blk: fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { + fn write_cond(&self, blk: &fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { unsafe { let state = get_shared_mutable_state(&self.x); do (*borrow_rwlock(state)).write_cond |cond| { @@ -335,7 +335,7 @@ pub impl RWARC { * Failing will unlock the ARC while unwinding. However, unlike all other * access modes, this will not poison the ARC. */ - fn read(&self, blk: fn(x: &T) -> U) -> U { + fn read(&self, blk: &fn(x: &T) -> U) -> U { let state = unsafe { get_shared_immutable_state(&self.x) }; do (&state.lock).read { check_poison(false, state.failed); @@ -360,14 +360,16 @@ pub impl RWARC { * } * ~~~ */ - fn write_downgrade(&self, blk: fn(v: RWWriteMode) -> U) -> U { + fn write_downgrade(&self, blk: &fn(v: RWWriteMode) -> U) -> U { unsafe { let state = get_shared_mutable_state(&self.x); do (*borrow_rwlock(state)).write_downgrade |write_mode| { check_poison(false, (*state).failed); - blk(RWWriteMode((&mut (*state).data, - write_mode, - PoisonOnFail(&mut (*state).failed)))) + blk(RWWriteMode { + data: &mut (*state).data, + token: write_mode, + poison: PoisonOnFail(&mut (*state).failed) + }) } } } @@ -376,7 +378,11 @@ pub impl RWARC { fn downgrade(&self, token: RWWriteMode/&a) -> RWReadMode/&a { // The rwlock should assert that the token belongs to us for us. let state = unsafe { get_shared_immutable_state(&self.x) }; - let RWWriteMode((data, t, _poison)) = token; + let RWWriteMode { + data: data, + token: t, + poison: _poison + } = token; // Let readers in let new_token = (&state.lock).downgrade(t); // Whatever region the input reference had, it will be safe to use @@ -386,7 +392,10 @@ pub impl RWARC { // Downgrade ensured the token belonged to us. Just a sanity check. fail_unless!(ptr::ref_eq(&state.data, new_data)); // Produce new token - RWReadMode((new_data, new_token)) + RWReadMode { + data: new_data, + token: new_token, + } } } @@ -398,19 +407,28 @@ fn borrow_rwlock(state: *const RWARCInner) -> *RWlock { unsafe { cast::transmute(&const (*state).lock) } } -// FIXME (#3154) ice with struct/& prevents these from being structs. - /// The "write permission" token used for RWARC.write_downgrade(). -pub enum RWWriteMode = - (&self/mut T, sync::RWlockWriteMode/&self, PoisonOnFail); +pub struct RWWriteMode<'self, T> { + data: &'self mut T, + token: sync::RWlockWriteMode<'self>, + poison: PoisonOnFail, +} + /// The "read permission" token used for RWARC.write_downgrade(). -pub enum RWReadMode = (&self/T, sync::RWlockReadMode/&self); +pub struct RWReadMode<'self, T> { + data: &'self T, + token: sync::RWlockReadMode<'self>, +} pub impl RWWriteMode/&self { /// Access the pre-downgrade RWARC in write mode. - fn write(&self, blk: fn(x: &mut T) -> U) -> U { + fn write(&self, blk: &fn(x: &mut T) -> U) -> U { match *self { - RWWriteMode((ref data, ref token, _)) => { + RWWriteMode { + data: ref data, + token: ref token, + poison: _ + } => { do token.write { blk(&mut **data) } @@ -418,9 +436,13 @@ pub impl RWWriteMode/&self { } } /// Access the pre-downgrade RWARC in write mode with a condvar. - fn write_cond(&self, blk: fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { + fn write_cond(&self, blk: &fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { match *self { - RWWriteMode((ref data, ref token, ref poison)) => { + RWWriteMode { + data: ref data, + token: ref token, + poison: ref poison + } => { do token.write_cond |cond| { unsafe { let cvar = Condvar { @@ -438,9 +460,12 @@ pub impl RWWriteMode/&self { pub impl RWReadMode/&self { /// Access the post-downgrade rwlock in read mode. - fn read(&self, blk: fn(x: &T) -> U) -> U { + fn read(&self, blk: &fn(x: &T) -> U) -> U { match *self { - RWReadMode((data, ref token)) => { + RWReadMode { + data: data, + token: ref token + } => { do token.read { blk(data) } } } diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 9ed6d285ce687..695b3d01376c3 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -201,7 +201,7 @@ pub impl Arena { } #[inline(always)] - fn alloc_pod(&self, op: fn() -> T) -> &self/T { + fn alloc_pod(&self, op: &fn() -> T) -> &self/T { unsafe { let tydesc = sys::get_type_desc::(); let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align); @@ -246,7 +246,7 @@ pub impl Arena { } #[inline(always)] - fn alloc_nonpod(&self, op: fn() -> T) -> &self/T { + fn alloc_nonpod(&self, op: &fn() -> T) -> &self/T { unsafe { let tydesc = sys::get_type_desc::(); let (ty_ptr, ptr) = @@ -268,7 +268,7 @@ pub impl Arena { // The external interface #[inline(always)] - fn alloc(&self, op: fn() -> T) -> &self/T { + fn alloc(&self, op: &fn() -> T) -> &self/T { unsafe { if !rusti::needs_drop::() { self.alloc_pod(op) diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 55ec29d2337ca..8dbdb83698c6f 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -33,7 +33,7 @@ pub impl SmallBitv { #[inline(always)] fn bits_op(&mut self, right_bits: uint, nbits: uint, - f: fn(uint, uint) -> uint) -> bool { + f: &fn(uint, uint) -> uint) -> bool { let mask = small_mask(nbits); let old_b: uint = self.bits; let new_b = f(old_b, right_bits); @@ -130,7 +130,7 @@ pub impl BigBitv { #[inline(always)] fn process(&mut self, b: &BigBitv, nbits: uint, - op: fn(uint, uint) -> uint) -> bool { + op: &fn(uint, uint) -> uint) -> bool { let len = b.storage.len(); fail_unless!((self.storage.len() == len)); let mut changed = false; @@ -148,7 +148,7 @@ pub impl BigBitv { } #[inline(always)] - fn each_storage(&mut self, op: fn(v: &mut uint) -> bool) { + fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) { for uint::range(0, self.storage.len()) |i| { let mut w = self.storage[i]; let b = op(&mut w); @@ -392,7 +392,7 @@ pub impl Bitv { } #[inline(always)] - fn each(&self, f: fn(bool) -> bool) { + fn each(&self, f: &fn(bool) -> bool) { let mut i = 0; while i < self.nbits { if !f(self.get(i)) { break; } @@ -493,7 +493,7 @@ pub impl Bitv { true } - fn ones(&self, f: fn(uint) -> bool) { + fn ones(&self, f: &fn(uint) -> bool) { for uint::range(0, self.nbits) |i| { if self.get(i) { if !f(i) { break } @@ -546,7 +546,7 @@ pub fn from_bools(bools: &[bool]) -> Bitv { * Create a bitv of the specified length where the value at each * index is f(index). */ -pub fn from_fn(len: uint, f: fn(index: uint) -> bool) -> Bitv { +pub fn from_fn(len: uint, f: &fn(index: uint) -> bool) -> Bitv { let mut bitv = Bitv::new(len, false); for uint::range(0, len) |i| { bitv.set(i, f(i)); @@ -561,7 +561,7 @@ impl ops::Index for Bitv { } #[inline(always)] -pure fn iterate_bits(base: uint, bits: uint, f: fn(uint) -> bool) -> bool { +pure fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool { if bits == 0 { return true; } @@ -622,7 +622,7 @@ pub impl BitvSet { } #[inline(always)] - priv fn other_op(&mut self, other: &BitvSet, f: fn(uint, uint) -> uint) { + priv fn other_op(&mut self, other: &BitvSet, f: &fn(uint, uint) -> uint) { fn nbits(mut w: uint) -> uint { let mut bits = 0; for uint::bits.times { @@ -669,7 +669,7 @@ pub impl BitvSet { impl BaseIter for BitvSet { pure fn size_hint(&self) -> Option { Some(self.len()) } - pure fn each(&self, blk: fn(v: &uint) -> bool) { + pure fn each(&self, blk: &fn(v: &uint) -> bool) { for self.bitv.storage.eachi |i, &w| { if !iterate_bits(i * uint::bits, w, |b| blk(&b)) { return; @@ -778,7 +778,7 @@ impl Set for BitvSet { other.is_subset(self) } - pure fn difference(&self, other: &BitvSet, f: fn(&uint) -> bool) { + pure fn difference(&self, other: &BitvSet, f: &fn(&uint) -> bool) { for self.each_common(other) |i, w1, w2| { if !iterate_bits(i, w1 & !w2, |b| f(&b)) { return; @@ -791,7 +791,7 @@ impl Set for BitvSet { } pure fn symmetric_difference(&self, other: &BitvSet, - f: fn(&uint) -> bool) { + f: &fn(&uint) -> bool) { for self.each_common(other) |i, w1, w2| { if !iterate_bits(i, w1 ^ w2, |b| f(&b)) { return; @@ -802,7 +802,7 @@ impl Set for BitvSet { ); } - pure fn intersection(&self, other: &BitvSet, f: fn(&uint) -> bool) { + pure fn intersection(&self, other: &BitvSet, f: &fn(&uint) -> bool) { for self.each_common(other) |i, w1, w2| { if !iterate_bits(i, w1 & w2, |b| f(&b)) { return; @@ -810,7 +810,7 @@ impl Set for BitvSet { } } - pure fn union(&self, other: &BitvSet, f: fn(&uint) -> bool) { + pure fn union(&self, other: &BitvSet, f: &fn(&uint) -> bool) { for self.each_common(other) |i, w1, w2| { if !iterate_bits(i, w1 | w2, |b| f(&b)) { return; @@ -828,7 +828,7 @@ priv impl BitvSet { /// w1, w2) where the bit location is the number of bits offset so far, /// and w1/w2 are the words coming from the two vectors self, other. pure fn each_common(&self, other: &BitvSet, - f: fn(uint, uint, uint) -> bool) { + f: &fn(uint, uint, uint) -> bool) { let min = uint::min(self.bitv.storage.len(), other.bitv.storage.len()); for self.bitv.storage.view(0, min).eachi |i, &w| { @@ -846,7 +846,7 @@ priv impl BitvSet { /// is true if the word comes from 'self', and false if it comes from /// 'other'. pure fn each_outlier(&self, other: &BitvSet, - f: fn(bool, uint, uint) -> bool) { + f: &fn(bool, uint, uint) -> bool) { let len1 = self.bitv.storage.len(); let len2 = other.bitv.storage.len(); let min = uint::min(len1, len2); diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 44461ae06fff4..a55d4bc97ec56 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -142,7 +142,7 @@ pub mod reader { } } - pub fn docs(d: Doc, it: fn(uint, Doc) -> bool) { + pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) { let mut pos = d.start; while pos < d.end { let elt_tag = vuint_at(*d.data, pos); @@ -155,7 +155,7 @@ pub mod reader { } } - pub fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) { + pub fn tagged_docs(d: Doc, tg: uint, it: &fn(Doc) -> bool) { let mut pos = d.start; while pos < d.end { let elt_tag = vuint_at(*d.data, pos); @@ -175,7 +175,7 @@ pub mod reader { vec::slice::(*d.data, d.start, d.end).to_vec() } - pub fn with_doc_data(d: Doc, f: fn(x: &[u8]) -> T) -> T { + pub fn with_doc_data(d: Doc, f: &fn(x: &[u8]) -> T) -> T { f(vec::slice(*d.data, d.start, d.end)) } @@ -255,7 +255,7 @@ pub mod reader { r_doc } - fn push_doc(&self, d: Doc, f: fn() -> T) -> T { + fn push_doc(&self, d: Doc, f: &fn() -> T) -> T { let old_parent = self.parent; let old_pos = self.pos; self.parent = d; @@ -274,7 +274,7 @@ pub mod reader { } pub impl Decoder { - fn read_opaque(&self, op: fn(Doc) -> R) -> R { + fn read_opaque(&self, op: &fn(Doc) -> R) -> R { do self.push_doc(self.next_doc(EsOpaque)) { op(copy self.parent) } @@ -321,23 +321,23 @@ pub mod reader { fn read_managed_str(&self) -> @str { fail!(~"read_managed_str()"); } // Compound types: - fn read_owned(&self, f: fn() -> T) -> T { + fn read_owned(&self, f: &fn() -> T) -> T { debug!("read_owned()"); f() } - fn read_managed(&self, f: fn() -> T) -> T { + fn read_managed(&self, f: &fn() -> T) -> T { debug!("read_managed()"); f() } - fn read_enum(&self, name: &str, f: fn() -> T) -> T { + fn read_enum(&self, name: &str, f: &fn() -> T) -> T { debug!("read_enum(%s)", name); self._check_label(name); self.push_doc(self.next_doc(EsEnum), f) } - fn read_enum_variant(&self, f: fn(uint) -> T) -> T { + fn read_enum_variant(&self, f: &fn(uint) -> T) -> T { debug!("read_enum_variant()"); let idx = self._next_uint(EsEnumVid); debug!(" idx=%u", idx); @@ -346,12 +346,12 @@ pub mod reader { } } - fn read_enum_variant_arg(&self, idx: uint, f: fn() -> T) -> T { + fn read_enum_variant_arg(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_enum_variant_arg(idx=%u)", idx); f() } - fn read_owned_vec(&self, f: fn(uint) -> T) -> T { + fn read_owned_vec(&self, f: &fn(uint) -> T) -> T { debug!("read_owned_vec()"); do self.push_doc(self.next_doc(EsVec)) { let len = self._next_uint(EsVecLen); @@ -360,7 +360,7 @@ pub mod reader { } } - fn read_managed_vec(&self, f: fn(uint) -> T) -> T { + fn read_managed_vec(&self, f: &fn(uint) -> T) -> T { debug!("read_managed_vec()"); do self.push_doc(self.next_doc(EsVec)) { let len = self._next_uint(EsVecLen); @@ -369,33 +369,33 @@ pub mod reader { } } - fn read_vec_elt(&self, idx: uint, f: fn() -> T) -> T { + fn read_vec_elt(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_vec_elt(idx=%u)", idx); self.push_doc(self.next_doc(EsVecElt), f) } - fn read_rec(&self, f: fn() -> T) -> T { + fn read_rec(&self, f: &fn() -> T) -> T { debug!("read_rec()"); f() } - fn read_struct(&self, name: &str, _len: uint, f: fn() -> T) -> T { + fn read_struct(&self, name: &str, _len: uint, f: &fn() -> T) -> T { debug!("read_struct(name=%s)", name); f() } - fn read_field(&self, name: &str, idx: uint, f: fn() -> T) -> T { + fn read_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { debug!("read_field(name=%s, idx=%u)", name, idx); self._check_label(name); f() } - fn read_tup(&self, len: uint, f: fn() -> T) -> T { + fn read_tup(&self, len: uint, f: &fn() -> T) -> T { debug!("read_tup(len=%u)", len); f() } - fn read_tup_elt(&self, idx: uint, f: fn() -> T) -> T { + fn read_tup_elt(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_tup_elt(idx=%u)", idx); f() } @@ -469,7 +469,7 @@ pub mod writer { debug!("End tag (size = %u)", size); } - fn wr_tag(&self, tag_id: uint, blk: fn()) { + fn wr_tag(&self, tag_id: uint, blk: &fn()) { self.start_tag(tag_id); blk(); self.end_tag(); @@ -566,7 +566,7 @@ pub mod writer { } pub impl Encoder { - fn emit_opaque(&self, f: fn()) { + fn emit_opaque(&self, f: &fn()) { do self.wr_tag(EsOpaque as uint) { f() } @@ -623,49 +623,49 @@ pub mod writer { self.emit_borrowed_str(v) } - fn emit_borrowed(&self, f: fn()) { f() } - fn emit_owned(&self, f: fn()) { f() } - fn emit_managed(&self, f: fn()) { f() } + fn emit_borrowed(&self, f: &fn()) { f() } + fn emit_owned(&self, f: &fn()) { f() } + fn emit_managed(&self, f: &fn()) { f() } - fn emit_enum(&self, name: &str, f: fn()) { + fn emit_enum(&self, name: &str, f: &fn()) { self._emit_label(name); self.wr_tag(EsEnum as uint, f) } fn emit_enum_variant(&self, _v_name: &str, v_id: uint, _cnt: uint, - f: fn()) { + f: &fn()) { self._emit_tagged_uint(EsEnumVid, v_id); self.wr_tag(EsEnumBody as uint, f) } - fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) { f() } + fn emit_enum_variant_arg(&self, _idx: uint, f: &fn()) { f() } - fn emit_borrowed_vec(&self, len: uint, f: fn()) { + fn emit_borrowed_vec(&self, len: uint, f: &fn()) { do self.wr_tag(EsVec as uint) { self._emit_tagged_uint(EsVecLen, len); f() } } - fn emit_owned_vec(&self, len: uint, f: fn()) { + fn emit_owned_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_managed_vec(&self, len: uint, f: fn()) { + fn emit_managed_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_vec_elt(&self, _idx: uint, f: fn()) { + fn emit_vec_elt(&self, _idx: uint, f: &fn()) { self.wr_tag(EsVecElt as uint, f) } - fn emit_rec(&self, f: fn()) { f() } - fn emit_struct(&self, _name: &str, _len: uint, f: fn()) { f() } - fn emit_field(&self, name: &str, _idx: uint, f: fn()) { + fn emit_rec(&self, f: &fn()) { f() } + fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { f() } + fn emit_field(&self, name: &str, _idx: uint, f: &fn()) { self._emit_label(name); f() } - fn emit_tup(&self, _len: uint, f: fn()) { f() } - fn emit_tup_elt(&self, _idx: uint, f: fn()) { f() } + fn emit_tup(&self, _len: uint, f: &fn()) { f() } + fn emit_tup_elt(&self, _idx: uint, f: &fn()) { f() } } } diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index 0729987958a06..735f86b34eca7 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -61,7 +61,7 @@ pub fn find(m: Treemap, k: K) -> Option { } /// Visit all pairs in the map in order. -pub fn traverse(m: Treemap, f: fn(&K, &V)) { +pub fn traverse(m: Treemap, f: &fn(&K, &V)) { match *m { Empty => (), /* diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 9208d415971c6..8c6a870b98cd4 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -116,15 +116,15 @@ impl serialize::Encoder for Encoder { fn emit_owned_str(&self, v: &str) { self.emit_borrowed_str(v) } fn emit_managed_str(&self, v: &str) { self.emit_borrowed_str(v) } - fn emit_borrowed(&self, f: fn()) { f() } - fn emit_owned(&self, f: fn()) { f() } - fn emit_managed(&self, f: fn()) { f() } + fn emit_borrowed(&self, f: &fn()) { f() } + fn emit_owned(&self, f: &fn()) { f() } + fn emit_managed(&self, f: &fn()) { f() } - fn emit_enum(&self, _name: &str, f: fn()) { + fn emit_enum(&self, _name: &str, f: &fn()) { f() } - fn emit_enum_variant(&self, name: &str, _id: uint, _cnt: uint, f: fn()) { + fn emit_enum_variant(&self, name: &str, _id: uint, _cnt: uint, f: &fn()) { // encoding of enums is special-cased for Option. Specifically: // Some(34) => 34 // None => null @@ -160,49 +160,49 @@ impl serialize::Encoder for Encoder { } } - fn emit_enum_variant_arg(&self, idx: uint, f: fn()) { + fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) { if (idx != 0) {self.wr.write_char(',');} f(); } - fn emit_borrowed_vec(&self, _len: uint, f: fn()) { + fn emit_borrowed_vec(&self, _len: uint, f: &fn()) { self.wr.write_char('['); f(); self.wr.write_char(']'); } - fn emit_owned_vec(&self, len: uint, f: fn()) { + fn emit_owned_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_managed_vec(&self, len: uint, f: fn()) { + fn emit_managed_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_vec_elt(&self, idx: uint, f: fn()) { + fn emit_vec_elt(&self, idx: uint, f: &fn()) { if idx != 0 { self.wr.write_char(','); } f() } - fn emit_rec(&self, f: fn()) { + fn emit_rec(&self, f: &fn()) { self.wr.write_char('{'); f(); self.wr.write_char('}'); } - fn emit_struct(&self, _name: &str, _len: uint, f: fn()) { + fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { self.wr.write_char('{'); f(); self.wr.write_char('}'); } - fn emit_field(&self, name: &str, idx: uint, f: fn()) { + fn emit_field(&self, name: &str, idx: uint, f: &fn()) { if idx != 0 { self.wr.write_char(','); } self.wr.write_str(escape_str(name)); self.wr.write_char(':'); f(); } - fn emit_tup(&self, len: uint, f: fn()) { + fn emit_tup(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f); } - fn emit_tup_elt(&self, idx: uint, f: fn()) { + fn emit_tup_elt(&self, idx: uint, f: &fn()) { self.emit_vec_elt(idx, f) } } @@ -251,39 +251,39 @@ impl serialize::Encoder for PrettyEncoder { fn emit_owned_str(&self, v: &str) { self.emit_borrowed_str(v) } fn emit_managed_str(&self, v: &str) { self.emit_borrowed_str(v) } - fn emit_borrowed(&self, f: fn()) { f() } - fn emit_owned(&self, f: fn()) { f() } - fn emit_managed(&self, f: fn()) { f() } + fn emit_borrowed(&self, f: &fn()) { f() } + fn emit_owned(&self, f: &fn()) { f() } + fn emit_managed(&self, f: &fn()) { f() } - fn emit_enum(&self, name: &str, f: fn()) { + fn emit_enum(&self, name: &str, f: &fn()) { if name != "option" { fail!(~"only supports option enum") } f() } - fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { + fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: &fn()) { if id == 0 { self.emit_nil(); } else { f() } } - fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) { + fn emit_enum_variant_arg(&self, _idx: uint, f: &fn()) { f() } - fn emit_borrowed_vec(&self, _len: uint, f: fn()) { + fn emit_borrowed_vec(&self, _len: uint, f: &fn()) { self.wr.write_char('['); self.indent += 2; f(); self.indent -= 2; self.wr.write_char(']'); } - fn emit_owned_vec(&self, len: uint, f: fn()) { + fn emit_owned_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_managed_vec(&self, len: uint, f: fn()) { + fn emit_managed_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_vec_elt(&self, idx: uint, f: fn()) { + fn emit_vec_elt(&self, idx: uint, f: &fn()) { if idx == 0 { self.wr.write_char('\n'); } else { @@ -293,17 +293,17 @@ impl serialize::Encoder for PrettyEncoder { f() } - fn emit_rec(&self, f: fn()) { + fn emit_rec(&self, f: &fn()) { self.wr.write_char('{'); self.indent += 2; f(); self.indent -= 2; self.wr.write_char('}'); } - fn emit_struct(&self, _name: &str, _len: uint, f: fn()) { + fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { self.emit_rec(f) } - fn emit_field(&self, name: &str, idx: uint, f: fn()) { + fn emit_field(&self, name: &str, idx: uint, f: &fn()) { if idx == 0 { self.wr.write_char('\n'); } else { @@ -314,10 +314,10 @@ impl serialize::Encoder for PrettyEncoder { self.wr.write_str(": "); f(); } - fn emit_tup(&self, sz: uint, f: fn()) { + fn emit_tup(&self, sz: uint, f: &fn()) { self.emit_borrowed_vec(sz, f); } - fn emit_tup_elt(&self, idx: uint, f: fn()) { + fn emit_tup_elt(&self, idx: uint, f: &fn()) { self.emit_vec_elt(idx, f) } } @@ -828,23 +828,23 @@ impl serialize::Decoder for Decoder/&self { } } - fn read_owned(&self, f: fn() -> T) -> T { + fn read_owned(&self, f: &fn() -> T) -> T { debug!("read_owned()"); f() } - fn read_managed(&self, f: fn() -> T) -> T { + fn read_managed(&self, f: &fn() -> T) -> T { debug!("read_managed()"); f() } - fn read_enum(&self, name: &str, f: fn() -> T) -> T { + fn read_enum(&self, name: &str, f: &fn() -> T) -> T { debug!("read_enum(%s)", name); if name != ~"option" { fail!(~"only supports the option enum") } f() } - fn read_enum_variant(&self, f: fn(uint) -> T) -> T { + fn read_enum_variant(&self, f: &fn(uint) -> T) -> T { debug!("read_enum_variant()"); let idx = match *self.peek() { Null => 0, @@ -853,13 +853,13 @@ impl serialize::Decoder for Decoder/&self { f(idx) } - fn read_enum_variant_arg(&self, idx: uint, f: fn() -> T) -> T { + fn read_enum_variant_arg(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_enum_variant_arg(idx=%u)", idx); if idx != 0 { fail!(~"unknown index") } f() } - fn read_owned_vec(&self, f: fn(uint) -> T) -> T { + fn read_owned_vec(&self, f: &fn(uint) -> T) -> T { debug!("read_owned_vec()"); let len = match *self.peek() { List(ref list) => list.len(), @@ -870,7 +870,7 @@ impl serialize::Decoder for Decoder/&self { res } - fn read_managed_vec(&self, f: fn(uint) -> T) -> T { + fn read_managed_vec(&self, f: &fn(uint) -> T) -> T { debug!("read_owned_vec()"); let len = match *self.peek() { List(ref list) => list.len(), @@ -881,7 +881,7 @@ impl serialize::Decoder for Decoder/&self { res } - fn read_vec_elt(&self, idx: uint, f: fn() -> T) -> T { + fn read_vec_elt(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_vec_elt(idx=%u)", idx); match *self.peek() { List(ref list) => { @@ -892,21 +892,21 @@ impl serialize::Decoder for Decoder/&self { } } - fn read_rec(&self, f: fn() -> T) -> T { + fn read_rec(&self, f: &fn() -> T) -> T { debug!("read_rec()"); let value = f(); self.pop(); value } - fn read_struct(&self, _name: &str, _len: uint, f: fn() -> T) -> T { + fn read_struct(&self, _name: &str, _len: uint, f: &fn() -> T) -> T { debug!("read_struct()"); let value = f(); self.pop(); value } - fn read_field(&self, name: &str, idx: uint, f: fn() -> T) -> T { + fn read_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { debug!("read_rec_field(%s, idx=%u)", name, idx); let top = self.peek(); match *top { @@ -929,14 +929,14 @@ impl serialize::Decoder for Decoder/&self { } } - fn read_tup(&self, len: uint, f: fn() -> T) -> T { + fn read_tup(&self, len: uint, f: &fn() -> T) -> T { debug!("read_tup(len=%u)", len); let value = f(); self.pop(); value } - fn read_tup_elt(&self, idx: uint, f: fn() -> T) -> T { + fn read_tup_elt(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_tup_elt(idx=%u)", idx); match *self.peek() { List(ref list) => { diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 5ab1722ae8399..3a0f299257e09 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -39,7 +39,7 @@ pub pure fn from_vec(v: &[T]) -> @List { * * z - The initial value * * f - The function to apply */ -pub fn foldl(z: T, ls: @List, f: fn(&T, &U) -> T) -> T { +pub fn foldl(z: T, ls: @List, f: &fn(&T, &U) -> T) -> T { let mut accum: T = z; do iter(ls) |elt| { accum = f(&accum, elt);} accum @@ -52,7 +52,7 @@ pub fn foldl(z: T, ls: @List, f: fn(&T, &U) -> T) -> T { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -pub pure fn find(ls: @List, f: fn(&T) -> bool) -> Option { +pub pure fn find(ls: @List, f: &fn(&T) -> bool) -> Option { let mut ls = ls; loop { ls = match *ls { @@ -125,7 +125,7 @@ pure fn push(ll: &mut @list, vv: T) { */ /// Iterate over a list -pub pure fn iter(l: @List, f: fn(&T)) { +pub pure fn iter(l: @List, f: &fn(&T)) { let mut cur = l; loop { cur = match *cur { @@ -139,7 +139,7 @@ pub pure fn iter(l: @List, f: fn(&T)) { } /// Iterate over a list -pub pure fn each(l: @List, f: fn(&T) -> bool) { +pub pure fn each(l: @List, f: &fn(&T) -> bool) { let mut cur = l; loop { cur = match *cur { diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index eb4bd6fe23f47..df254543512b0 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -105,7 +105,7 @@ pub pure fn md4(msg: &[u8]) -> Quad { pub pure fn md4_str(msg: &[u8]) -> ~str { let Quad {a, b, c, d} = md4(msg); - pure fn app(a: u32, b: u32, c: u32, d: u32, f: fn(u32)) { + pure fn app(a: u32, b: u32, c: u32, d: u32, f: &fn(u32)) { f(a); f(b); f(c); f(d); } let mut result = ~""; diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index 0f6434f1b2ba5..18527cfece111 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -134,7 +134,7 @@ pub mod chained { } pub impl T { - pure fn each_entry(&self, blk: fn(@Entry) -> bool) { + pure fn each_entry(&self, blk: &fn(@Entry) -> bool) { // n.b. we can't use vec::iter() here because self.chains // is stored in a mutable location. let mut i = 0u, n = self.chains.len(); @@ -236,17 +236,17 @@ pub mod chained { } } - pure fn each(&self, blk: fn(key: &K, value: &V) -> bool) { + pure fn each(&self, blk: &fn(key: &K, value: &V) -> bool) { for self.each_entry |entry| { if !blk(&entry.key, &entry.value) { break; } } } - pure fn each_key(&self, blk: fn(key: &K) -> bool) { + pure fn each_key(&self, blk: &fn(key: &K) -> bool) { self.each(|k, _v| blk(k)) } - pure fn each_value(&self, blk: fn(value: &V) -> bool) { + pure fn each_value(&self, blk: &fn(value: &V) -> bool) { self.each(|_k, v| blk(v)) } } @@ -260,8 +260,8 @@ pub mod chained { } } - fn update_with_key(&self, key: K, newval: V, ff: fn(K, V, V) -> V) - -> bool { + fn update_with_key(&self, key: K, newval: V, ff: &fn(K, V, V) -> V) + -> bool { /* match self.find(key) { None => return self.insert(key, val), @@ -312,7 +312,7 @@ pub mod chained { } } - fn update(&self, key: K, newval: V, ff: fn(V, V) -> V) -> bool { + fn update(&self, key: K, newval: V, ff: &fn(V, V) -> V) -> bool { return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)); } diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index ed02ea87dac4a..d2d80eb7da803 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -98,87 +98,87 @@ impl serialize::Encoder for Serializer { self.wr.write_str(fmt!("@%?", v)); } - fn emit_borrowed(&self, f: fn()) { + fn emit_borrowed(&self, f: &fn()) { self.wr.write_str(~"&"); f(); } - fn emit_owned(&self, f: fn()) { + fn emit_owned(&self, f: &fn()) { self.wr.write_str(~"~"); f(); } - fn emit_managed(&self, f: fn()) { + fn emit_managed(&self, f: &fn()) { self.wr.write_str(~"@"); f(); } - fn emit_enum(&self, _name: &str, f: fn()) { + fn emit_enum(&self, _name: &str, f: &fn()) { f(); } fn emit_enum_variant(&self, v_name: &str, _v_id: uint, sz: uint, - f: fn()) { + f: &fn()) { self.wr.write_str(v_name); if sz > 0u { self.wr.write_str(~"("); } f(); if sz > 0u { self.wr.write_str(~")"); } } - fn emit_enum_variant_arg(&self, idx: uint, f: fn()) { + fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) { if idx > 0u { self.wr.write_str(~", "); } f(); } - fn emit_borrowed_vec(&self, _len: uint, f: fn()) { + fn emit_borrowed_vec(&self, _len: uint, f: &fn()) { self.wr.write_str(~"&["); f(); self.wr.write_str(~"]"); } - fn emit_owned_vec(&self, _len: uint, f: fn()) { + fn emit_owned_vec(&self, _len: uint, f: &fn()) { self.wr.write_str(~"~["); f(); self.wr.write_str(~"]"); } - fn emit_managed_vec(&self, _len: uint, f: fn()) { + fn emit_managed_vec(&self, _len: uint, f: &fn()) { self.wr.write_str(~"@["); f(); self.wr.write_str(~"]"); } - fn emit_vec_elt(&self, idx: uint, f: fn()) { + fn emit_vec_elt(&self, idx: uint, f: &fn()) { if idx > 0u { self.wr.write_str(~", "); } f(); } - fn emit_rec(&self, f: fn()) { + fn emit_rec(&self, f: &fn()) { self.wr.write_str(~"{"); f(); self.wr.write_str(~"}"); } - fn emit_struct(&self, name: &str, _len: uint, f: fn()) { + fn emit_struct(&self, name: &str, _len: uint, f: &fn()) { self.wr.write_str(fmt!("%s {", name)); f(); self.wr.write_str(~"}"); } - fn emit_field(&self, name: &str, idx: uint, f: fn()) { + fn emit_field(&self, name: &str, idx: uint, f: &fn()) { if idx > 0u { self.wr.write_str(~", "); } self.wr.write_str(name); self.wr.write_str(~": "); f(); } - fn emit_tup(&self, _len: uint, f: fn()) { + fn emit_tup(&self, _len: uint, f: &fn()) { self.wr.write_str(~"("); f(); self.wr.write_str(~")"); } - fn emit_tup_elt(&self, idx: uint, f: fn()) { + fn emit_tup_elt(&self, idx: uint, f: &fn()) { if idx > 0u { self.wr.write_str(~", "); } f(); } diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 676bc68e4e513..31f29ce23f2cd 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -31,7 +31,7 @@ impl BaseIter for PriorityQueue { /// Visit all values in the underlying vector. /// /// The values are **not** visited in order. - pure fn each(&self, f: fn(&T) -> bool) { self.data.each(f) } + pure fn each(&self, f: &fn(&T) -> bool) { self.data.each(f) } pure fn size_hint(&self) -> Option { self.data.size_hint() } } diff --git a/src/libstd/rl.rs b/src/libstd/rl.rs index b2b30c1057ef9..a8b25767ce595 100644 --- a/src/libstd/rl.rs +++ b/src/libstd/rl.rs @@ -68,7 +68,7 @@ pub unsafe fn read(prompt: ~str) -> Option<~str> { } } -pub type CompletionCb = @fn(~str, fn(~str)); +pub type CompletionCb<'self> = @fn(~str, &'self fn(~str)); fn complete_key(_v: @CompletionCb) {} diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index d511ac9744eb3..dd2f5b58fb96a 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -393,7 +393,7 @@ Section: Iterating * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -pub fn loop_chars(rope: Rope, it: fn(c: char) -> bool) -> bool { +pub fn loop_chars(rope: Rope, it: &fn(c: char) -> bool) -> bool { match (rope) { node::Empty => return true, node::Content(x) => return node::loop_chars(x, it) @@ -407,7 +407,7 @@ pub fn loop_chars(rope: Rope, it: fn(c: char) -> bool) -> bool { * * rope - A rope to traverse. It may be empty * * it - A block to execute with each consecutive character of the rope. */ -pub fn iter_chars(rope: Rope, it: fn(char)) { +pub fn iter_chars(rope: Rope, it: &fn(char)) { do loop_chars(rope) |x| { it(x); true @@ -436,7 +436,7 @@ pub fn iter_chars(rope: Rope, it: fn(char)) { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -pub fn loop_leaves(rope: Rope, it: fn(node::Leaf) -> bool) -> bool{ +pub fn loop_leaves(rope: Rope, it: &fn(node::Leaf) -> bool) -> bool{ match (rope) { node::Empty => return true, node::Content(x) => return node::loop_leaves(x, it) @@ -1078,7 +1078,7 @@ pub mod node { return result; } - pub fn loop_chars(node: @Node, it: fn(c: char) -> bool) -> bool { + pub fn loop_chars(node: @Node, it: &fn(c: char) -> bool) -> bool { return loop_leaves(node,|leaf| { str::all_between(*leaf.content, leaf.byte_offset, @@ -1100,7 +1100,7 @@ pub mod node { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ - pub fn loop_leaves(node: @Node, it: fn(Leaf) -> bool) -> bool{ + pub fn loop_leaves(node: @Node, it: &fn(Leaf) -> bool) -> bool{ let mut current = node; loop { match (*current) { diff --git a/src/libstd/semver.rs b/src/libstd/semver.rs index bf4091e1e902d..7b8a06f1b93af 100644 --- a/src/libstd/semver.rs +++ b/src/libstd/semver.rs @@ -140,7 +140,7 @@ condition! { fn take_nonempty_prefix(rdr: io::Reader, ch: char, - pred: fn(char) -> bool) -> (~str, char) { + pred: &fn(char) -> bool) -> (~str, char) { let mut buf = ~""; let mut ch = ch; while pred(ch) { diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 5bbd926ba6beb..0288155d29ebd 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -43,25 +43,25 @@ pub trait Encoder { fn emit_managed_str(&self, v: &str); // Compound types: - fn emit_borrowed(&self, f: fn()); - fn emit_owned(&self, f: fn()); - fn emit_managed(&self, f: fn()); + fn emit_borrowed(&self, f: &fn()); + fn emit_owned(&self, f: &fn()); + fn emit_managed(&self, f: &fn()); - fn emit_enum(&self, name: &str, f: fn()); - fn emit_enum_variant(&self, v_name: &str, v_id: uint, sz: uint, f: fn()); - fn emit_enum_variant_arg(&self, idx: uint, f: fn()); + fn emit_enum(&self, name: &str, f: &fn()); + fn emit_enum_variant(&self, v_name: &str, v_id: uint, sz: uint, f: &fn()); + fn emit_enum_variant_arg(&self, idx: uint, f: &fn()); - fn emit_borrowed_vec(&self, len: uint, f: fn()); - fn emit_owned_vec(&self, len: uint, f: fn()); - fn emit_managed_vec(&self, len: uint, f: fn()); - fn emit_vec_elt(&self, idx: uint, f: fn()); + fn emit_borrowed_vec(&self, len: uint, f: &fn()); + fn emit_owned_vec(&self, len: uint, f: &fn()); + fn emit_managed_vec(&self, len: uint, f: &fn()); + fn emit_vec_elt(&self, idx: uint, f: &fn()); - fn emit_rec(&self, f: fn()); - fn emit_struct(&self, name: &str, _len: uint, f: fn()); - fn emit_field(&self, f_name: &str, f_idx: uint, f: fn()); + fn emit_rec(&self, f: &fn()); + fn emit_struct(&self, name: &str, _len: uint, f: &fn()); + fn emit_field(&self, f_name: &str, f_idx: uint, f: &fn()); - fn emit_tup(&self, len: uint, f: fn()); - fn emit_tup_elt(&self, idx: uint, f: fn()); + fn emit_tup(&self, len: uint, f: &fn()); + fn emit_tup_elt(&self, idx: uint, f: &fn()); } pub trait Decoder { @@ -86,23 +86,23 @@ pub trait Decoder { fn read_managed_str(&self) -> @str; // Compound types: - fn read_enum(&self, name: &str, f: fn() -> T) -> T; - fn read_enum_variant(&self, f: fn(uint) -> T) -> T; - fn read_enum_variant_arg(&self, idx: uint, f: fn() -> T) -> T; + fn read_enum(&self, name: &str, f: &fn() -> T) -> T; + fn read_enum_variant(&self, f: &fn(uint) -> T) -> T; + fn read_enum_variant_arg(&self, idx: uint, f: &fn() -> T) -> T; - fn read_owned(&self, f: fn() -> T) -> T; - fn read_managed(&self, f: fn() -> T) -> T; + fn read_owned(&self, f: &fn() -> T) -> T; + fn read_managed(&self, f: &fn() -> T) -> T; - fn read_owned_vec(&self, f: fn(uint) -> T) -> T; - fn read_managed_vec(&self, f: fn(uint) -> T) -> T; - fn read_vec_elt(&self, idx: uint, f: fn() -> T) -> T; + fn read_owned_vec(&self, f: &fn(uint) -> T) -> T; + fn read_managed_vec(&self, f: &fn(uint) -> T) -> T; + fn read_vec_elt(&self, idx: uint, f: &fn() -> T) -> T; - fn read_rec(&self, f: fn() -> T) -> T; - fn read_struct(&self, name: &str, _len: uint, f: fn() -> T) -> T; - fn read_field(&self, name: &str, idx: uint, f: fn() -> T) -> T; + fn read_rec(&self, f: &fn() -> T) -> T; + fn read_struct(&self, name: &str, _len: uint, f: &fn() -> T) -> T; + fn read_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T; - fn read_tup(&self, sz: uint, f: fn() -> T) -> T; - fn read_tup_elt(&self, idx: uint, f: fn() -> T) -> T; + fn read_tup(&self, sz: uint, f: &fn() -> T) -> T; + fn read_tup_elt(&self, idx: uint, f: &fn() -> T) -> T; } pub trait Encodable { @@ -547,11 +547,11 @@ impl< // In some cases, these should eventually be coded as traits. pub trait EncoderHelpers { - fn emit_from_vec(&self, v: &[T], f: fn(v: &T)); + fn emit_from_vec(&self, v: &[T], f: &fn(v: &T)); } impl EncoderHelpers for S { - fn emit_from_vec(&self, v: &[T], f: fn(v: &T)) { + fn emit_from_vec(&self, v: &[T], f: &fn(v: &T)) { do self.emit_owned_vec(v.len()) { for v.eachi |i, e| { do self.emit_vec_elt(i) { @@ -563,11 +563,11 @@ impl EncoderHelpers for S { } pub trait DecoderHelpers { - fn read_to_vec(&self, f: fn() -> T) -> ~[T]; + fn read_to_vec(&self, f: &fn() -> T) -> ~[T]; } impl DecoderHelpers for D { - fn read_to_vec(&self, f: fn() -> T) -> ~[T] { + fn read_to_vec(&self, f: &fn() -> T) -> ~[T] { do self.read_owned_vec |len| { do vec::from_fn(len) |i| { self.read_vec_elt(i, || f()) diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 84600ac74eeb9..726e7c36abd1b 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -24,7 +24,7 @@ pub struct SmallIntMap { impl BaseIter<(uint, &self/V)> for SmallIntMap { /// Visit all key-value pairs in order - pure fn each(&self, it: fn(&(uint, &self/V)) -> bool) { + pure fn each(&self, it: &fn(&(uint, &self/V)) -> bool) { for uint::range(0, self.v.len()) |i| { match self.v[i] { Some(ref elt) => if !it(&(i, elt)) { break }, @@ -38,7 +38,7 @@ impl BaseIter<(uint, &self/V)> for SmallIntMap { impl ReverseIter<(uint, &self/V)> for SmallIntMap { /// Visit all key-value pairs in reverse order - pure fn each_reverse(&self, it: fn(&(uint, &self/V)) -> bool) { + pure fn each_reverse(&self, it: &fn(&(uint, &self/V)) -> bool) { for uint::range_rev(self.v.len(), 0) |i| { match self.v[i - 1] { Some(ref elt) => if !it(&(i - 1, elt)) { break }, @@ -76,12 +76,12 @@ impl Map for SmallIntMap { } /// Visit all keys in order - pure fn each_key(&self, blk: fn(key: &uint) -> bool) { + pure fn each_key(&self, blk: &fn(key: &uint) -> bool) { self.each(|&(k, _)| blk(&k)) } /// Visit all values in order - pure fn each_value(&self, blk: fn(value: &V) -> bool) { + pure fn each_value(&self, blk: &fn(value: &V) -> bool) { self.each(|&(_, v)| blk(v)) } @@ -133,7 +133,7 @@ pub impl SmallIntMap { pub impl SmallIntMap { fn update_with_key(&mut self, key: uint, val: V, - ff: fn(uint, V, V) -> V) -> bool { + ff: &fn(uint, V, V) -> V) -> bool { let new_val = match self.find(&key) { None => val, Some(orig) => ff(key, *orig, val) @@ -141,7 +141,7 @@ pub impl SmallIntMap { self.insert(key, new_val) } - fn update(&mut self, key: uint, newval: V, ff: fn(V, V) -> V) -> bool { + fn update(&mut self, key: uint, newval: V, ff: &fn(V, V) -> V) -> bool { self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)) } } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index d143c665d8310..2190475d943b6 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -79,8 +79,9 @@ struct SemInner { // a condition variable attached, others should. blocked: Q } + #[doc(hidden)] -enum Sem = Exclusive>; +struct Sem(Exclusive>); #[doc(hidden)] fn new_sem(count: int, q: Q) -> Sem { @@ -135,7 +136,7 @@ pub impl &self/Sem { // FIXME(#3154) move both copies of this into Sem, and unify the 2 structs #[doc(hidden)] pub impl &self/Sem<()> { - fn access(&self, blk: fn() -> U) -> U { + fn access(&self, blk: &fn() -> U) -> U { let mut release = None; unsafe { do task::unkillable { @@ -148,7 +149,7 @@ pub impl &self/Sem<()> { } #[doc(hidden)] pub impl &self/Sem<~[Waitqueue]> { - fn access(&self, blk: fn() -> U) -> U { + fn access(&self, blk: &fn() -> U) -> U { let mut release = None; unsafe { do task::unkillable { @@ -332,7 +333,7 @@ pub impl Condvar/&self { #[inline(always)] #[doc(hidden)] fn check_cvar_bounds(out_of_bounds: Option, id: uint, act: &str, - blk: fn() -> U) -> U { + blk: &fn() -> U) -> U { match out_of_bounds { Some(0) => fail!(fmt!("%s with illegal ID %u - this lock has no condvars!", @@ -347,7 +348,7 @@ fn check_cvar_bounds(out_of_bounds: Option, id: uint, act: &str, #[doc(hidden)] pub impl Sem<~[Waitqueue]> { // The only other place that condvars get built is rwlock_write_mode. - fn access_cond(&self, blk: fn(c: &Condvar) -> U) -> U { + fn access_cond(&self, blk: &fn(c: &Condvar) -> U) -> U { do self.access { blk(&Condvar { sem: self }) } } } @@ -385,7 +386,7 @@ pub impl Semaphore { fn release(&self) { (&self.sem).release() } /// Run a function with ownership of one of the semaphore's resources. - fn access(&self, blk: fn() -> U) -> U { (&self.sem).access(blk) } + fn access(&self, blk: &fn() -> U) -> U { (&self.sem).access(blk) } } /**************************************************************************** @@ -421,10 +422,10 @@ impl Clone for Mutex { pub impl Mutex { /// Run a function with ownership of the mutex. - fn lock(&self, blk: fn() -> U) -> U { (&self.sem).access(blk) } + fn lock(&self, blk: &fn() -> U) -> U { (&self.sem).access(blk) } /// Run a function with ownership of the mutex and a handle to a condvar. - fn lock_cond(&self, blk: fn(c: &Condvar) -> U) -> U { + fn lock_cond(&self, blk: &fn(c: &Condvar) -> U) -> U { (&self.sem).access_cond(blk) } } @@ -480,7 +481,7 @@ pub impl RWlock { * Run a function with the rwlock in read mode. Calls to 'read' from other * tasks may run concurrently with this one. */ - fn read(&self, blk: fn() -> U) -> U { + fn read(&self, blk: &fn() -> U) -> U { let mut release = None; unsafe { do task::unkillable { @@ -511,7 +512,7 @@ pub impl RWlock { * Run a function with the rwlock in write mode. No calls to 'read' or * 'write' from other tasks will run concurrently with this one. */ - fn write(&self, blk: fn() -> U) -> U { + fn write(&self, blk: &fn() -> U) -> U { unsafe { do task::unkillable { (&self.order_lock).acquire(); @@ -529,7 +530,7 @@ pub impl RWlock { * the waiting task is signalled. (Note: a writer that waited and then * was signalled might reacquire the lock before other waiting writers.) */ - fn write_cond(&self, blk: fn(c: &Condvar) -> U) -> U { + fn write_cond(&self, blk: &fn(c: &Condvar) -> U) -> U { // NB: You might think I should thread the order_lock into the cond // wait call, so that it gets waited on before access_lock gets // reacquired upon being woken up. However, (a) this would be not @@ -564,7 +565,7 @@ pub impl RWlock { * } * ~~~ */ - fn write_downgrade(&self, blk: fn(v: RWlockWriteMode) -> U) -> U { + fn write_downgrade(&self, blk: &fn(v: RWlockWriteMode) -> U) -> U { // Implementation slightly different from the slicker 'write's above. // The exit path is conditional on whether the caller downgrades. let mut _release = None; @@ -692,16 +693,16 @@ impl Drop for RWlockReadMode/&self { fn finalize(&self) {} } pub impl RWlockWriteMode/&self { /// Access the pre-downgrade rwlock in write mode. - fn write(&self, blk: fn() -> U) -> U { blk() } + fn write(&self, blk: &fn() -> U) -> U { blk() } /// Access the pre-downgrade rwlock in write mode with a condvar. - fn write_cond(&self, blk: fn(c: &Condvar) -> U) -> U { + fn write_cond(&self, blk: &fn(c: &Condvar) -> U) -> U { blk(&Condvar { sem: &self.lock.access_lock }) } } pub impl RWlockReadMode/&self { /// Access the post-downgrade rwlock in read mode. - fn read(&self, blk: fn() -> U) -> U { blk() } + fn read(&self, blk: &fn() -> U) -> U { blk() } } /**************************************************************************** @@ -1082,7 +1083,7 @@ mod tests { #[cfg(test)] pub enum RWlockMode { Read, Write, Downgrade, DowngradeRead } #[cfg(test)] - pub fn lock_rwlock_in_mode(x: &RWlock, mode: RWlockMode, blk: fn()) { + pub fn lock_rwlock_in_mode(x: &RWlock, mode: RWlockMode, blk: &fn()) { match mode { Read => x.read(blk), Write => x.write(blk), @@ -1239,7 +1240,7 @@ mod tests { dg1: bool, dg2: bool) { // Much like the mutex broadcast test. Downgrade-enabled. - fn lock_cond(x: &RWlock, downgrade: bool, blk: fn(c: &Condvar)) { + fn lock_cond(x: &RWlock, downgrade: bool, blk: &fn(c: &Condvar)) { if downgrade { do x.write_downgrade |mode| { (&mode).write_cond(blk) diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index f06f64dde010b..72351aac33975 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -96,7 +96,7 @@ impl Ord for TreeMap { impl<'self, K: TotalOrd, V> BaseIter<(&'self K, &'self V)> for TreeMap { /// Visit all key-value pairs in order - pure fn each(&self, f: fn(&(&self/K, &self/V)) -> bool) { + pure fn each(&self, f: &fn(&(&self/K, &self/V)) -> bool) { each(&self.root, f) } pure fn size_hint(&self) -> Option { Some(self.len()) } @@ -107,7 +107,7 @@ impl<'self, K: TotalOrd, V> for TreeMap { /// Visit all key-value pairs in reverse order - pure fn each_reverse(&self, f: fn(&(&self/K, &self/V)) -> bool) { + pure fn each_reverse(&self, f: &fn(&(&self/K, &self/V)) -> bool) { each_reverse(&self.root, f); } } @@ -135,10 +135,12 @@ impl Map for TreeMap { } /// Visit all keys in order - pure fn each_key(&self, f: fn(&K) -> bool) { self.each(|&(k, _)| f(k)) } + pure fn each_key(&self, f: &fn(&K) -> bool) { self.each(|&(k, _)| f(k)) } /// Visit all values in order - pure fn each_value(&self, f: fn(&V) -> bool) { self.each(|&(_, v)| f(v)) } + pure fn each_value(&self, f: &fn(&V) -> bool) { + self.each(|&(_, v)| f(v)) + } /// Return the value corresponding to the key in the map pure fn find(&self, key: &K) -> Option<&self/V> { @@ -180,12 +182,12 @@ pub impl TreeMap { static pure fn new() -> TreeMap { TreeMap{root: None, length: 0} } /// Visit all keys in reverse order - pure fn each_key_reverse(&self, f: fn(&K) -> bool) { + pure fn each_key_reverse(&self, f: &fn(&K) -> bool) { self.each_reverse(|&(k, _)| f(k)) } /// Visit all values in reverse order - pure fn each_value_reverse(&self, f: fn(&V) -> bool) { + pure fn each_value_reverse(&self, f: &fn(&V) -> bool) { self.each_reverse(|&(_, v)| f(v)) } @@ -225,7 +227,7 @@ pub fn map_next(iter: &mut TreeMapIterator/&r) /// Advance the iterator through the map pub fn map_advance(iter: &mut TreeMapIterator/&r, - f: fn((&r/K, &r/V)) -> bool) { + f: &fn((&r/K, &r/V)) -> bool) { loop { match map_next(iter) { Some(x) => { @@ -242,13 +244,13 @@ pub struct TreeSet { impl BaseIter for TreeSet { /// Visit all values in order - pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) } + pure fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) } pure fn size_hint(&self) -> Option { Some(self.len()) } } impl ReverseIter for TreeSet { /// Visit all values in reverse order - pure fn each_reverse(&self, f: fn(&T) -> bool) { + pure fn each_reverse(&self, f: &fn(&T) -> bool) { self.map.each_key_reverse(f) } } @@ -350,7 +352,7 @@ impl Set for TreeSet { } /// Visit the values (in-order) representing the difference - pure fn difference(&self, other: &TreeSet, f: fn(&T) -> bool) { + pure fn difference(&self, other: &TreeSet, f: &fn(&T) -> bool) { let mut x = self.iter(); let mut y = other.iter(); @@ -383,7 +385,7 @@ impl Set for TreeSet { /// Visit the values (in-order) representing the symmetric difference pure fn symmetric_difference(&self, other: &TreeSet, - f: fn(&T) -> bool) { + f: &fn(&T) -> bool) { let mut x = self.iter(); let mut y = other.iter(); @@ -422,7 +424,7 @@ impl Set for TreeSet { } /// Visit the values (in-order) representing the intersection - pure fn intersection(&self, other: &TreeSet, f: fn(&T) -> bool) { + pure fn intersection(&self, other: &TreeSet, f: &fn(&T) -> bool) { let mut x = self.iter(); let mut y = other.iter(); @@ -449,7 +451,7 @@ impl Set for TreeSet { } /// Visit the values (in-order) representing the union - pure fn union(&self, other: &TreeSet, f: fn(&T) -> bool) { + pure fn union(&self, other: &TreeSet, f: &fn(&T) -> bool) { let mut x = self.iter(); let mut y = other.iter(); @@ -508,7 +510,7 @@ pub fn set_next(iter: &mut TreeSetIterator/&r) -> Option<&r/T> { /// Advance the iterator through the set fn set_advance(iter: &mut TreeSetIterator/&r, - f: fn(&r/T) -> bool) { + f: &fn(&r/T) -> bool) { do map_advance(&mut iter.iter) |(k, _)| { f(k) } } @@ -530,7 +532,7 @@ pub impl TreeNode { } pure fn each(node: &r/Option<~TreeNode>, - f: fn(&(&r/K, &r/V)) -> bool) { + f: &fn(&(&r/K, &r/V)) -> bool) { for node.each |x| { each(&x.left, f); if f(&(&x.key, &x.value)) { each(&x.right, f) } @@ -538,7 +540,7 @@ pure fn each(node: &r/Option<~TreeNode>, } pure fn each_reverse(node: &r/Option<~TreeNode>, - f: fn(&(&r/K, &r/V)) -> bool) { + f: &fn(&(&r/K, &r/V)) -> bool) { for node.each |x| { each_reverse(&x.right, f); if f(&(&x.key, &x.value)) { each_reverse(&x.left, f) } diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index eac6e090f1f10..68a6f8effaa77 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -269,7 +269,7 @@ pub impl Context { Decodable>( // FIXME(#5121) @self, fn_name:&str, - blk: fn(@Mut)->Work) -> Work { + blk: &fn(@Mut)->Work) -> Work { let p = @Mut(Prep {ctxt: self, fn_name: fn_name.to_owned(), declared_inputs: LinearMap::new()}); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f3e73823f69b3..27dba9c2b5ebc 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1086,16 +1086,11 @@ pub enum variant_kind { #[auto_encode] #[auto_decode] #[deriving_eq] -pub struct enum_def_ { +pub struct enum_def { variants: ~[variant], common: Option<@struct_def>, } -#[auto_encode] -#[auto_decode] -#[deriving_eq] -pub enum enum_def = enum_def_; - #[auto_encode] #[auto_decode] #[deriving_eq] diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 3001fe8069c93..a7d5c0ce75fa0 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -423,7 +423,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str { } pub fn node_item_query(items: map, id: node_id, - query: fn(@item) -> Result, + query: &fn(@item) -> Result, +error_msg: ~str) -> Result { match items.find(&id) { Some(node_item(it, _)) => query(it), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 7b0e72e6e956e..35b188a248fd4 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -516,7 +516,7 @@ pub pure fn is_item_impl(item: @ast::item) -> bool { } } -pub fn walk_pat(pat: @pat, it: fn(@pat)) { +pub fn walk_pat(pat: @pat, it: &fn(@pat)) { it(pat); match pat.node { pat_ident(_, _, Some(p)) => walk_pat(p, it), diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 3397ca91c9624..0d6ece8ad92f1 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -35,11 +35,11 @@ pub trait Pos { } /// A byte offset -pub enum BytePos = uint; +pub struct BytePos(uint); /// A character offset. Because of multibyte utf8 characters, a byte offset /// is not equivalent to a character offset. The CodeMap will convert BytePos /// values to CharPos values as necessary. -pub enum CharPos = uint; +pub struct CharPos(uint); // XXX: Lots of boilerplate in these impls, but so far my attempts to fix // have been unsuccessful diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 33e734fbd64cc..4e177fecec9e6 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -306,7 +306,7 @@ fn print_macro_backtrace(cm: @codemap::CodeMap, sp: span) { pub fn expect(diag: span_handler, opt: Option, - msg: fn() -> ~str) -> T { + msg: &fn() -> ~str) -> T { match opt { Some(ref t) => (*t), None => diag.handler().bug(msg()) diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index ecb5be6cc3c61..c99d89776431a 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -432,7 +432,7 @@ fn mk_impl( ty_param: ast::TyParam, path: @ast::path, generics: &ast::Generics, - f: fn(@ast::Ty) -> @ast::method + f: &fn(@ast::Ty) -> @ast::method ) -> @ast::item { /*! * @@ -1256,51 +1256,51 @@ mod test { fn emit_owned_str(&self, +_v: &str) { self.add_unknown_to_log(); } fn emit_managed_str(&self, +_v: &str) { self.add_unknown_to_log(); } - fn emit_borrowed(&self, f: fn()) { self.add_unknown_to_log(); f() } - fn emit_owned(&self, f: fn()) { self.add_unknown_to_log(); f() } - fn emit_managed(&self, f: fn()) { self.add_unknown_to_log(); f() } + fn emit_borrowed(&self, f: &fn()) { self.add_unknown_to_log(); f() } + fn emit_owned(&self, f: &fn()) { self.add_unknown_to_log(); f() } + fn emit_managed(&self, f: &fn()) { self.add_unknown_to_log(); f() } - fn emit_enum(&self, name: &str, f: fn()) { + fn emit_enum(&self, name: &str, f: &fn()) { self.add_to_log(CallToEmitEnum(name.to_str())); f(); } fn emit_enum_variant(&self, name: &str, +id: uint, - +cnt: uint, f: fn()) { + +cnt: uint, f: &fn()) { self.add_to_log(CallToEmitEnumVariant (name.to_str(),id,cnt)); f(); } - fn emit_enum_variant_arg(&self, +idx: uint, f: fn()) { + fn emit_enum_variant_arg(&self, +idx: uint, f: &fn()) { self.add_to_log(CallToEmitEnumVariantArg (idx)); f(); } - fn emit_borrowed_vec(&self, +_len: uint, f: fn()) { + fn emit_borrowed_vec(&self, +_len: uint, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_owned_vec(&self, +_len: uint, f: fn()) { + fn emit_owned_vec(&self, +_len: uint, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_managed_vec(&self, +_len: uint, f: fn()) { + fn emit_managed_vec(&self, +_len: uint, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_vec_elt(&self, +_idx: uint, f: fn()) { + fn emit_vec_elt(&self, +_idx: uint, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_rec(&self, f: fn()) { + fn emit_rec(&self, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_struct(&self, name: &str, +len: uint, f: fn()) { + fn emit_struct(&self, name: &str, +len: uint, f: &fn()) { self.add_to_log(CallToEmitStruct (name.to_str(),len)); f(); } - fn emit_field(&self, name: &str, +idx: uint, f: fn()) { + fn emit_field(&self, name: &str, +idx: uint, f: &fn()) { self.add_to_log(CallToEmitField (name.to_str(),idx)); f(); } - fn emit_tup(&self, +_len: uint, f: fn()) { + fn emit_tup(&self, +_len: uint, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_tup_elt(&self, +_idx: uint, f: fn()) { + fn emit_tup_elt(&self, +_idx: uint, f: &fn()) { self.add_unknown_to_log(); f(); } } @@ -1327,16 +1327,4 @@ mod test { CallToEmitEnumVariantArg (1), CallToEmitUint (44)]); } - - pub enum BPos = uint; - - #[auto_encode] - pub struct HasPos { pos : BPos } - - #[test] fn encode_newtype_test () { - check_equal (to_call_log (HasPos {pos:BPos(48)}), - ~[CallToEmitStruct(~"HasPos",1), - CallToEmitField(~"pos",0), - CallToEmitUint(48)]); - } } diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 001e1b0daf63f..fd8b2dbf72f81 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -238,9 +238,7 @@ impl to_type_decls for state { cx.item_enum_poly( name, self.span, - ast::enum_def(enum_def_ { - variants: items_msg, - common: None }), + ast::enum_def { variants: items_msg, common: None }, cx.strip_bounds(&self.generics) ) ] diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 329b3f59b1e33..dc9abd536d11f 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -104,7 +104,7 @@ pub impl state_ { /// Iterate over the states that can be reached in one message /// from this state. - fn reachable(&self, f: fn(state) -> bool) { + fn reachable(&self, f: &fn(state) -> bool) { for self.messages.each |m| { match *m { message(_, _, _, _, Some(next_state { state: ref id, _ })) => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 2a5fe7887704d..427760c920f6d 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -254,16 +254,14 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ { } item_enum(ref enum_definition, ref generics) => { item_enum( - ast::enum_def( - ast::enum_def_ { - variants: do enum_definition.variants.map |x| { - fld.fold_variant(x) - }, - common: do enum_definition.common.map |x| { - fold_struct_def(*x, fld) - } + ast::enum_def { + variants: do enum_definition.variants.map |x| { + fld.fold_variant(x) + }, + common: do enum_definition.common.map |x| { + fold_struct_def(*x, fld) } - ), + }, fold_generics(generics, fld)) } item_struct(ref struct_def, ref generics) => { @@ -684,10 +682,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ { fold_struct_def(*x, fld) }; kind = enum_variant_kind( - ast::enum_def(ast::enum_def_ { - variants: variants, - common: common - }) + ast::enum_def { variants: variants, common: common } ); } } diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 16db384bb062c..ba0c7a71b7c17 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -122,7 +122,7 @@ impl Eq for OptVec { } impl BaseIter for OptVec { - pure fn each(&self, blk: fn(v: &A) -> bool) { + pure fn each(&self, blk: &fn(v: &A) -> bool) { match *self { Empty => {} Vec(ref v) => v.each(blk) @@ -136,31 +136,31 @@ impl BaseIter for OptVec { impl iter::ExtendedIter for OptVec { #[inline(always)] - pure fn eachi(&self, blk: fn(+v: uint, v: &A) -> bool) { + pure fn eachi(&self, blk: &fn(+v: uint, v: &A) -> bool) { iter::eachi(self, blk) } #[inline(always)] - pure fn all(&self, blk: fn(&A) -> bool) -> bool { + pure fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } #[inline(always)] - pure fn any(&self, blk: fn(&A) -> bool) -> bool { + pure fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } #[inline(always)] - pure fn foldl(&self, +b0: B, blk: fn(&B, &A) -> B) -> B { + pure fn foldl(&self, +b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } #[inline(always)] - pure fn position(&self, f: fn(&A) -> bool) -> Option { + pure fn position(&self, f: &fn(&A) -> bool) -> Option { iter::position(self, f) } #[inline(always)] - pure fn map_to_vec(&self, op: fn(&A) -> B) -> ~[B] { + pure fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } #[inline(always)] - pure fn flat_map_to_vec>(&self, op: fn(&A) -> IB) + pure fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } @@ -176,13 +176,13 @@ impl iter::EqIter for OptVec { impl iter::CopyableIter for OptVec { #[inline(always)] - pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { + pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } #[inline(always)] pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } #[inline(always)] - pure fn find(&self, f: fn(&A) -> bool) -> Option { + pure fn find(&self, f: &fn(&A) -> bool) -> Option { iter::find(self, f) } } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 7af2204fafd09..c7b9a769293d6 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -248,7 +248,7 @@ pub impl Parser { fn parse_seq_to_before_gt( &self, sep: Option, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> OptVec { let mut first = true; let mut v = opt_vec::Empty; @@ -269,7 +269,7 @@ pub impl Parser { fn parse_seq_to_gt( &self, sep: Option, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> OptVec { let v = self.parse_seq_to_before_gt(sep, f); self.expect_gt(); @@ -283,7 +283,7 @@ pub impl Parser { &self, ket: &token::Token, sep: SeqSep, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> ~[T] { let val = self.parse_seq_to_before_end(ket, sep, f); self.bump(); @@ -297,7 +297,7 @@ pub impl Parser { &self, ket: &token::Token, sep: SeqSep, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> ~[T] { let mut first: bool = true; let mut v: ~[T] = ~[]; @@ -323,7 +323,7 @@ pub impl Parser { bra: &token::Token, ket: &token::Token, sep: SeqSep, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> ~[T] { self.expect(bra); let result = self.parse_seq_to_before_end(ket, sep, f); @@ -338,7 +338,7 @@ pub impl Parser { bra: &token::Token, ket: &token::Token, sep: SeqSep, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> spanned<~[T]> { let lo = self.span.lo; self.expect(bra); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index a1fc7230dd1f0..fd84f8670686b 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -173,7 +173,7 @@ pub fn parse_tts_from_source_str( } pub fn parse_from_source_str( - f: fn (Parser) -> T, + f: &fn (Parser) -> T, name: ~str, ss: codemap::FileSubstr, source: @~str, +cfg: ast::crate_cfg, diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 97ff175da07fe..ef858a2d5ebd1 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -53,6 +53,8 @@ pub enum ObsoleteSyntax { ObsoleteRecordPattern, ObsoleteAssertion, ObsoletePostFnTySigil, + ObsoleteBareFnType, + ObsoleteNewtypeEnum, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -166,6 +168,14 @@ pub impl Parser { "Rather than `fn@`, `fn~`, or `fn&`, \ write `@fn`, `~fn`, and `&fn` respectively" ), + ObsoleteBareFnType => ( + "bare function type", + "use `&fn` or `extern fn` instead" + ), + ObsoleteNewtypeEnum => ( + "newtype enum", + "instead of `enum Foo = int`, write `struct Foo(int)`" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 38cd09abad42b..99c1c2cb1feec 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -77,6 +77,7 @@ use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer}; use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility}; use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern}; use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil}; +use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum}; use parse::prec::{as_prec, token_to_binop}; use parse::token::{can_begin_expr, is_ident, is_ident_or_path}; use parse::token::{is_plain_ident, INTERPOLATED, special_idents}; @@ -647,8 +648,9 @@ pub impl Parser { } else if self.eat_keyword(&~"extern") { self.parse_ty_bare_fn() } else if self.token_is_closure_keyword(© *self.token) { - // self.warn(fmt!("Old-school closure keyword")); - self.parse_ty_closure(ast::BorrowedSigil, None) + let result = self.parse_ty_closure(ast::BorrowedSigil, None); + self.obsolete(*self.last_span, ObsoleteBareFnType); + result } else if *self.token == token::MOD_SEP || is_ident_or_path(&*self.token) { let path = self.parse_path_with_tps(colons_before_params); @@ -1829,7 +1831,7 @@ pub impl Parser { fn parse_sugary_call_expr(&self, keyword: ~str, sugar: CallSugar, - ctor: fn(+v: @expr) -> expr_) -> @expr { + ctor: &fn(+v: @expr) -> expr_) -> @expr { let lo = self.last_span; // Parse the callee `foo` in // for foo || { @@ -2769,7 +2771,7 @@ pub impl Parser { (lifetimes, opt_vec::take_vec(result)) } - fn parse_fn_decl(&self, parse_arg_fn: fn(&Parser) -> arg_or_capture_item) + fn parse_fn_decl(&self, parse_arg_fn: &fn(&Parser) -> arg_or_capture_item) -> fn_decl { let args_or_capture_items: ~[arg_or_capture_item] = @@ -2813,10 +2815,10 @@ pub impl Parser { fn parse_fn_decl_with_self( &self, parse_arg_fn: - fn(&Parser) -> arg_or_capture_item + &fn(&Parser) -> arg_or_capture_item ) -> (self_ty, fn_decl) { fn maybe_parse_self_ty( - cnstr: fn(+v: mutability) -> ast::self_ty_, + cnstr: &fn(+v: mutability) -> ast::self_ty_, p: &Parser ) -> ast::self_ty_ { // We need to make sure it isn't a mode or a type @@ -3765,7 +3767,7 @@ pub impl Parser { enum"); } - enum_def(ast::enum_def_ { variants: variants, common: common_fields }) + ast::enum_def { variants: variants, common: common_fields } } fn parse_item_enum(&self) -> item_info { @@ -3788,12 +3790,12 @@ pub impl Parser { vis: public, }); + self.obsolete(*self.last_span, ObsoleteNewtypeEnum); + return ( id, item_enum( - enum_def( - ast::enum_def_ { variants: ~[variant], common: None } - ), + ast::enum_def { variants: ~[variant], common: None }, generics), None ); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index c81c1c8bd0e1a..49899fdeec415 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -314,8 +314,8 @@ pub fn commasep(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN)) { } -pub fn commasep_cmnt(s: @ps, b: breaks, elts: ~[IN], op: fn(@ps, IN), - get_span: fn(IN) -> codemap::span) { +pub fn commasep_cmnt(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN), + get_span: &fn(IN) -> codemap::span) { box(s, 0u, b); let len = vec::len::(elts); let mut i = 0u; @@ -612,36 +612,11 @@ pub fn print_item(s: @ps, &&item: @ast::item) { pub fn print_enum_def(s: @ps, enum_definition: ast::enum_def, generics: &ast::Generics, ident: ast::ident, span: codemap::span, visibility: ast::visibility) { - let mut newtype = - vec::len(enum_definition.variants) == 1u && - ident == enum_definition.variants[0].node.name; - if newtype { - match enum_definition.variants[0].node.kind { - ast::tuple_variant_kind(ref args) if args.len() == 1 => {} - _ => newtype = false - } - } - if newtype { - ibox(s, indent_unit); - word_space(s, visibility_qualified(visibility, ~"enum")); - } else { - head(s, visibility_qualified(visibility, ~"enum")); - } - + head(s, visibility_qualified(visibility, ~"enum")); print_ident(s, ident); print_generics(s, generics); space(s.s); - if newtype { - word_space(s, ~"="); - match /*bad*/ copy enum_definition.variants[0].node.kind { - ast::tuple_variant_kind(args) => print_type(s, args[0].ty), - _ => fail!(~"newtype syntax with struct?") - } - word(s.s, ~";"); - end(s); - } else { - print_variants(s, enum_definition.variants, span); - } + print_variants(s, enum_definition.variants, span); } pub fn print_variants(s: @ps, diff --git a/src/test/auxiliary/cci_impl_lib.rs b/src/test/auxiliary/cci_impl_lib.rs index ab744d60ac228..b7149be00cca9 100644 --- a/src/test/auxiliary/cci_impl_lib.rs +++ b/src/test/auxiliary/cci_impl_lib.rs @@ -11,12 +11,12 @@ #[link(name="cci_impl_lib", vers="0.0")]; trait uint_helpers { - fn to(v: uint, f: fn(uint)); + fn to(v: uint, f: &fn(uint)); } impl uint_helpers for uint { #[inline] - fn to(v: uint, f: fn(uint)) { + fn to(v: uint, f: &fn(uint)) { let mut i = self; while i < v { f(i); diff --git a/src/test/auxiliary/cci_iter_lib.rs b/src/test/auxiliary/cci_iter_lib.rs index 6e2c36578ff1c..107f0ac32a4bf 100644 --- a/src/test/auxiliary/cci_iter_lib.rs +++ b/src/test/auxiliary/cci_iter_lib.rs @@ -12,7 +12,7 @@ #[legacy_modes]; #[inline] -pub fn iter(v: ~[T], f: fn(T)) { +pub fn iter(v: ~[T], f: &fn(T)) { let mut i = 0u; let n = vec::len(v); while i < n { diff --git a/src/test/auxiliary/cci_no_inline_lib.rs b/src/test/auxiliary/cci_no_inline_lib.rs index 0b0492f13b8c5..407f62adb0251 100644 --- a/src/test/auxiliary/cci_no_inline_lib.rs +++ b/src/test/auxiliary/cci_no_inline_lib.rs @@ -11,7 +11,7 @@ #[link(name="cci_no_inline_lib", vers="0.0")]; // same as cci_iter_lib, more-or-less, but not marked inline -pub fn iter(v: ~[uint], f: fn(uint)) { +pub fn iter(v: ~[uint], f: &fn(uint)) { let mut i = 0u; let n = vec::len(v); while i < n { diff --git a/src/test/auxiliary/issue_2472_b.rs b/src/test/auxiliary/issue_2472_b.rs index e7a9295472554..1dd30edcc980b 100644 --- a/src/test/auxiliary/issue_2472_b.rs +++ b/src/test/auxiliary/issue_2472_b.rs @@ -9,13 +9,13 @@ // except according to those terms. -enum S = (); +pub struct S(()); pub impl S { fn foo() { } } -trait T { +pub trait T { fn bar(); } diff --git a/src/test/auxiliary/issue_3136_a.rs b/src/test/auxiliary/issue_3136_a.rs index 4de0b900dd3ea..c80457ef1e92c 100644 --- a/src/test/auxiliary/issue_3136_a.rs +++ b/src/test/auxiliary/issue_3136_a.rs @@ -11,7 +11,7 @@ trait x { fn use_x(); } -enum y = (); +struct y(()); impl x for y { fn use_x() { struct foo { //~ ERROR quux diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index a1896c660eb6f..c86d2fe4d9332 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -25,7 +25,7 @@ struct Results { } fn timed(result: &mut float, - op: fn()) { + op: &fn()) { let start = std::time::precise_time_s(); op(); let end = std::time::precise_time_s(); diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index ab441277c62a3..adfde66e57a01 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -24,7 +24,7 @@ struct Results { delete_strings: float } -fn timed(result: &mut float, op: fn()) { +fn timed(result: &mut float, op: &fn()) { let start = std::time::precise_time_s(); op(); let end = std::time::precise_time_s(); @@ -33,7 +33,7 @@ fn timed(result: &mut float, op: fn()) { pub impl Results { fn bench_int>(&mut self, rng: @rand::Rng, num_keys: uint, - rand_cap: uint, f: fn() -> T) { + rand_cap: uint, f: &fn() -> T) { { let mut set = f(); do timed(&mut self.sequential_ints) { @@ -71,7 +71,7 @@ pub impl Results { } fn bench_str>(&mut self, rng: @rand::Rng, num_keys: uint, - f: fn() -> T) { + f: &fn() -> T) { { let mut set = f(); do timed(&mut self.sequential_strings) { diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index e026e78ffb81d..e8fb86fda7889 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -34,7 +34,7 @@ fn main() { bench!(vec_push_all); } -fn maybe_run_test(argv: &[~str], name: ~str, test: fn()) { +fn maybe_run_test(argv: &[~str], name: ~str, test: &fn()) { let mut run_test = false; if os::getenv(~"RUST_BENCH").is_some() { run_test = true } diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs index f95bc3fc35a18..731605e82bd1f 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -71,7 +71,7 @@ macro_rules! follow ( ) fn switch(+endp: core::pipes::RecvPacketBuffered, - f: fn(+v: Option) -> U) -> U { + f: &fn(+v: Option) -> U) -> U { f(core::pipes::try_recv(endp)) } @@ -131,7 +131,7 @@ fn unbounded(count: uint) { } } -fn timeit(f: fn()) -> float { +fn timeit(f: &fn()) -> float { let start = precise_time_s(); f(); let stop = precise_time_s(); diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 35c6694ee0c74..fc980e3d6db53 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -85,7 +85,7 @@ fn update_freq(mm: HashMap<~[u8], uint>, key: &[u8]) { // i.e., for "hello" and windows of size four, // run it("hell") and it("ello"), then return "llo" fn windows_with_carry(bb: &[u8], nn: uint, - it: fn(window: &[u8])) -> ~[u8] { + it: &fn(window: &[u8])) -> ~[u8] { let mut ii = 0u; let len = vec::len(bb); diff --git a/src/test/compile-fail/access-mode-in-closures.rs b/src/test/compile-fail/access-mode-in-closures.rs index 24897608880ca..f6b9a82ec676c 100644 --- a/src/test/compile-fail/access-mode-in-closures.rs +++ b/src/test/compile-fail/access-mode-in-closures.rs @@ -9,7 +9,7 @@ // except according to those terms. -enum sty = ~[int]; +struct sty(~[int]); fn unpack(_unpack: &fn(v: &sty) -> ~[int]) {} diff --git a/src/test/compile-fail/arg-style-mismatch.rs b/src/test/compile-fail/arg-style-mismatch.rs index f07a2be1edf66..2efc16de8307f 100644 --- a/src/test/compile-fail/arg-style-mismatch.rs +++ b/src/test/compile-fail/arg-style-mismatch.rs @@ -11,5 +11,5 @@ // error-pattern: mismatched types fn f(&&_x: int) {} -fn g(_a: fn(+v: int)) {} +fn g(_a: &fn(+v: int)) {} fn main() { g(f); } diff --git a/src/test/compile-fail/bad-for-loop.rs b/src/test/compile-fail/bad-for-loop.rs index bda463031fae9..8835c577fa8fd 100644 --- a/src/test/compile-fail/bad-for-loop.rs +++ b/src/test/compile-fail/bad-for-loop.rs @@ -9,6 +9,6 @@ // except according to those terms. fn main() { - fn baz(_x: fn(y: int) -> int) {} + fn baz(_x: &fn(y: int) -> int) {} for baz |_e| { } //~ ERROR A `for` loop iterator should expect a closure that returns `bool` } diff --git a/src/test/compile-fail/block-coerce-no-2.rs b/src/test/compile-fail/block-coerce-no-2.rs index b2265f5e959a0..95ff995258fad 100644 --- a/src/test/compile-fail/block-coerce-no-2.rs +++ b/src/test/compile-fail/block-coerce-no-2.rs @@ -15,7 +15,7 @@ fn main() { fn f(f: extern fn(extern fn(extern fn()))) { } - fn g(f: extern fn(fn())) { + fn g(f: extern fn(&fn())) { } f(g); diff --git a/src/test/compile-fail/block-coerce-no.rs b/src/test/compile-fail/block-coerce-no.rs index af93b1891e840..980dc66b4af59 100644 --- a/src/test/compile-fail/block-coerce-no.rs +++ b/src/test/compile-fail/block-coerce-no.rs @@ -11,9 +11,9 @@ // Make sure that fn-to-block coercion isn't incorrectly lifted over // other tycons. -fn coerce(b: fn()) -> extern fn() { - fn lol(+f: extern fn(+v: fn()) -> extern fn(), - +g: fn()) -> extern fn() { return f(g); } +fn coerce(b: &fn()) -> extern fn() { + fn lol(+f: extern fn(+v: &fn()) -> extern fn(), + +g: &fn()) -> extern fn() { return f(g); } fn fn_id(+f: extern fn()) -> extern fn() { return f } return lol(fn_id, b); //~^ ERROR mismatched types diff --git a/src/test/compile-fail/borrowck-assign-comp-idx.rs b/src/test/compile-fail/borrowck-assign-comp-idx.rs index 9c175ed42b665..25b56abb5ba00 100644 --- a/src/test/compile-fail/borrowck-assign-comp-idx.rs +++ b/src/test/compile-fail/borrowck-assign-comp-idx.rs @@ -22,7 +22,7 @@ fn a() { p[0] = 5; //~ ERROR assigning to mutable vec content prohibited due to outstanding loan } -fn borrow(_x: &[int], _f: fn()) {} +fn borrow(_x: &[int], _f: &fn()) {} fn b() { // here we alias the mutable vector into an imm slice and try to diff --git a/src/test/compile-fail/borrowck-assign-to-enum.rs b/src/test/compile-fail/borrowck-assign-to-enum.rs index 25a320061d451..a35d88a76f393 100644 --- a/src/test/compile-fail/borrowck-assign-to-enum.rs +++ b/src/test/compile-fail/borrowck-assign-to-enum.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum foo = int; +struct foo(int); fn main() { let x = foo(3); - *x = 4; //~ ERROR assigning to enum content + *x = 4; //~ ERROR assigning to anonymous field } diff --git a/src/test/compile-fail/borrowck-autoref-3261.rs b/src/test/compile-fail/borrowck-autoref-3261.rs index 7873adbf21d8e..b874eac34b18c 100644 --- a/src/test/compile-fail/borrowck-autoref-3261.rs +++ b/src/test/compile-fail/borrowck-autoref-3261.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum X = Either<(uint,uint),extern fn()>; +struct X(Either<(uint,uint),extern fn()>); + pub impl &'self X { - fn with(blk: fn(x: &Either<(uint,uint),extern fn()>)) { + fn with(blk: &fn(x: &Either<(uint,uint),extern fn()>)) { blk(&**self) } } diff --git a/src/test/compile-fail/borrowck-insert-during-each.rs b/src/test/compile-fail/borrowck-insert-during-each.rs index 476a790b85ede..788c5397e35d0 100644 --- a/src/test/compile-fail/borrowck-insert-during-each.rs +++ b/src/test/compile-fail/borrowck-insert-during-each.rs @@ -15,7 +15,7 @@ struct Foo { } pub impl Foo { - fn foo(&mut self, fun: fn(&int)) { + fn foo(&mut self, fun: &fn(&int)) { for self.n.each |f| { fun(f); } diff --git a/src/test/compile-fail/borrowck-lend-flow.rs b/src/test/compile-fail/borrowck-lend-flow.rs index 6ec7dd7330526..ed6446a6311b8 100644 --- a/src/test/compile-fail/borrowck-lend-flow.rs +++ b/src/test/compile-fail/borrowck-lend-flow.rs @@ -94,7 +94,7 @@ fn loop_in_block() { } fn at_most_once_block() { - fn at_most_once(f: fn()) { f() } + fn at_most_once(f: &fn()) { f() } // Here, the borrow check has no way of knowing that the block is // executed at most once. diff --git a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs index aca63308d874e..784fce1300f76 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn borrow(v: &int, f: fn(x: &int)) { +fn borrow(v: &int, f: &fn(x: &int)) { f(v); } diff --git a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs index e56a179e7741e..332ec3fe697d0 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn borrow(v: &int, f: fn(x: &int)) { +fn borrow(v: &int, f: &fn(x: &int)) { f(v); } diff --git a/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs b/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs index 7b6484fd4aadb..ece9ae7e86199 100644 --- a/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs +++ b/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs @@ -10,7 +10,7 @@ // xfail-test #3387 -enum foo = ~uint; +struct foo(~uint); impl Add for foo { pure fn add(f: &foo) -> foo { diff --git a/src/test/compile-fail/borrowck-loan-rcvr.rs b/src/test/compile-fail/borrowck-loan-rcvr.rs index bd4428dc93064..85989bf9d2140 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr.rs @@ -12,7 +12,7 @@ struct point { x: int, y: int } trait methods { fn impurem(); - fn blockm(f: fn()); + fn blockm(f: &fn()); pure fn purem(); } @@ -20,7 +20,7 @@ impl methods for point { fn impurem() { } - fn blockm(f: fn()) { f() } + fn blockm(f: &fn()) { f() } pure fn purem() { } diff --git a/src/test/compile-fail/borrowck-loan-vec-content.rs b/src/test/compile-fail/borrowck-loan-vec-content.rs index 8457fce255ea3..d27d690437aff 100644 --- a/src/test/compile-fail/borrowck-loan-vec-content.rs +++ b/src/test/compile-fail/borrowck-loan-vec-content.rs @@ -12,7 +12,7 @@ // (locally rooted) mutable, unique vector, and that we then prevent // modifications to the contents. -fn takes_imm_elt(_v: &int, f: fn()) { +fn takes_imm_elt(_v: &int, f: &fn()) { f(); } @@ -29,7 +29,7 @@ fn has_mut_vec_but_tries_to_change_it() { } } -fn takes_const_elt(_v: &const int, f: fn()) { +fn takes_const_elt(_v: &const int, f: &fn()) { f(); } diff --git a/src/test/compile-fail/borrowck-mut-deref-comp.rs b/src/test/compile-fail/borrowck-mut-deref-comp.rs index 3c67b6d5caf8d..540793d4135f2 100644 --- a/src/test/compile-fail/borrowck-mut-deref-comp.rs +++ b/src/test/compile-fail/borrowck-mut-deref-comp.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum foo = ~int; +struct foo(~int); fn borrow(x: @mut foo) { let _y = &***x; //~ ERROR illegal borrow unless pure diff --git a/src/test/compile-fail/borrowck-unary-move-2.rs b/src/test/compile-fail/borrowck-unary-move-2.rs index a25fc8327bd10..520772f1ceea9 100644 --- a/src/test/compile-fail/borrowck-unary-move-2.rs +++ b/src/test/compile-fail/borrowck-unary-move-2.rs @@ -24,9 +24,9 @@ fn noncopyable() -> noncopyable { } } -enum wrapper = noncopyable; +struct wrapper(noncopyable); fn main() { let x1 = wrapper(noncopyable()); - let _x2 = *x1; //~ ERROR moving out of enum content + let _x2 = *x1; //~ ERROR moving out of anonymous field } diff --git a/src/test/compile-fail/closure-that-fails.rs b/src/test/compile-fail/closure-that-fails.rs index 66d4e601ec7b6..aad0e8bcbb6dd 100644 --- a/src/test/compile-fail/closure-that-fails.rs +++ b/src/test/compile-fail/closure-that-fails.rs @@ -1,4 +1,4 @@ -fn foo(f: fn() -> !) {} +fn foo(f: &fn() -> !) {} fn main() { // Type inference didn't use to be able to handle this: diff --git a/src/test/compile-fail/enum-in-scope.rs b/src/test/compile-fail/enum-in-scope.rs index 704001de95844..cccf66ef2d54e 100644 --- a/src/test/compile-fail/enum-in-scope.rs +++ b/src/test/compile-fail/enum-in-scope.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum hello = int; +struct hello(int); fn main() { let hello = 0; //~ERROR declaration of `hello` shadows diff --git a/src/test/compile-fail/extern-wrong-value-type.rs b/src/test/compile-fail/extern-wrong-value-type.rs index 2462451c88a00..4daa7f71adf28 100644 --- a/src/test/compile-fail/extern-wrong-value-type.rs +++ b/src/test/compile-fail/extern-wrong-value-type.rs @@ -13,5 +13,5 @@ extern fn f() { fn main() { // extern functions are *u8 types - let _x: fn() = f; //~ ERROR mismatched types: expected `&fn()` but found `*u8` + let _x: &fn() = f; //~ ERROR mismatched types: expected `&fn()` but found `*u8` } diff --git a/src/test/compile-fail/fn-variance-1.rs b/src/test/compile-fail/fn-variance-1.rs index 5550eb4902e17..c5c29bd3ecfe7 100644 --- a/src/test/compile-fail/fn-variance-1.rs +++ b/src/test/compile-fail/fn-variance-1.rs @@ -14,7 +14,7 @@ fn takes_mut(&&x: @mut int) { } fn takes_const(&&x: @const int) { } fn takes_imm(&&x: @int) { } -fn apply(t: T, f: fn(T)) { +fn apply(t: T, f: &fn(T)) { f(t) } diff --git a/src/test/compile-fail/immut-function-arguments.rs b/src/test/compile-fail/immut-function-arguments.rs index e557eaba83474..2084729372d1d 100644 --- a/src/test/compile-fail/immut-function-arguments.rs +++ b/src/test/compile-fail/immut-function-arguments.rs @@ -13,7 +13,7 @@ fn f(y: ~int) { } fn g() { - let _frob: fn(~int) = |q| { *q = 2; }; //~ ERROR assigning to dereference of immutable ~ pointer + let _frob: &fn(~int) = |q| { *q = 2; }; //~ ERROR assigning to dereference of immutable ~ pointer } diff --git a/src/test/compile-fail/issue-2063-resource.rs b/src/test/compile-fail/issue-2063-resource.rs index 137ce2d5030fe..db054d5aba700 100644 --- a/src/test/compile-fail/issue-2063-resource.rs +++ b/src/test/compile-fail/issue-2063-resource.rs @@ -16,7 +16,7 @@ struct t { //~ ERROR this type cannot be instantiated to_str: (), } -enum x = @t; //~ ERROR this type cannot be instantiated +struct x(@t); //~ ERROR this type cannot be instantiated fn main() { } diff --git a/src/test/compile-fail/issue-2063.rs b/src/test/compile-fail/issue-2063.rs index 8f344f4260664..0ebf0218efe6d 100644 --- a/src/test/compile-fail/issue-2063.rs +++ b/src/test/compile-fail/issue-2063.rs @@ -1,3 +1,5 @@ +// xfail-test + // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. @@ -11,7 +13,7 @@ // test that autoderef of a type like this does not // cause compiler to loop. Note that no instances // of such a type could ever be constructed. -enum t = @t; //~ ERROR this type cannot be instantiated +struct t(@t); //~ ERROR this type cannot be instantiated trait to_str_2 { fn to_str() -> ~str; diff --git a/src/test/compile-fail/issue-2149.rs b/src/test/compile-fail/issue-2149.rs index 0880cabb2abf9..361a20ad45133 100644 --- a/src/test/compile-fail/issue-2149.rs +++ b/src/test/compile-fail/issue-2149.rs @@ -9,11 +9,11 @@ // except according to those terms. trait vec_monad { - fn bind(f: fn(A) -> ~[B]); + fn bind(f: &fn(A) -> ~[B]); } impl vec_monad for ~[A] { - fn bind(f: fn(A) -> ~[B]) { + fn bind(f: &fn(A) -> ~[B]) { let mut r = fail!(); for self.each |elt| { r += f(*elt); } //~^ WARNING unreachable expression diff --git a/src/test/compile-fail/issue-2718-a.rs b/src/test/compile-fail/issue-2718-a.rs index 925350d9b8804..8afaf8995c291 100644 --- a/src/test/compile-fail/issue-2718-a.rs +++ b/src/test/compile-fail/issue-2718-a.rs @@ -1,3 +1,5 @@ +// xfail-test + // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. @@ -16,7 +18,7 @@ pub struct send_packet { mod pingpong { use send_packet; pub type ping = send_packet; - pub enum pong = send_packet; //~ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable + pub struct pong(send_packet); //~ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable } fn main() {} diff --git a/src/test/compile-fail/issue-2817-2.rs b/src/test/compile-fail/issue-2817-2.rs index 890b984e42ef2..6084552f0ed6d 100644 --- a/src/test/compile-fail/issue-2817-2.rs +++ b/src/test/compile-fail/issue-2817-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn not_bool(f: fn(int) -> ~str) {} +fn not_bool(f: &fn(int) -> ~str) {} fn main() { for uint::range(0, 100000) |_i| { //~ ERROR A for-loop body must return (), but diff --git a/src/test/compile-fail/issue-3080.rs b/src/test/compile-fail/issue-3080.rs index 530dadd7e9094..02df25d87d7fb 100644 --- a/src/test/compile-fail/issue-3080.rs +++ b/src/test/compile-fail/issue-3080.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test -enum x = (); +struct x(()); pub impl x { unsafe fn with() { } // This should fail } diff --git a/src/test/compile-fail/issue-3344.rs b/src/test/compile-fail/issue-3344.rs index 2d31867752ac5..df768860cba94 100644 --- a/src/test/compile-fail/issue-3344.rs +++ b/src/test/compile-fail/issue-3344.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum thing = uint; +struct thing(uint); impl cmp::Ord for thing { //~ ERROR missing method `gt` pure fn lt(&self, other: &thing) -> bool { **self < **other } pure fn le(&self, other: &thing) -> bool { **self < **other } diff --git a/src/test/compile-fail/issue-3953.rs b/src/test/compile-fail/issue-3953.rs index afd8cf892333f..bfc17c589db91 100644 --- a/src/test/compile-fail/issue-3953.rs +++ b/src/test/compile-fail/issue-3953.rs @@ -20,7 +20,7 @@ trait Hahaha: Eq + Eq + Eq + Eq + Eq + //~ ERROR Duplicate supertrait Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq {} -enum Lol = int; +struct Lol(int); impl Hahaha for Lol { } diff --git a/src/test/compile-fail/liveness-closure-require-ret.rs b/src/test/compile-fail/liveness-closure-require-ret.rs index 742afd6d30ea9..b1fc6a870d086 100644 --- a/src/test/compile-fail/liveness-closure-require-ret.rs +++ b/src/test/compile-fail/liveness-closure-require-ret.rs @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn force(f: fn() -> int) -> int { f() } +fn force(f: &fn() -> int) -> int { f() } fn main() { log(debug, force(|| {})); } //~ ERROR mismatched types diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index 95dd59eb27f73..c0de60fa58e3f 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -14,7 +14,7 @@ fn send(ch: _chan, -data: T) { fail!(); } -enum _chan = int; +struct _chan(int); // Tests that "log(debug, message);" is flagged as using // message after the send deinitializes it diff --git a/src/test/compile-fail/missing-do.rs b/src/test/compile-fail/missing-do.rs index fc4a4c11e7d27..974f30feb0651 100644 --- a/src/test/compile-fail/missing-do.rs +++ b/src/test/compile-fail/missing-do.rs @@ -10,7 +10,7 @@ // Regression test for issue #2783 -fn foo(f: fn()) { f() } +fn foo(f: &fn()) { f() } fn main() { ~"" || 42; //~ ERROR binary operation || cannot be applied to type `~str` diff --git a/src/test/compile-fail/mode-inference-fail.rs b/src/test/compile-fail/mode-inference-fail.rs index fd15321e1d02b..d9f6cf8b2d722 100644 --- a/src/test/compile-fail/mode-inference-fail.rs +++ b/src/test/compile-fail/mode-inference-fail.rs @@ -13,8 +13,8 @@ // In this test, the mode gets inferred to ++ due to the apply_int(), // but then we get a failure in the generic apply(). -fn apply(f: fn(A) -> A, a: A) -> A { f(a) } -fn apply_int(f: fn(int) -> int, a: int) -> int { f(a) } +fn apply(f: &fn(A) -> A, a: A) -> A { f(a) } +fn apply_int(f: &fn(int) -> int, a: int) -> int { f(a) } fn main() { let f = {|i| i}; diff --git a/src/test/compile-fail/pat-shadow-in-nested-binding.rs b/src/test/compile-fail/pat-shadow-in-nested-binding.rs index 3d2587551857a..4d89ec14d94b2 100644 --- a/src/test/compile-fail/pat-shadow-in-nested-binding.rs +++ b/src/test/compile-fail/pat-shadow-in-nested-binding.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum foo = uint; +struct foo(uint); fn main() { let (foo, _) = (2, 3); //~ ERROR declaration of `foo` shadows diff --git a/src/test/compile-fail/pure-higher-order.rs b/src/test/compile-fail/pure-higher-order.rs index e5638e11ae918..6d262bc04e1e4 100644 --- a/src/test/compile-fail/pure-higher-order.rs +++ b/src/test/compile-fail/pure-higher-order.rs @@ -16,7 +16,7 @@ struct S<'self> { f: &'self fn(uint) } -pure fn range(from: uint, to: uint, f: fn(uint)) { +pure fn range(from: uint, to: uint, f: &fn(uint)) { let mut i = from; while i < to { f(i); // Note: legal to call argument, even if it is not pure. @@ -24,13 +24,13 @@ pure fn range(from: uint, to: uint, f: fn(uint)) { } } -pure fn range2(from: uint, to: uint, f: fn(uint)) { +pure fn range2(from: uint, to: uint, f: &fn(uint)) { do range(from, to) |i| { f(i*2u); } } -pure fn range3(from: uint, to: uint, f: fn(uint)) { +pure fn range3(from: uint, to: uint, f: &fn(uint)) { range(from, to, f) } diff --git a/src/test/compile-fail/purity-infer-fail.rs b/src/test/compile-fail/purity-infer-fail.rs index e5301c0693d52..3e5296530fa35 100644 --- a/src/test/compile-fail/purity-infer-fail.rs +++ b/src/test/compile-fail/purity-infer-fail.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn something(f: pure fn()) { f(); } +fn something(f: &pure fn()) { f(); } fn main() { let mut x = ~[]; diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index e4e61e438f938..eda207f711d68 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -62,7 +62,7 @@ fn main() { check_pp(expr3, pprust::print_expr, "2 - 23 + 7"); } -fn check_pp(expr: T, f: fn(pprust::ps, T), expect: str) { +fn check_pp(expr: T, f: &fn(pprust::ps, T), expect: str) { fail!(); } diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index abe62e15e1309..c669053400831 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -57,7 +57,7 @@ fn main() { check_pp(*stmt, pprust::print_stmt, ""); } -fn check_pp(expr: T, f: fn(pprust::ps, T), expect: str) { +fn check_pp(expr: T, f: &fn(pprust::ps, T), expect: str) { fail!(); } diff --git a/src/test/compile-fail/regions-bounds.rs b/src/test/compile-fail/regions-bounds.rs index c7a951c9c056d..35bef5a407a55 100644 --- a/src/test/compile-fail/regions-bounds.rs +++ b/src/test/compile-fail/regions-bounds.rs @@ -12,7 +12,7 @@ // nominal types (but not on other types) and that they are type // checked. -enum an_enum = &'self int; +struct an_enum(&'self int); trait a_trait { fn foo() -> &'self int; } diff --git a/src/test/compile-fail/regions-creating-enums.rs b/src/test/compile-fail/regions-creating-enums.rs index 27fcd2338fa51..88f2eefd36905 100644 --- a/src/test/compile-fail/regions-creating-enums.rs +++ b/src/test/compile-fail/regions-creating-enums.rs @@ -29,7 +29,7 @@ fn compute(x: &ast) -> uint { } } -fn map_nums(x: &ast, f: fn(uint) -> uint) -> &ast { +fn map_nums(x: &ast, f: &fn(uint) -> uint) -> &ast { match *x { num(x) => { return &num(f(x)); //~ ERROR illegal borrow diff --git a/src/test/compile-fail/regions-escape-bound-fn-2.rs b/src/test/compile-fail/regions-escape-bound-fn-2.rs index 147a1bfa36d54..9cee55643f89c 100644 --- a/src/test/compile-fail/regions-escape-bound-fn-2.rs +++ b/src/test/compile-fail/regions-escape-bound-fn-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn with_int(f: fn(x: &int)) { +fn with_int(f: &fn(x: &int)) { let x = 3; f(&x); } diff --git a/src/test/compile-fail/regions-escape-bound-fn.rs b/src/test/compile-fail/regions-escape-bound-fn.rs index 8cdfe69a2f3ba..c81ef77f497db 100644 --- a/src/test/compile-fail/regions-escape-bound-fn.rs +++ b/src/test/compile-fail/regions-escape-bound-fn.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn with_int(f: fn(x: &int)) { +fn with_int(f: &fn(x: &int)) { let x = 3; f(&x); } diff --git a/src/test/compile-fail/regions-escape-via-trait-or-not.rs b/src/test/compile-fail/regions-escape-via-trait-or-not.rs index 0a1e917c361af..767d7c9174dfa 100644 --- a/src/test/compile-fail/regions-escape-via-trait-or-not.rs +++ b/src/test/compile-fail/regions-escape-via-trait-or-not.rs @@ -18,7 +18,7 @@ impl deref for &'self int { } } -fn with(f: fn(x: &int) -> R) -> int { +fn with(f: &fn(x: &int) -> R) -> int { f(&3).get() } diff --git a/src/test/compile-fail/regions-fn-subtyping.rs b/src/test/compile-fail/regions-fn-subtyping.rs index 526a5de7fefe2..50674ac81fecf 100644 --- a/src/test/compile-fail/regions-fn-subtyping.rs +++ b/src/test/compile-fail/regions-fn-subtyping.rs @@ -17,41 +17,41 @@ fn test_fn(_x: &x/T, _y: &y/T, _z: &z/T) { // subtype::(of::()) will typecheck // iff T1 <: T2. - subtype::( - of::()); + subtype::<&fn(&a/T)>( + of::<&fn(&a/T)>()); - subtype::( - of::()); + subtype::<&fn(&a/T)>( + of::<&fn(&b/T)>()); - subtype::( - of::()); + subtype::<&fn(&b/T)>( + of::<&fn(&x/T)>()); - subtype::( - of::()); //~ ERROR mismatched types + subtype::<&fn(&x/T)>( + of::<&fn(&b/T)>()); //~ ERROR mismatched types - subtype::( - of::()); + subtype::<&fn(&a/T, &b/T)>( + of::<&fn(&a/T, &a/T)>()); - subtype::( - of::()); //~ ERROR mismatched types + subtype::<&fn(&a/T, &a/T)>( + of::<&fn(&a/T, &b/T)>()); //~ ERROR mismatched types - subtype::( - of::()); + subtype::<&fn(&a/T, &b/T)>( + of::<&fn(&x/T, &y/T)>()); - subtype::( - of::()); //~ ERROR mismatched types + subtype::<&fn(&x/T, &y/T)>( + of::<&fn(&a/T, &b/T)>()); //~ ERROR mismatched types - subtype:: @fn(&a/T)>( - of:: @fn(&a/T)>()); + subtype::<&fn(&x/T) -> @fn(&a/T)>( + of::<&fn(&x/T) -> @fn(&a/T)>()); - subtype:: @fn(&a/T)>( - of:: @fn(&b/T)>()); //~ ERROR mismatched types + subtype::<&fn(&a/T) -> @fn(&a/T)>( + of::<&fn(&a/T) -> @fn(&b/T)>()); //~ ERROR mismatched types - subtype:: @fn(&a/T)>( - of:: @fn(&b/T)>()); //~ ERROR mismatched types + subtype::<&fn(&a/T) -> @fn(&a/T)>( + of::<&fn(&x/T) -> @fn(&b/T)>()); //~ ERROR mismatched types - subtype:: @fn(&b/T)>( - of:: @fn(&a/T)>()); + subtype::<&fn(&a/T) -> @fn(&b/T)>( + of::<&fn(&a/T) -> @fn(&a/T)>()); } fn main() {} diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs index 59329195b712c..ef8f6748d36af 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs @@ -10,7 +10,7 @@ fn borrow(x: &r/T) -> &r/T {x} -fn foo(cond: fn() -> bool, box: fn() -> @int) { +fn foo(cond: &fn() -> bool, box: &fn() -> @int) { let mut y: ∫ loop { let x = box(); diff --git a/src/test/compile-fail/regions-infer-call-3.rs b/src/test/compile-fail/regions-infer-call-3.rs index 762142993f9d9..49d3f6aee65c8 100644 --- a/src/test/compile-fail/regions-infer-call-3.rs +++ b/src/test/compile-fail/regions-infer-call-3.rs @@ -10,7 +10,7 @@ fn select(x: &r/int, y: &r/int) -> &r/int { x } -fn with(f: fn(x: &int) -> T) -> T { +fn with(f: &fn(x: &int) -> T) -> T { f(&20) } diff --git a/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs b/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs index fe37d8990985d..4c3338d2e1d0c 100644 --- a/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs +++ b/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs @@ -11,7 +11,7 @@ // check that the &int here does not cause us to think that `foo` // contains region pointers -enum foo = ~fn(x: &int); +struct foo(~fn(x: &int)); fn take_foo(x: foo<'static>) {} //~ ERROR no region bound is allowed on `foo` diff --git a/src/test/compile-fail/regions-ret-borrowed-1.rs b/src/test/compile-fail/regions-ret-borrowed-1.rs index 5e2f45293842c..ab6a37b58de6f 100644 --- a/src/test/compile-fail/regions-ret-borrowed-1.rs +++ b/src/test/compile-fail/regions-ret-borrowed-1.rs @@ -12,7 +12,7 @@ // some point regions-ret-borrowed reported an error but this file did // not, due to special hardcoding around the anonymous region. -fn with(f: fn(x: &a/int) -> R) -> R { +fn with(f: &fn(x: &a/int) -> R) -> R { f(&3) } diff --git a/src/test/compile-fail/regions-ret-borrowed.rs b/src/test/compile-fail/regions-ret-borrowed.rs index 52f9770250ee4..157b99de9e806 100644 --- a/src/test/compile-fail/regions-ret-borrowed.rs +++ b/src/test/compile-fail/regions-ret-borrowed.rs @@ -15,7 +15,7 @@ // used to successfully compile because we failed to account for the // fact that fn(x: &int) rebound the region &. -fn with(f: fn(x: &int) -> R) -> R { +fn with(f: &fn(x: &int) -> R) -> R { f(&3) } diff --git a/src/test/compile-fail/regions-scoping.rs b/src/test/compile-fail/regions-scoping.rs index 66f1007afcf97..e675d4d455f2c 100644 --- a/src/test/compile-fail/regions-scoping.rs +++ b/src/test/compile-fail/regions-scoping.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn with(t: T, f: fn(T)) { f(t) } +fn with(t: T, f: &fn(T)) { f(t) } fn nested<'x>(x: &'x int) { // (1) do with( diff --git a/src/test/compile-fail/tps-invariant-enum.rs b/src/test/compile-fail/tps-invariant-enum.rs index 967b201908c4b..9e19ecdcb7556 100644 --- a/src/test/compile-fail/tps-invariant-enum.rs +++ b/src/test/compile-fail/tps-invariant-enum.rs @@ -12,7 +12,7 @@ struct box { f: T } -enum box_impl = box; +struct box_impl(box); fn set_box_impl(b: box_impl<@const T>, v: @const T) { b.f = v; diff --git a/src/test/compile-fail/tps-invariant-trait.rs b/src/test/compile-fail/tps-invariant-trait.rs index 94bcea8f1d3bf..9569e5f1e8210 100644 --- a/src/test/compile-fail/tps-invariant-trait.rs +++ b/src/test/compile-fail/tps-invariant-trait.rs @@ -17,7 +17,7 @@ struct box { f: T } -enum box_impl = box; +struct box_impl(box); impl box_trait for box_impl { fn get() -> T { return self.f; } diff --git a/src/test/compile-fail/type-arg-out-of-scope.rs b/src/test/compile-fail/type-arg-out-of-scope.rs index 4d3005a2a7410..07dc677c04763 100644 --- a/src/test/compile-fail/type-arg-out-of-scope.rs +++ b/src/test/compile-fail/type-arg-out-of-scope.rs @@ -10,6 +10,6 @@ // error-pattern:attempt to use a type argument out of scope fn foo(x: T) { - fn bar(f: fn(T) -> T) { } + fn bar(f: &fn(T) -> T) { } } fn main() { foo(1); } diff --git a/src/test/run-fail/unwind-iter.rs b/src/test/run-fail/unwind-iter.rs index 135c5eecc2e9b..1b28d2f6c6d63 100644 --- a/src/test/run-fail/unwind-iter.rs +++ b/src/test/run-fail/unwind-iter.rs @@ -10,7 +10,7 @@ // error-pattern:fail -fn x(it: fn(int)) { +fn x(it: &fn(int)) { fail!(); it(0); } diff --git a/src/test/run-fail/unwind-iter2.rs b/src/test/run-fail/unwind-iter2.rs index f17f9fb9154bb..286e5f4976430 100644 --- a/src/test/run-fail/unwind-iter2.rs +++ b/src/test/run-fail/unwind-iter2.rs @@ -10,7 +10,7 @@ // error-pattern:fail -fn x(it: fn(int)) { +fn x(it: &fn(int)) { let a = @0; it(1); } diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 92f80a9aa0d9b..613480e3a63cd 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -75,7 +75,7 @@ fn main() { } fn check_pp(cx: fake_ext_ctxt, - expr: T, f: fn(pprust::ps, T), expect: ~str) { + expr: T, f: &fn(pprust::ps, T), expect: ~str) { let s = do io::with_str_writer |wr| { let pp = pprust::rust_printer(wr, cx.parse_sess().interner); f(pp, expr); diff --git a/src/test/run-pass/alignment-gep-tup-like-2.rs b/src/test/run-pass/alignment-gep-tup-like-2.rs index 5bf8051cc1a47..22855bce28fca 100644 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ b/src/test/run-pass/alignment-gep-tup-like-2.rs @@ -12,7 +12,7 @@ struct Pair { a: A, b: B } -enum RecEnum = Rec; +struct RecEnum(Rec); struct Rec { val: A, rec: Option<@mut RecEnum> diff --git a/src/test/run-pass/alt-phi.rs b/src/test/run-pass/alt-phi.rs index 3702db8327e0d..40d2158835002 100644 --- a/src/test/run-pass/alt-phi.rs +++ b/src/test/run-pass/alt-phi.rs @@ -12,7 +12,7 @@ enum thing { a, b, c, } -fn foo(it: fn(int)) { it(10); } +fn foo(it: &fn(int)) { it(10); } pub fn main() { let mut x = true; diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 9f13147b276d1..ae046babfdf83 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -13,11 +13,11 @@ // it. trait iterable { - fn iterate(blk: fn(x: &A) -> bool); + fn iterate(blk: &fn(x: &A) -> bool); } impl iterable for &self/[A] { - fn iterate(f: fn(x: &A) -> bool) { + fn iterate(f: &fn(x: &A) -> bool) { for vec::each(self) |e| { if !f(e) { break; } } @@ -25,7 +25,7 @@ impl iterable for &self/[A] { } impl iterable for ~[A] { - fn iterate(f: fn(x: &A) -> bool) { + fn iterate(f: &fn(x: &A) -> bool) { for vec::each(self) |e| { if !f(e) { break; } } diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index f9e5ebf261c03..b6fdb07789c8d 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -85,13 +85,6 @@ impl cmp::Eq for Expr { pure fn ne(&self, other: &Expr) -> bool { !(*self).eq(other) } } -impl cmp::Eq for AnEnum { - pure fn eq(&self, other: &AnEnum) -> bool { - (*self).v == other.v - } - pure fn ne(&self, other: &AnEnum) -> bool { !(*self).eq(other) } -} - impl cmp::Eq for Point { pure fn eq(&self, other: &Point) -> bool { self.x == other.x && self.y == other.y @@ -139,10 +132,6 @@ struct Spanned { #[auto_decode] struct SomeStruct { v: ~[uint] } -#[auto_encode] -#[auto_decode] -enum AnEnum = SomeStruct; - #[auto_encode] #[auto_decode] struct Point {x: uint, y: uint} @@ -168,10 +157,6 @@ pub fn main() { test_prettyprint(a, &~"Spanned {lo: 0u, hi: 5u, node: 22u}"); test_ebml(a); - let a = &AnEnum(SomeStruct {v: ~[1u, 2u, 3u]}); - test_prettyprint(a, &~"AnEnum(SomeStruct {v: ~[1u, 2u, 3u]})"); - test_ebml(a); - let a = &Point {x: 3u, y: 5u}; test_prettyprint(a, &~"Point {x: 3u, y: 5u}"); test_ebml(a); diff --git a/src/test/run-pass/auto-ref-newtype.rs b/src/test/run-pass/auto-ref-newtype.rs index cdcf3c54c5838..9a84aa6a10e4a 100644 --- a/src/test/run-pass/auto-ref-newtype.rs +++ b/src/test/run-pass/auto-ref-newtype.rs @@ -11,7 +11,7 @@ // Check that we can define inherent methods on newtype enums that use // an auto-ref'd receiver. -enum Foo = uint; +struct Foo(uint); pub impl Foo { fn len(&self) -> uint { **self } diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index 1ab760307b272..44688a8dfce96 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -10,10 +10,10 @@ fn f(x: ~[T]) -> T { return x[0]; } -fn g(act: fn(~[int]) -> int) -> int { return act(~[1, 2, 3]); } +fn g(act: &fn(~[int]) -> int) -> int { return act(~[1, 2, 3]); } pub fn main() { fail_unless!((g(f) == 1)); - let f1: fn(~[~str]) -> ~str = f; + let f1: &fn(~[~str]) -> ~str = f; fail_unless!((f1(~[~"x", ~"y", ~"z"]) == ~"x")); } diff --git a/src/test/run-pass/autoderef-method-newtype.rs b/src/test/run-pass/autoderef-method-newtype.rs index 9cd4093787db9..732c26694adb5 100644 --- a/src/test/run-pass/autoderef-method-newtype.rs +++ b/src/test/run-pass/autoderef-method-newtype.rs @@ -16,7 +16,7 @@ impl double for uint { fn double() -> uint { self * 2u } } -enum foo = uint; +struct foo(uint); pub fn main() { let x = foo(3u); diff --git a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs index 94d568b71585d..b2e1bc515865a 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - fn f(i: fn() -> uint) -> uint { i() } + fn f(i: &fn() -> uint) -> uint { i() } let v = ~[-1f, 0f, 1f, 2f, 3f]; let z = do do vec::foldl(f, v) |x, _y| { x } { 22u }; fail_unless!(z == 22u); diff --git a/src/test/run-pass/block-arg-used-as-any.rs b/src/test/run-pass/block-arg-used-as-any.rs index 6d311a138288d..ae110a0477374 100644 --- a/src/test/run-pass/block-arg-used-as-any.rs +++ b/src/test/run-pass/block-arg-used-as-any.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn call_any(f: fn() -> uint) -> uint { +fn call_any(f: &fn() -> uint) -> uint { return f(); } diff --git a/src/test/run-pass/block-explicit-types.rs b/src/test/run-pass/block-explicit-types.rs index f6bbb94690f79..b24a655667a6b 100644 --- a/src/test/run-pass/block-explicit-types.rs +++ b/src/test/run-pass/block-explicit-types.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn main() { - fn as_buf(s: ~str, f: fn(~str) -> T) -> T { f(s) } + fn as_buf(s: ~str, f: &fn(~str) -> T) -> T { f(s) } as_buf(~"foo", |foo: ~str| -> () log(error, foo) ); } diff --git a/src/test/run-pass/block-fn-coerce.rs b/src/test/run-pass/block-fn-coerce.rs index 4593934d52300..dc8ad25e27606 100644 --- a/src/test/run-pass/block-fn-coerce.rs +++ b/src/test/run-pass/block-fn-coerce.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn force(f: fn() -> int) -> int { return f(); } +fn force(f: &fn() -> int) -> int { return f(); } pub fn main() { fn f() -> int { return 7; } fail_unless!((force(f) == 7)); diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index 571e67b4e5b85..d0a24f80c0b90 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -10,7 +10,7 @@ // xfail-fast -fn iter_vec(v: ~[T], f: fn(&T)) { for v.each |x| { f(x); } } +fn iter_vec(v: ~[T], f: &fn(&T)) { for v.each |x| { f(x); } } pub fn main() { let v = ~[1, 2, 3, 4, 5, 6, 7]; diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index 1ec5c781807fd..acffb6830dede 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -10,7 +10,7 @@ // xfail-fast -fn iter_vec(v: ~[T], f: fn(&T)) { for v.each |x| { f(x); } } +fn iter_vec(v: ~[T], f: &fn(&T)) { for v.each |x| { f(x); } } pub fn main() { let v = ~[1, 2, 3, 4, 5]; diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs index f2bde5a9f4bd8..0422be9d333df 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn borrow(x: &int, f: fn(x: &int)) { +fn borrow(x: &int, f: &fn(x: &int)) { f(x) } diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index 2cd445ee7af8b..5f5b9c59d7680 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -18,7 +18,7 @@ fn add_int(x: &mut Ints, v: int) { x.values <-> values; } -fn iter_ints(x: &Ints, f: fn(x: &int) -> bool) { +fn iter_ints(x: &Ints, f: &fn(x: &int) -> bool) { let l = x.values.len(); uint::range(0, l, |i| f(&x.values[i])) } diff --git a/src/test/run-pass/borrowck-preserve-box-in-field.rs b/src/test/run-pass/borrowck-preserve-box-in-field.rs index 0b84ba4ff59fb..795b074e37c4f 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-field.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-field.rs @@ -10,7 +10,7 @@ // exec-env:RUST_POISON_ON_FREE=1 -fn borrow(x: &int, f: fn(x: &int)) { +fn borrow(x: &int, f: &fn(x: &int)) { let before = *x; f(x); let after = *x; diff --git a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs index fedd8c42e8fc9..11ec78b681cbb 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs @@ -10,7 +10,7 @@ // exec-env:RUST_POISON_ON_FREE=1 -fn borrow(x: &int, f: fn(x: &int)) { +fn borrow(x: &int, f: &fn(x: &int)) { let before = *x; f(x); let after = *x; diff --git a/src/test/run-pass/borrowck-preserve-box.rs b/src/test/run-pass/borrowck-preserve-box.rs index ec9e82c7731fc..8d625476f57dc 100644 --- a/src/test/run-pass/borrowck-preserve-box.rs +++ b/src/test/run-pass/borrowck-preserve-box.rs @@ -10,7 +10,7 @@ // exec-env:RUST_POISON_ON_FREE=1 -fn borrow(x: &int, f: fn(x: &int)) { +fn borrow(x: &int, f: &fn(x: &int)) { let before = *x; f(x); let after = *x; diff --git a/src/test/run-pass/borrowck-preserve-expl-deref.rs b/src/test/run-pass/borrowck-preserve-expl-deref.rs index fd64507daa19e..fcb84eaaf00ab 100644 --- a/src/test/run-pass/borrowck-preserve-expl-deref.rs +++ b/src/test/run-pass/borrowck-preserve-expl-deref.rs @@ -10,7 +10,7 @@ // exec-env:RUST_POISON_ON_FREE=1 -fn borrow(x: &int, f: fn(x: &int)) { +fn borrow(x: &int, f: &fn(x: &int)) { let before = *x; f(x); let after = *x; diff --git a/src/test/run-pass/class-impl-parameterized-trait.rs b/src/test/run-pass/class-impl-parameterized-trait.rs index 15972d4bcd04d..87573b84dc885 100644 --- a/src/test/run-pass/class-impl-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-parameterized-trait.rs @@ -57,17 +57,17 @@ class cat : map { fn [](&&k:int) -> bool { k <= self.meows } fn find(&&k:int) -> Option { Some(self.get(k)) } fn remove(&&k:int) -> Option { self.meows -= k; Some(true) } - fn each(f: fn(&&int, &&bool) -> bool) { + fn each(f: &fn(&&int, &&bool) -> bool) { let mut n = int::abs(self.meows); while n > 0 { if !f(n, true) { break; } n -= 1; } } - fn each_key(&&f: fn(&&int) -> bool) { + fn each_key(&&f: &fn(&&int) -> bool) { for self.each |k, _v| { if !f(k) { break; } again;}; } - fn each_value(&&f: fn(&&bool) -> bool) { + fn each_value(&&f: &fn(&&bool) -> bool) { for self.each |_k, v| { if !f(v) { break; } again;}; } fn clear() { } diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index b616937731091..6cb0749ddb57f 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -50,7 +50,7 @@ pub impl cat { } impl BaseIter<(int, &'self T)> for cat { - pure fn each(&self, f: fn(&(int, &'self T)) -> bool) { + pure fn each(&self, f: &fn(&(int, &'self T)) -> bool) { let mut n = int::abs(self.meows); while n > 0 { if !f(&(n, &self.name)) { break; } @@ -73,11 +73,11 @@ impl Mutable for cat { impl Map for cat { pure fn contains_key(&self, k: &int) -> bool { *k <= self.meows } - pure fn each_key(&self, f: fn(v: &int) -> bool) { + pure fn each_key(&self, f: &fn(v: &int) -> bool) { for self.each |&(k, _)| { if !f(&k) { break; } loop;}; } - pure fn each_value(&self, f: fn(v: &T) -> bool) { + pure fn each_value(&self, f: &fn(v: &T) -> bool) { for self.each |&(_, v)| { if !f(v) { break; } loop;}; } diff --git a/src/test/run-pass/class-trait-bounded-param.rs b/src/test/run-pass/class-trait-bounded-param.rs index 294c7264c739e..e525312d6da5b 100644 --- a/src/test/run-pass/class-trait-bounded-param.rs +++ b/src/test/run-pass/class-trait-bounded-param.rs @@ -22,9 +22,9 @@ class keys> self.map = map; } - fn each(blk: fn(K) -> bool) { self.map.each(|k, _v| blk(k) ) } + fn each(blk: &fn(K) -> bool) { self.map.each(|k, _v| blk(k) ) } fn size_hint() -> Option { Some(self.map.size()) } - fn eachi(blk: fn(uint, K) -> bool) { iter::eachi(self, blk) } + fn eachi(blk: &fn(uint, K) -> bool) { iter::eachi(self, blk) } } pub fn main() { diff --git a/src/test/run-pass/closure-inference.rs b/src/test/run-pass/closure-inference.rs index 246450d2a075b..e61636a323a65 100644 --- a/src/test/run-pass/closure-inference.rs +++ b/src/test/run-pass/closure-inference.rs @@ -12,7 +12,7 @@ fn foo(i: int) -> int { i + 1 } -fn apply(f: fn(A) -> A, v: A) -> A { f(v) } +fn apply(f: &fn(A) -> A, v: A) -> A { f(v) } pub fn main() { let f = {|i| foo(i)}; diff --git a/src/test/run-pass/coherence-copy-bound.rs b/src/test/run-pass/coherence-copy-bound.rs deleted file mode 100644 index 9921389da6674..0000000000000 --- a/src/test/run-pass/coherence-copy-bound.rs +++ /dev/null @@ -1,13 +0,0 @@ -trait X {} - -impl X for A {} - -struct S { - x: int, - drop {} -} - -impl X for S {} - -pub fn main(){} - diff --git a/src/test/run-pass/const-enum-newtype-align.rs b/src/test/run-pass/const-enum-newtype-align.rs deleted file mode 100644 index 5aa9aeafeed28..0000000000000 --- a/src/test/run-pass/const-enum-newtype-align.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum E = u32; -struct S { a: u8, b: E } -const C: S = S { a: 0xA5, b: E(0xDEADBEEF) }; - -pub fn main() { - fail_unless!(C.b == 0xDEADBEEF); -} diff --git a/src/test/run-pass/const-newtype-enum.rs b/src/test/run-pass/const-newtype-enum.rs deleted file mode 100644 index b96b0e957c990..0000000000000 --- a/src/test/run-pass/const-newtype-enum.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Foo = u32; - -const X: Foo = Foo(17); - -pub fn main() { - fail_unless!((*X == 17)); - fail_unless!((*Y == 23)); -} - -const Y: Foo = Foo(23); diff --git a/src/test/run-pass/do-for-empty-args.rs b/src/test/run-pass/do-for-empty-args.rs index 2a7091cb16305..c86c1768111f7 100644 --- a/src/test/run-pass/do-for-empty-args.rs +++ b/src/test/run-pass/do-for-empty-args.rs @@ -11,7 +11,7 @@ // no-reformat // Testing various forms of `do` and `for` with empty arg lists -fn f(f: fn() -> bool) { +fn f(f: &fn() -> bool) { } pub fn main() { diff --git a/src/test/run-pass/do-pure.rs b/src/test/run-pass/do-pure.rs index b422f5819f09c..41686cf5b3736 100644 --- a/src/test/run-pass/do-pure.rs +++ b/src/test/run-pass/do-pure.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pure fn f(f: fn()) { +pure fn f(f: &fn()) { } pure fn g() { diff --git a/src/test/run-pass/fn-assign-managed-to-bare-1.rs b/src/test/run-pass/fn-assign-managed-to-bare-1.rs index a9bd5587de240..9ab6af0ac276e 100644 --- a/src/test/run-pass/fn-assign-managed-to-bare-1.rs +++ b/src/test/run-pass/fn-assign-managed-to-bare-1.rs @@ -15,6 +15,6 @@ fn add(n: int) -> @fn(int) -> int { pub fn main() { fail_unless!(add(3)(4) == 7); - let add3 : fn(int)->int = add(3); + let add3 : &fn(int)->int = add(3); fail_unless!(add3(4) == 7); } diff --git a/src/test/run-pass/fn-bare-coerce-to-block.rs b/src/test/run-pass/fn-bare-coerce-to-block.rs index a1ccb8b37eff9..db7604d11484d 100644 --- a/src/test/run-pass/fn-bare-coerce-to-block.rs +++ b/src/test/run-pass/fn-bare-coerce-to-block.rs @@ -10,7 +10,7 @@ fn bare() {} -fn likes_block(f: fn()) { f() } +fn likes_block(f: &fn()) { f() } pub fn main() { likes_block(bare); diff --git a/src/test/run-pass/fn-pattern-expected-type.rs b/src/test/run-pass/fn-pattern-expected-type.rs index 411eb5ffb0946..3f5d3818e1c12 100644 --- a/src/test/run-pass/fn-pattern-expected-type.rs +++ b/src/test/run-pass/fn-pattern-expected-type.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let f: fn((int,int)) = |(x, y)| { + let f: &fn((int,int)) = |(x, y)| { fail_unless!(x == 1); fail_unless!(y == 2); }; diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs index 8d705447531f9..a94131b36c051 100644 --- a/src/test/run-pass/foreach-nested.rs +++ b/src/test/run-pass/foreach-nested.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn two(it: fn(int)) { it(0); it(1); } +fn two(it: &fn(int)) { it(0); it(1); } pub fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; diff --git a/src/test/run-pass/foreach-put-structured.rs b/src/test/run-pass/foreach-put-structured.rs index 8bbfe90ba0307..1a71cf52de259 100644 --- a/src/test/run-pass/foreach-put-structured.rs +++ b/src/test/run-pass/foreach-put-structured.rs @@ -10,7 +10,7 @@ -fn pairs(it: fn((int, int))) { +fn pairs(it: &fn((int, int))) { let mut i: int = 0; let mut j: int = 0; while i < 10 { it((i, j)); i += 1; j += i; } diff --git a/src/test/run-pass/foreach-simple-outer-slot.rs b/src/test/run-pass/foreach-simple-outer-slot.rs index 5245158525019..1c0b28982dbe1 100644 --- a/src/test/run-pass/foreach-simple-outer-slot.rs +++ b/src/test/run-pass/foreach-simple-outer-slot.rs @@ -20,7 +20,7 @@ pub fn main() { fail_unless!((sum == 45)); } -fn first_ten(it: fn(int)) { +fn first_ten(it: &fn(int)) { let mut i: int = 0; while i < 10 { debug!("first_ten"); it(i); i = i + 1; } } diff --git a/src/test/run-pass/instantiable.rs b/src/test/run-pass/instantiable.rs index 2230c2df9fcef..c140a66ffe4d6 100644 --- a/src/test/run-pass/instantiable.rs +++ b/src/test/run-pass/instantiable.rs @@ -11,7 +11,7 @@ // check that we do not report a type like this as uninstantiable, // even though it would be if the nxt field had type @foo: -enum foo = X; +struct foo(X); struct X { x: uint, nxt: *foo } diff --git a/src/test/run-pass/issue-1458.rs b/src/test/run-pass/issue-1458.rs index 7ef47ed1dda93..a6556895dda33 100644 --- a/src/test/run-pass/issue-1458.rs +++ b/src/test/run-pass/issue-1458.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn plus_one(f: fn() -> int) -> int { +fn plus_one(f: &fn() -> int) -> int { return f() + 1; } -fn ret_plus_one() -> extern fn(fn() -> int) -> int { +fn ret_plus_one() -> extern fn(&fn() -> int) -> int { return plus_one; } diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index cd2273ab173fe..ac680d3d12e41 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -15,15 +15,15 @@ // warrant still having a test, so I inlined the old definitions. trait iterable { - fn iter(blk: fn(A)); + fn iter(blk: &fn(A)); } impl iterable for @fn(&fn(A)) { - fn iter(blk: fn(A)) { self(blk); } + fn iter(blk: &fn(A)) { self(blk); } } impl iterable for @fn(&fn(uint)) { - fn iter(blk: fn(&&v: uint)) { self( |i| blk(i) ) } + fn iter(blk: &fn(&&v: uint)) { self( |i| blk(i) ) } } fn filter>(self: IA, prd: @fn(A) -> bool, blk: &fn(A)) { diff --git a/src/test/run-pass/issue-2312.rs b/src/test/run-pass/issue-2312.rs index 9e45a6b53c2b6..ad6320aed2bb7 100644 --- a/src/test/run-pass/issue-2312.rs +++ b/src/test/run-pass/issue-2312.rs @@ -12,7 +12,7 @@ trait clam { } -enum foo = int; +struct foo(int); pub impl foo { fn bar>(c: C) -> B { fail!(); } diff --git a/src/test/run-pass/issue-2487-a.rs b/src/test/run-pass/issue-2487-a.rs index 33023db5323fc..138860ce72d1f 100644 --- a/src/test/run-pass/issue-2487-a.rs +++ b/src/test/run-pass/issue-2487-a.rs @@ -32,7 +32,7 @@ fn socket() -> socket { } } -fn closure(f: fn()) { f() } +fn closure(f: &fn()) { f() } fn setsockopt_bytes(_sock: int) { } diff --git a/src/test/run-pass/issue-2611.rs b/src/test/run-pass/issue-2611.rs index 83cedc0fe5024..af3e8e9c7a2b5 100644 --- a/src/test/run-pass/issue-2611.rs +++ b/src/test/run-pass/issue-2611.rs @@ -11,11 +11,11 @@ use core::iter::BaseIter; trait FlatMapToVec { - fn flat_map_to_vec>(&self, op: fn(&A) -> IB) -> ~[B]; + fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B]; } impl FlatMapToVec for ~[A] { - fn flat_map_to_vec>(&self, op: fn(&A) -> IB) -> ~[B] { + fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index d39f02a357418..1376f20571be6 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -225,8 +225,8 @@ pub mod pingpong { use core::cast; use core::ptr; - pub enum ping = ::pipes::send_packet; - pub enum pong = ::pipes::send_packet; + pub struct ping(::pipes::send_packet); + pub struct pong(::pipes::send_packet); pub fn liberate_ping(-p: ping) -> ::pipes::send_packet { unsafe { diff --git a/src/test/run-pass/issue-3874.rs b/src/test/run-pass/issue-3874.rs index d709757adb02d..8d62da9efad42 100644 --- a/src/test/run-pass/issue-3874.rs +++ b/src/test/run-pass/issue-3874.rs @@ -11,7 +11,7 @@ // xfail-test enum PureCounter { PureCounter(uint) } -pure fn each(self: PureCounter, blk: fn(v: &uint)) { +pure fn each(self: PureCounter, blk: &fn(v: &uint)) { let PureCounter(ref x) = self; blk(x); } diff --git a/src/test/run-pass/issue-868.rs b/src/test/run-pass/issue-868.rs index 55c5dcb4e0768..16e8fa18c2a02 100644 --- a/src/test/run-pass/issue-868.rs +++ b/src/test/run-pass/issue-868.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(g: fn() -> T) -> T { g() } +fn f(g: &fn() -> T) -> T { g() } pub fn main() { let _x = f( | | { 10 }); diff --git a/src/test/run-pass/issue-912.rs b/src/test/run-pass/issue-912.rs index dddcb8b957f6d..d2c51df2b8fb3 100644 --- a/src/test/run-pass/issue-912.rs +++ b/src/test/run-pass/issue-912.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test -fn find(_f: fn(@T) -> bool, _v: [@T]) {} +fn find(_f: &fn(@T) -> bool, _v: [@T]) {} pub fn main() { let x = 10, arr = []; diff --git a/src/test/run-pass/iter-range.rs b/src/test/run-pass/iter-range.rs index 5fdd60bedb366..0ec8eea52365f 100644 --- a/src/test/run-pass/iter-range.rs +++ b/src/test/run-pass/iter-range.rs @@ -10,7 +10,7 @@ -fn range(a: int, b: int, it: fn(int)) { +fn range(a: int, b: int, it: &fn(int)) { fail_unless!((a < b)); let mut i: int = a; while i < b { it(i); i += 1; } diff --git a/src/test/run-pass/last-use-in-block.rs b/src/test/run-pass/last-use-in-block.rs index e8083dd3f6b21..e2dbf7d29db19 100644 --- a/src/test/run-pass/last-use-in-block.rs +++ b/src/test/run-pass/last-use-in-block.rs @@ -10,7 +10,7 @@ // Issue #1818 -fn lp(s: ~str, f: fn(~str) -> T) -> T { +fn lp(s: ~str, f: &fn(~str) -> T) -> T { while false { let r = f(s); return (r); @@ -18,8 +18,8 @@ fn lp(s: ~str, f: fn(~str) -> T) -> T { fail!(); } -fn apply(s: ~str, f: fn(~str) -> T) -> T { - fn g(s: ~str, f: fn(~str) -> T) -> T {f(s)} +fn apply(s: ~str, f: &fn(~str) -> T) -> T { + fn g(s: ~str, f: &fn(~str) -> T) -> T {f(s)} g(s, |v| { let r = f(v); r }) } diff --git a/src/test/run-pass/let-destruct.rs b/src/test/run-pass/let-destruct.rs index eec3064cbbdf1..05e50e3e66047 100644 --- a/src/test/run-pass/let-destruct.rs +++ b/src/test/run-pass/let-destruct.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum xx = int; +struct xx(int); struct X { x: xx, y: int } diff --git a/src/test/run-pass/log-degen-enum.rs b/src/test/run-pass/log-degen-enum.rs deleted file mode 100644 index 79ad6e8a2506a..0000000000000 --- a/src/test/run-pass/log-degen-enum.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Foo = uint; - -pub fn main() { - let x = Foo(1); - let y = fmt!("%?", x); - fail_unless!(y == ~"Foo(1)"); -} diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 523348b4ffdea..b21b3b6c7fb26 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -11,11 +11,11 @@ // xfail-fast trait vec_monad { - fn bind(f: fn(&A) -> ~[B]) -> ~[B]; + fn bind(f: &fn(&A) -> ~[B]) -> ~[B]; } impl vec_monad for ~[A] { - fn bind(f: fn(&A) -> ~[B]) -> ~[B] { + fn bind(f: &fn(&A) -> ~[B]) -> ~[B] { let mut r = ~[]; for self.each |elt| { r += f(elt); } r @@ -23,11 +23,11 @@ impl vec_monad for ~[A] { } trait option_monad { - fn bind(f: fn(&A) -> Option) -> Option; + fn bind(f: &fn(&A) -> Option) -> Option; } impl option_monad for Option { - fn bind(f: fn(&A) -> Option) -> Option { + fn bind(f: &fn(&A) -> Option) -> Option { match self { Some(ref a) => { f(a) } None => { None } diff --git a/src/test/run-pass/mut-function-arguments.rs b/src/test/run-pass/mut-function-arguments.rs index a092e3bcc1889..f61ffc1bc3e00 100644 --- a/src/test/run-pass/mut-function-arguments.rs +++ b/src/test/run-pass/mut-function-arguments.rs @@ -14,7 +14,7 @@ fn f(mut y: ~int) { } fn g() { - let frob: fn(~int) = |mut q| { *q = 2; fail_unless!(*q == 2); }; + let frob: &fn(~int) = |mut q| { *q = 2; fail_unless!(*q == 2); }; let w = ~37; frob(w); diff --git a/src/test/run-pass/newlambdas.rs b/src/test/run-pass/newlambdas.rs index 267946e7b2e01..076e019bab46d 100644 --- a/src/test/run-pass/newlambdas.rs +++ b/src/test/run-pass/newlambdas.rs @@ -12,7 +12,7 @@ fn f(i: int, f: &fn(int) -> int) -> int { f(i) } -fn g(g: fn()) { } +fn g(g: &fn()) { } fn ff() -> @fn(int) -> int { return |x| x + 1; diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index d661fecc52659..18132d15d5787 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum myvec = ~[X]; +struct myvec(~[X]); fn myvec_deref(mv: myvec) -> ~[X] { return copy *mv; } diff --git a/src/test/run-pass/newtype.rs b/src/test/run-pass/newtype.rs index 41b16193ca1ef..6a82f70d9158a 100644 --- a/src/test/run-pass/newtype.rs +++ b/src/test/run-pass/newtype.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum mytype = Mytype; +struct mytype(Mytype); struct Mytype {compute: extern fn(mytype) -> int, val: int} diff --git a/src/test/run-pass/non-legacy-modes.rs b/src/test/run-pass/non-legacy-modes.rs index 6260de64cd839..330a9b9de7b8f 100644 --- a/src/test/run-pass/non-legacy-modes.rs +++ b/src/test/run-pass/non-legacy-modes.rs @@ -12,7 +12,7 @@ struct X { repr: int } -fn apply(x: T, f: fn(T)) { +fn apply(x: T, f: &fn(T)) { f(x); } diff --git a/src/test/run-pass/operator-overloading-explicit-self.rs b/src/test/run-pass/operator-overloading-explicit-self.rs deleted file mode 100644 index 3d2fd649f1562..0000000000000 --- a/src/test/run-pass/operator-overloading-explicit-self.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S { - x: int -} - -pub impl S { - pure fn add(&self, other: &S) -> S { - S { x: self.x + other.x } - } -} - -pub fn main() { - let mut s = S { x: 1 }; - s += S { x: 2 }; - fail_unless!(s.x == 3); -} - diff --git a/src/test/run-pass/pipe-bank-proto.rs b/src/test/run-pass/pipe-bank-proto.rs index b74c70d3ea716..20daa894bc128 100644 --- a/src/test/run-pass/pipe-bank-proto.rs +++ b/src/test/run-pass/pipe-bank-proto.rs @@ -49,7 +49,7 @@ macro_rules! move_it ( ) fn switch(+endp: pipes::RecvPacket, - f: fn(+v: Option) -> U) -> U { + f: &fn(+v: Option) -> U) -> U { f(pipes::try_recv(endp)) } diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs index 2b270a54d80a0..f1686080f4661 100644 --- a/src/test/run-pass/pipe-pingpong-bounded.rs +++ b/src/test/run-pass/pipe-pingpong-bounded.rs @@ -43,8 +43,8 @@ mod pingpong { ptr::addr_of(&(data.ping)) } } - pub enum ping = server::pong; - pub enum pong = client::ping; + pub struct ping(server::pong); + pub struct pong(client::ping); pub mod client { use core::pipes; use core::pipes::*; diff --git a/src/test/run-pass/purity-infer.rs b/src/test/run-pass/purity-infer.rs index 9aba504695579..d546909de8e1e 100644 --- a/src/test/run-pass/purity-infer.rs +++ b/src/test/run-pass/purity-infer.rs @@ -9,7 +9,7 @@ // except according to those terms. -fn something(f: pure fn()) { f(); } +fn something(f: &pure fn()) { f(); } pub fn main() { something(|| log(error, "hi!") ); } diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index 029dc37cfb2ee..0f3f4db3bbfe2 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -19,7 +19,7 @@ use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor}; /// Trait for visitor that wishes to reflect on data. trait movable_ptr { - fn move_ptr(adjustment: fn(*c_void) -> *c_void); + fn move_ptr(adjustment: &fn(*c_void) -> *c_void); } /// Helper function for alignment calculation. @@ -28,7 +28,7 @@ fn align(size: uint, align: uint) -> uint { ((size + align) - 1u) & !(align - 1u) } -enum ptr_visit_adaptor = Inner; +struct ptr_visit_adaptor(Inner); pub impl ptr_visit_adaptor { @@ -470,7 +470,7 @@ impl TyVisitor for ptr_visit_adaptor { } } -enum my_visitor = @mut Stuff; +struct my_visitor(@mut Stuff); struct Stuff { ptr1: *c_void, @@ -479,7 +479,7 @@ struct Stuff { } pub impl my_visitor { - fn get(f: fn(T)) { + fn get(f: &fn(T)) { unsafe { f(*(self.ptr1 as *T)); } @@ -498,7 +498,7 @@ pub impl my_visitor { struct Inner { inner: V } impl movable_ptr for my_visitor { - fn move_ptr(adjustment: fn(*c_void) -> *c_void) { + fn move_ptr(adjustment: &fn(*c_void) -> *c_void) { self.ptr1 = adjustment(self.ptr1); self.ptr2 = adjustment(self.ptr2); } diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index 6efd40b1fd6e1..bc67ece79de50 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -10,7 +10,7 @@ // xfail-test use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor}; -enum my_visitor = @mut { types: ~[str] }; +struct my_visitor(@mut { types: ~[str] }); impl TyVisitor for my_visitor { fn visit_bot() -> bool { diff --git a/src/test/run-pass/regions-fn-subtyping-2.rs b/src/test/run-pass/regions-fn-subtyping-2.rs index ad9ede07f779b..a995b3d969352 100644 --- a/src/test/run-pass/regions-fn-subtyping-2.rs +++ b/src/test/run-pass/regions-fn-subtyping-2.rs @@ -15,13 +15,13 @@ // Here, `f` is a function that takes a pointer `x` and a function // `g`, where `g` requires its argument `y` to be in the same region // that `x` is in. -fn has_same_region(f: fn(x: &a.int, g: fn(y: &a.int))) { +fn has_same_region(f: &fn(x: &a.int, g: &fn(y: &a.int))) { // `f` should be the type that `wants_same_region` wants, but // right now the compiler complains that it isn't. wants_same_region(f); } -fn wants_same_region(_f: fn(x: &b.int, g: fn(y: &b.int))) { +fn wants_same_region(_f: &fn(x: &b.int, g: &fn(y: &b.int))) { } pub fn main() { diff --git a/src/test/run-pass/regions-infer-call-2.rs b/src/test/run-pass/regions-infer-call-2.rs index eba9bb592bb65..dc38a7baacd21 100644 --- a/src/test/run-pass/regions-infer-call-2.rs +++ b/src/test/run-pass/regions-infer-call-2.rs @@ -10,7 +10,7 @@ fn takes_two(x: &int, y: &int) -> int { *x + *y } -fn with(f: fn(x: &int) -> T) -> T { +fn with(f: &fn(x: &int) -> T) -> T { f(&20) } diff --git a/src/test/run-pass/regions-mock-trans.rs b/src/test/run-pass/regions-mock-trans.rs index 7a1b9ae563aa5..b249a4470cb9e 100644 --- a/src/test/run-pass/regions-mock-trans.rs +++ b/src/test/run-pass/regions-mock-trans.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum arena = (); +struct arena(()); struct Bcx { fcx: &'self Fcx<'self> diff --git a/src/test/run-pass/regions-params.rs b/src/test/run-pass/regions-params.rs index 500ce356018c0..0049653dea9d3 100644 --- a/src/test/run-pass/regions-params.rs +++ b/src/test/run-pass/regions-params.rs @@ -12,7 +12,7 @@ fn region_identity(x: &r/uint) -> &r/uint { x } -fn apply(t: T, f: fn(T) -> T) -> T { f(t) } +fn apply(t: T, f: &fn(T) -> T) -> T { f(t) } fn parameterized(x: &uint) -> uint { let z = apply(x, ({|y| diff --git a/src/test/run-pass/resource-cycle.rs b/src/test/run-pass/resource-cycle.rs index f5a959b2dbcab..058cb4ec77e48 100644 --- a/src/test/run-pass/resource-cycle.rs +++ b/src/test/run-pass/resource-cycle.rs @@ -34,7 +34,7 @@ fn r(v: *int) -> r { } } -enum t = Node; +struct t(Node); struct Node { next: Option<@mut t>, diff --git a/src/test/run-pass/resource-cycle2.rs b/src/test/run-pass/resource-cycle2.rs index cf5f36916a041..e3b03060893a2 100644 --- a/src/test/run-pass/resource-cycle2.rs +++ b/src/test/run-pass/resource-cycle2.rs @@ -34,7 +34,7 @@ fn r(v: U) -> r { } } -enum t = Node; +struct t(Node); struct Node { next: Option<@mut t>, diff --git a/src/test/run-pass/resource-cycle3.rs b/src/test/run-pass/resource-cycle3.rs index 4cd3df0f87f90..c76c1c6aeb910 100644 --- a/src/test/run-pass/resource-cycle3.rs +++ b/src/test/run-pass/resource-cycle3.rs @@ -43,7 +43,7 @@ fn r(v: U, w: int, _x: *int) -> R { } } -enum t = Node; +struct t(Node); struct Node { next: Option<@mut t>, diff --git a/src/test/run-pass/ret-break-cont-in-block.rs b/src/test/run-pass/ret-break-cont-in-block.rs index da2aa2b8cd4b3..6fe7575884249 100644 --- a/src/test/run-pass/ret-break-cont-in-block.rs +++ b/src/test/run-pass/ret-break-cont-in-block.rs @@ -12,7 +12,7 @@ use core::cmp::Eq; -fn iter(v: ~[T], it: fn(&T) -> bool) { +fn iter(v: ~[T], it: &fn(&T) -> bool) { let mut i = 0u, l = v.len(); while i < l { if !it(&v[i]) { break; } diff --git a/src/test/run-pass/sendfn-is-a-block.rs b/src/test/run-pass/sendfn-is-a-block.rs index 33e6eb6c85585..0d9d01f9e700f 100644 --- a/src/test/run-pass/sendfn-is-a-block.rs +++ b/src/test/run-pass/sendfn-is-a-block.rs @@ -10,7 +10,7 @@ // xfail-fast -fn test(f: fn(uint) -> uint) -> uint { +fn test(f: &fn(uint) -> uint) -> uint { return f(22u); } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index 2ad01557e800e..2ee6f631ea521 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -26,12 +26,12 @@ mod b { trait uint_utils { fn str() -> ~str; - fn multi(f: fn(uint)); + fn multi(f: &fn(uint)); } impl uint_utils for uint { fn str() -> ~str { uint::to_str(self) } - fn multi(f: fn(uint)) { + fn multi(f: &fn(uint)) { let mut c = 0u; while c < self { f(c); c += 1u; } } @@ -39,14 +39,14 @@ impl uint_utils for uint { trait vec_utils { fn length_() -> uint; - fn iter_(f: fn(&T)); - fn map_(f: fn(&T) -> U) -> ~[U]; + fn iter_(f: &fn(&T)); + fn map_(f: &fn(&T) -> U) -> ~[U]; } impl vec_utils for ~[T] { fn length_() -> uint { vec::len(self) } - fn iter_(f: fn(&T)) { for self.each |x| { f(x); } } - fn map_(f: fn(&T) -> U) -> ~[U] { + fn iter_(f: &fn(&T)) { for self.each |x| { f(x); } } + fn map_(f: &fn(&T) -> U) -> ~[U] { let mut r = ~[]; for self.each |elt| { r += ~[f(elt)]; } r diff --git a/src/test/run-pass/static-method-test.rs b/src/test/run-pass/static-method-test.rs index a2148fb0ef501..0c6359375d306 100644 --- a/src/test/run-pass/static-method-test.rs +++ b/src/test/run-pass/static-method-test.rs @@ -36,33 +36,33 @@ impl bool_like for int { // A trait for sequences that can be constructed imperatively. trait buildable { static pure fn build_sized(size: uint, - builder: fn(push: pure fn(+v: A))) -> Self; + builder: &fn(push: &pure fn(+v: A))) -> Self; } impl buildable for @[A] { #[inline(always)] static pure fn build_sized(size: uint, - builder: fn(push: pure fn(+v: A))) -> @[A] { + builder: &fn(push: &pure fn(+v: A))) -> @[A] { at_vec::build_sized(size, builder) } } impl buildable for ~[A] { #[inline(always)] static pure fn build_sized(size: uint, - builder: fn(push: pure fn(+v: A))) -> ~[A] { + builder: &fn(push: &pure fn(+v: A))) -> ~[A] { vec::build_sized(size, builder) } } #[inline(always)] -pure fn build>(builder: fn(push: pure fn(+v: A))) -> B { +pure fn build>(builder: &fn(push: &pure fn(+v: A))) -> B { buildable::build_sized(4, builder) } /// Apply a function to each element of an iterable and return the results fn map, U, BU: buildable> - (v: IT, f: fn(T) -> U) -> BU { + (v: IT, f: &fn(T) -> U) -> BU { do build |push| { for v.each() |elem| { push(f(*elem)); diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index 48a2b30209825..39651f86e227b 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -40,7 +40,7 @@ fn notify(ch: Chan, v: @mut bool) -> notify { } fn joinable(f: ~fn()) -> Port { - fn wrapper(c: Chan, f: fn()) { + fn wrapper(c: Chan, f: &fn()) { let b = @mut false; error!("wrapper: task=%? allocated v=%x", task::get_task(), diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index 677852a74d69e..4cee3c636c572 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -13,7 +13,7 @@ // Test cyclic detector when using trait instances. -enum Tree = @mut TreeR; +struct Tree(@mut TreeR); struct TreeR { left: Option, right: Option, diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index b375b5f328f88..7b8ebe6d34cab 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -24,10 +24,10 @@ impl to_str for () { } trait map { - fn map(f: fn(&T) -> U) -> ~[U]; + fn map(f: &fn(&T) -> U) -> ~[U]; } impl map for ~[T] { - fn map(f: fn(&T) -> U) -> ~[U] { + fn map(f: &fn(&T) -> U) -> ~[U] { let mut r = ~[]; for self.each |x| { r += ~[f(x)]; } r diff --git a/src/test/run-pass/type-params-in-for-each.rs b/src/test/run-pass/type-params-in-for-each.rs index bf252ee136491..d600ff25f0298 100644 --- a/src/test/run-pass/type-params-in-for-each.rs +++ b/src/test/run-pass/type-params-in-for-each.rs @@ -13,7 +13,7 @@ struct S { b: uint, } -fn range(lo: uint, hi: uint, it: fn(uint)) { +fn range(lo: uint, hi: uint, it: &fn(uint)) { let mut lo_ = lo; while lo_ < hi { it(lo_); lo_ += 1u; } } diff --git a/src/test/run-pass/unnamed_argument_mode.rs b/src/test/run-pass/unnamed_argument_mode.rs index e8ceeab3bf6ce..649f424ec36be 100644 --- a/src/test/run-pass/unnamed_argument_mode.rs +++ b/src/test/run-pass/unnamed_argument_mode.rs @@ -3,7 +3,7 @@ fn good(a: &int) { // unnamed argument &int is now parse x: &int -fn called(f: fn(&int)) { +fn called(f: &fn(&int)) { } pub fn main() {