Skip to content

Commit f67ccca

Browse files
olsonjefferybrson
authored andcommitted
---
yaml --- r: 49844 b: refs/heads/auto c: 4bc26ce h: refs/heads/master v: v3
1 parent 505a977 commit f67ccca

File tree

296 files changed

+2217
-2400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

296 files changed

+2217
-2400
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 61524251800ba5408166b45ef640f87da965dd73
17+
refs/heads/auto: 4bc26ce575b4bc6f7254a2cfe9fee0a08de90b49
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167

branches/auto/doc/rust.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -889,10 +889,10 @@ declared, in an angle-bracket-enclosed, comma-separated list following
889889
the function name.
890890

891891
~~~~ {.xfail-test}
892-
fn iter<T>(seq: &[T], f: fn(T)) {
892+
fn iter<T>(seq: &[T], f: &fn(T)) {
893893
for seq.each |elt| { f(elt); }
894894
}
895-
fn map<T, U>(seq: &[T], f: fn(T) -> U) -> ~[U] {
895+
fn map<T, U>(seq: &[T], f: &fn(T) -> U) -> ~[U] {
896896
let mut acc = ~[];
897897
for seq.each |elt| { acc.push(f(elt)); }
898898
acc
@@ -1198,7 +1198,7 @@ These appear after the trait name, using the same syntax used in [generic functi
11981198
trait Seq<T> {
11991199
fn len() -> uint;
12001200
fn elt_at(n: uint) -> T;
1201-
fn iter(fn(T));
1201+
fn iter(&fn(T));
12021202
}
12031203
~~~~
12041204

@@ -2074,7 +2074,7 @@ and moving values from the environment into the lambda expression's captured env
20742074
An example of a lambda expression:
20752075

20762076
~~~~
2077-
fn ten_times(f: fn(int)) {
2077+
fn ten_times(f: &fn(int)) {
20782078
let mut i = 0;
20792079
while i < 10 {
20802080
f(i);
@@ -2177,7 +2177,7 @@ If the `expr` is a [field expression](#field-expressions), it is parsed as thoug
21772177
In this example, both calls to `f` are equivalent:
21782178

21792179
~~~~
2180-
# fn f(f: fn(int)) { }
2180+
# fn f(f: &fn(int)) { }
21812181
# fn g(i: int) { }
21822182
21832183
f(|j| g(j));
@@ -2755,7 +2755,7 @@ and the cast expression in `main`.
27552755
Within the body of an item that has type parameter declarations, the names of its type parameters are types:
27562756

27572757
~~~~~~~
2758-
fn map<A: Copy, B: Copy>(f: fn(A) -> B, xs: &[A]) -> ~[B] {
2758+
fn map<A: Copy, B: Copy>(f: &fn(A) -> B, xs: &[A]) -> ~[B] {
27592759
if xs.len() == 0 { return ~[]; }
27602760
let first: B = f(xs[0]);
27612761
let rest: ~[B] = map(f, xs.slice(1, xs.len()));

branches/auto/doc/tutorial.md

Lines changed: 45 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -681,45 +681,6 @@ the value of `North` is 0, `East` is 1, `South` is 2, and `West` is 3.
681681
When an enum is C-like, you can apply the `as` cast operator to
682682
convert it to its discriminator value as an `int`.
683683

684-
<a name="single_variant_enum"></a>
685-
686-
There is a special case for enums with a single variant, which are
687-
sometimes called "newtype-style enums" (after Haskell's "newtype"
688-
feature). These are used to define new types in such a way that the
689-
new name is not just a synonym for an existing type, but its own
690-
distinct type: `type` creates a structural synonym, while this form of
691-
`enum` creates a nominal synonym. If you say:
692-
693-
~~~~
694-
enum GizmoId = int;
695-
~~~~
696-
697-
That is a shorthand for this:
698-
699-
~~~~
700-
enum GizmoId { GizmoId(int) }
701-
~~~~
702-
703-
You can extract the contents of such an enum type with the
704-
dereference (`*`) unary operator:
705-
706-
~~~~
707-
# enum GizmoId = int;
708-
let my_gizmo_id: GizmoId = GizmoId(10);
709-
let id_int: int = *my_gizmo_id;
710-
~~~~
711-
712-
Types like this can be useful to differentiate between data that have
713-
the same type but must be used in different ways.
714-
715-
~~~~
716-
enum Inches = int;
717-
enum Centimeters = int;
718-
~~~~
719-
720-
The above definitions allow for a simple way for programs to avoid
721-
confusing numbers that correspond to different units.
722-
723684
For enum types with multiple variants, destructuring is the only way to
724685
get at their contents. All variant constructors can be used as
725686
patterns, as in this definition of `area`:
@@ -789,10 +750,10 @@ match mytup {
789750

790751
## Tuple structs
791752

792-
Rust also has _nominal tuples_, which behave like both structs and tuples,
793-
except that nominal tuple types have names
794-
(so `Foo(1, 2)` has a different type from `Bar(1, 2)`),
795-
and nominal tuple types' _fields_ do not have names.
753+
Rust also has _tuple structs_, which behave like both structs and tuples,
754+
except that, unlike tuples, tuple structs have names (so `Foo(1, 2)` has a
755+
different type from `Bar(1, 2)`), and tuple structs' _fields_ do not have
756+
names.
796757

797758
For example:
798759
~~~~
@@ -803,6 +764,37 @@ match mytup {
803764
}
804765
~~~~
805766

767+
<a name="newtype"></a>
768+
769+
There is a special case for tuple structs with a single field, which are
770+
sometimes called "newtypes" (after Haskell's "newtype" feature). These are
771+
used to define new types in such a way that the new name is not just a
772+
synonym for an existing type but is rather its own distinct type.
773+
774+
~~~~
775+
struct GizmoId(int);
776+
~~~~
777+
778+
For convenience, you can extract the contents of such a struct with the
779+
dereference (`*`) unary operator:
780+
781+
~~~~
782+
# struct GizmoId(int);
783+
let my_gizmo_id: GizmoId = GizmoId(10);
784+
let id_int: int = *my_gizmo_id;
785+
~~~~
786+
787+
Types like this can be useful to differentiate between data that have
788+
the same type but must be used in different ways.
789+
790+
~~~~
791+
struct Inches(int);
792+
struct Centimeters(int);
793+
~~~~
794+
795+
The above definitions allow for a simple way for programs to avoid
796+
confusing numbers that correspond to different units.
797+
806798
# Functions
807799

808800
We've already seen several function definitions. Like all other static
@@ -1369,7 +1361,7 @@ the enclosing scope.
13691361

13701362
~~~~
13711363
# use println = core::io::println;
1372-
fn call_closure_with_ten(b: fn(int)) { b(10); }
1364+
fn call_closure_with_ten(b: &fn(int)) { b(10); }
13731365
13741366
let captured_var = 20;
13751367
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,
14551447
callers may pass any kind of closure.
14561448

14571449
~~~~
1458-
fn call_twice(f: fn()) { f(); f(); }
1450+
fn call_twice(f: &fn()) { f(); f(); }
14591451
let closure = || { "I'm a closure, and it doesn't matter what type I am"; };
14601452
fn function() { "I'm a normal function"; }
14611453
call_twice(closure);
@@ -1475,7 +1467,7 @@ Consider this function that iterates over a vector of
14751467
integers, passing in a pointer to each integer in the vector:
14761468

14771469
~~~~
1478-
fn each(v: &[int], op: fn(v: &int)) {
1470+
fn each(v: &[int], op: &fn(v: &int)) {
14791471
let mut n = 0;
14801472
while n < v.len() {
14811473
op(&v[n]);
@@ -1496,7 +1488,7 @@ argument, we can write it in a way that has a pleasant, block-like
14961488
structure.
14971489

14981490
~~~~
1499-
# fn each(v: &[int], op: fn(v: &int)) { }
1491+
# fn each(v: &[int], op: &fn(v: &int)) { }
15001492
# fn do_some_work(i: &int) { }
15011493
each([1, 2, 3], |n| {
15021494
do_some_work(n);
@@ -1507,7 +1499,7 @@ This is such a useful pattern that Rust has a special form of function
15071499
call that can be written more like a built-in control structure:
15081500

15091501
~~~~
1510-
# fn each(v: &[int], op: fn(v: &int)) { }
1502+
# fn each(v: &[int], op: &fn(v: &int)) { }
15111503
# fn do_some_work(i: &int) { }
15121504
do each([1, 2, 3]) |n| {
15131505
do_some_work(n);
@@ -1554,7 +1546,7 @@ Consider again our `each` function, this time improved to
15541546
break early when the iteratee returns `false`:
15551547

15561548
~~~~
1557-
fn each(v: &[int], op: fn(v: &int) -> bool) {
1549+
fn each(v: &[int], op: &fn(v: &int) -> bool) {
15581550
let mut n = 0;
15591551
while n < v.len() {
15601552
if !op(&v[n]) {
@@ -1778,7 +1770,7 @@ vector consisting of the result of applying `function` to each element
17781770
of `vector`:
17791771

17801772
~~~~
1781-
fn map<T, U>(vector: &[T], function: fn(v: &T) -> U) -> ~[U] {
1773+
fn map<T, U>(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] {
17821774
let mut accumulator = ~[];
17831775
for vec::each(vector) |element| {
17841776
accumulator.push(function(element));
@@ -1977,12 +1969,12 @@ types might look like the following:
19771969
~~~~
19781970
trait Seq<T> {
19791971
fn len(&self) -> uint;
1980-
fn iter(&self, b: fn(v: &T));
1972+
fn iter(&self, b: &fn(v: &T));
19811973
}
19821974
19831975
impl<T> Seq<T> for ~[T] {
19841976
fn len(&self) -> uint { vec::len(*self) }
1985-
fn iter(&self, b: fn(v: &T)) {
1977+
fn iter(&self, b: &fn(v: &T)) {
19861978
for vec::each(*self) |elt| { b(elt); }
19871979
}
19881980
}
@@ -2294,7 +2286,7 @@ struct level. Note that fields and methods are _public_ by default.
22942286
pub mod farm {
22952287
# pub type Chicken = int;
22962288
# type Cow = int;
2297-
# enum Human = int;
2289+
# struct Human(int);
22982290
# impl Human { fn rest(&self) { } }
22992291
# pub fn make_me_a_farm() -> Farm { Farm { chickens: ~[], cows: ~[], farmer: Human(0) } }
23002292
pub struct Farm {

branches/auto/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
103103
}
104104
}
105105
106-
fn iter_header(testfile: &Path, it: fn(~str) -> bool) -> bool {
106+
fn iter_header(testfile: &Path, it: &fn(~str) -> bool) -> bool {
107107
let rdr = io::file_reader(testfile).get();
108108
while !rdr.eof() {
109109
let ln = rdr.read_line();

branches/auto/src/compiletest/runtest.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,6 @@ actual:\n\
225225
}
226226

227227
fn run_debuginfo_test(config: config, props: TestProps, testfile: &Path) {
228-
// do not optimize debuginfo tests
229-
let config = match config.rustcflags {
230-
Some(flags) => config {
231-
rustcflags: Some(str::replace(flags, ~"-O", ~"")),
232-
.. config
233-
},
234-
None => config
235-
};
236-
237228
// compile test file (it shoud have 'compile-flags:-g' in the header)
238229
let mut ProcRes = compile_test(config, props, testfile);
239230
if ProcRes.status != 0 {
@@ -276,8 +267,8 @@ fn run_debuginfo_test(config: config, props: TestProps, testfile: &Path) {
276267
}
277268
}
278269
if i != num_check_lines {
279-
fatal_ProcRes(fmt!("line not found in debugger output: %s"
280-
props.check_lines[i]), ProcRes);
270+
fatal(fmt!("line not found in debugger output: %s",
271+
props.check_lines[i]));
281272
}
282273
}
283274
}
@@ -539,7 +530,7 @@ fn compose_and_run(config: config, testfile: &Path,
539530
}
540531

541532
fn make_compile_args(config: config, props: TestProps, extras: ~[~str],
542-
xform: fn(config, (&Path)) -> Path,
533+
xform: &fn(config, (&Path)) -> Path,
543534
testfile: &Path) -> ProcArgs {
544535
let prog = config.rustc_path;
545536
let mut args = ~[testfile.to_str(),

branches/auto/src/etc/emacs/rust-mode.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
(require 'cm-mode)
99
(require 'cc-mode)
10+
(eval-when-compile (require 'cl))
1011

1112
(defun rust-electric-brace (arg)
1213
(interactive "*P")

branches/auto/src/etc/kate/rust.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
</list>
1818
<list name="keywords">
1919
<item> as </item>
20-
<item> assert </item>
2120
<item> break </item>
2221
<item> const </item>
2322
<item> copy </item>
@@ -69,6 +68,7 @@
6968
<item> Shl </item>
7069
<item> Shr </item>
7170
<item> Index </item>
71+
<item> Not </item>
7272
</list>
7373
<list name="types">
7474
<item> bool </item>

branches/auto/src/libcore/at_vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub pure fn capacity<T>(v: @[const T]) -> uint {
6161
*/
6262
#[inline(always)]
6363
pub pure fn build_sized<A>(size: uint,
64-
builder: &fn(push: pure fn(v: A))) -> @[A] {
64+
builder: &fn(push: &pure fn(v: A))) -> @[A] {
6565
let mut vec: @[const A] = @[];
6666
unsafe { raw::reserve(&mut vec, size); }
6767
builder(|+x| unsafe { raw::push(&mut vec, x) });
@@ -79,7 +79,7 @@ pub pure fn build_sized<A>(size: uint,
7979
* onto the vector being constructed.
8080
*/
8181
#[inline(always)]
82-
pub pure fn build<A>(builder: &fn(push: pure fn(v: A))) -> @[A] {
82+
pub pure fn build<A>(builder: &fn(push: &pure fn(v: A))) -> @[A] {
8383
build_sized(4, builder)
8484
}
8585

@@ -97,7 +97,7 @@ pub pure fn build<A>(builder: &fn(push: pure fn(v: A))) -> @[A] {
9797
*/
9898
#[inline(always)]
9999
pub pure fn build_sized_opt<A>(size: Option<uint>,
100-
builder: &fn(push: pure fn(v: A))) -> @[A] {
100+
builder: &fn(push: &pure fn(v: A))) -> @[A] {
101101
build_sized(size.get_or_default(4), builder)
102102
}
103103

branches/auto/src/libcore/bool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub pure fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } }
6767
* Iterates over all truth values by passing them to `blk` in an unspecified
6868
* order
6969
*/
70-
pub fn all_values(blk: fn(v: bool)) {
70+
pub fn all_values(blk: &fn(v: bool)) {
7171
blk(true);
7272
blk(false);
7373
}

branches/auto/src/libcore/cell.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use prelude::*;
1515
///
1616
/// Similar to a mutable option type, but friendlier.
1717
18+
#[deriving_eq]
1819
pub struct Cell<T> {
1920
mut value: Option<T>
2021
}
@@ -54,7 +55,7 @@ pub impl<T> Cell<T> {
5455
}
5556

5657
// Calls a closure with a reference to the value.
57-
fn with_ref<R>(&self, op: fn(v: &T) -> R) -> R {
58+
fn with_ref<R>(&self, op: &fn(v: &T) -> R) -> R {
5859
let v = self.take();
5960
let r = op(&v);
6061
self.put_back(v);

branches/auto/src/libcore/cleanup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct AnnihilateStats {
124124
n_bytes_freed: uint
125125
}
126126

127-
unsafe fn each_live_alloc(f: fn(box: *mut BoxRepr, uniq: bool) -> bool) {
127+
unsafe fn each_live_alloc(f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
128128
use managed;
129129

130130
let task: *Task = transmute(rustrt::rust_get_task());

0 commit comments

Comments
 (0)