Skip to content

Commit 39b6d40

Browse files
committed
---
yaml --- r: 171855 b: refs/heads/beta c: 6f7faa0 h: refs/heads/master i: 171853: 156a370 171851: 5518384 171847: c517081 171839: c75f3b7 v: v3
1 parent 4d5724d commit 39b6d40

File tree

352 files changed

+7232
-3193
lines changed

Some content is hidden

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

352 files changed

+7232
-3193
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b5571ed71a5879c0495a982506258d5d267744ed
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: a56e7aee81733485d6edd415ab383347232e3c36
34+
refs/heads/beta: 6f7faa0b757a5afef33fcb9702f85a4a66341603
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/beta/src/compiletest/compiletest.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,9 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
339339
return valid;
340340
}
341341

342-
pub fn make_test(config: &Config, testfile: &Path, f: || -> test::TestFn)
343-
-> test::TestDescAndFn {
342+
pub fn make_test<F>(config: &Config, testfile: &Path, f: F) -> test::TestDescAndFn where
343+
F: FnOnce() -> test::TestFn,
344+
{
344345
test::TestDescAndFn {
345346
desc: test::TestDesc {
346347
name: make_test_name(config, testfile),

branches/beta/src/compiletest/header.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
220220
!val
221221
}
222222

223-
fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
223+
fn iter_header<F>(testfile: &Path, mut it: F) -> bool where
224+
F: FnMut(&str) -> bool,
225+
{
224226
use std::io::{BufferedReader, File};
225227

226228
let mut rdr = BufferedReader::new(File::open(testfile).unwrap());

branches/beta/src/compiletest/runtest.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,12 +1233,14 @@ enum TargetLocation {
12331233
ThisDirectory(Path),
12341234
}
12351235

1236-
fn make_compile_args(config: &Config,
1237-
props: &TestProps,
1238-
extras: Vec<String> ,
1239-
xform: |&Config, &Path| -> TargetLocation,
1240-
testfile: &Path)
1241-
-> ProcArgs {
1236+
fn make_compile_args<F>(config: &Config,
1237+
props: &TestProps,
1238+
extras: Vec<String> ,
1239+
xform: F,
1240+
testfile: &Path)
1241+
-> ProcArgs where
1242+
F: FnOnce(&Config, &Path) -> TargetLocation,
1243+
{
12421244
let xform_file = xform(config, testfile);
12431245
let target = if props.force_host {
12441246
config.host.as_slice()

branches/beta/src/doc/guide-testing.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ computation entirely. This could be done for the example above by adjusting the
537537
`b.iter` call to
538538

539539
```rust
540-
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let b = X;
540+
# struct X;
541+
# impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;
541542
b.iter(|| {
542543
// note lack of `;` (could also use an explicit `return`).
543544
range(0u, 1000).fold(0, |old, new| old ^ new)
@@ -552,7 +553,8 @@ argument as used.
552553
extern crate test;
553554

554555
# fn main() {
555-
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let b = X;
556+
# struct X;
557+
# impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;
556558
b.iter(|| {
557559
test::black_box(range(0u, 1000).fold(0, |old, new| old ^ new));
558560
});

branches/beta/src/doc/guide.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4232,7 +4232,7 @@ arguments, really powerful things are possible.
42324232
Let's make a closure:
42334233
42344234
```{rust}
4235-
let add_one = |x| { 1 + x };
4235+
let add_one = |&: x| { 1 + x };
42364236
42374237
println!("The sum of 5 plus 1 is {}.", add_one(5));
42384238
```
@@ -4244,8 +4244,8 @@ binding name and two parentheses, just like we would for a named function.
42444244
Let's compare syntax. The two are pretty close:
42454245
42464246
```{rust}
4247-
let add_one = |x: i32| -> i32 { 1 + x };
4248-
fn add_one (x: i32) -> i32 { 1 + x }
4247+
let add_one = |&: x: i32| -> i32 { 1 + x };
4248+
fn add_one (x: i32) -> i32 { 1 + x }
42494249
```
42504250
42514251
As you may have noticed, closures infer their argument and return types, so you
@@ -4258,9 +4258,9 @@ this:
42584258
42594259
```{rust}
42604260
fn main() {
4261-
let x = 5;
4261+
let x: i32 = 5;
42624262
4263-
let printer = || { println!("x is: {}", x); };
4263+
let printer = |&:| { println!("x is: {}", x); };
42644264
42654265
printer(); // prints "x is: 5"
42664266
}
@@ -4276,7 +4276,7 @@ defined. The closure borrows any variables it uses, so this will error:
42764276
fn main() {
42774277
let mut x = 5;
42784278
4279-
let printer = || { println!("x is: {}", x); };
4279+
let printer = |&:| { println!("x is: {}", x); };
42804280
42814281
x = 6; // error: cannot assign to `x` because it is borrowed
42824282
}
@@ -4298,12 +4298,12 @@ now. We'll talk about them more in the "Threads" section of the guide.
42984298
Closures are most useful as an argument to another function. Here's an example:
42994299
43004300
```{rust}
4301-
fn twice(x: i32, f: |i32| -> i32) -> i32 {
4301+
fn twice<F: Fn(i32) -> i32>(x: i32, f: F) -> i32 {
43024302
f(x) + f(x)
43034303
}
43044304
43054305
fn main() {
4306-
let square = |x: i32| { x * x };
4306+
let square = |&: x: i32| { x * x };
43074307
43084308
twice(5, square); // evaluates to 50
43094309
}
@@ -4312,15 +4312,15 @@ fn main() {
43124312
Let's break the example down, starting with `main`:
43134313
43144314
```{rust}
4315-
let square = |x: i32| { x * x };
4315+
let square = |&: x: i32| { x * x };
43164316
```
43174317
43184318
We've seen this before. We make a closure that takes an integer, and returns
43194319
its square.
43204320
43214321
```{rust}
4322-
# fn twice(x: i32, f: |i32| -> i32) -> i32 { f(x) + f(x) }
4323-
# let square = |x: i32| { x * x };
4322+
# fn twice<F: Fn(i32) -> i32>(x: i32, f: F) -> i32 { f(x) + f(x) }
4323+
# let square = |&: x: i32| { x * x };
43244324
twice(5, square); // evaluates to 50
43254325
```
43264326
@@ -4343,8 +4343,8 @@ how the `|i32| -> i32` syntax looks a lot like our definition of `square`
43434343
above, if we added the return type in:
43444344
43454345
```{rust}
4346-
let square = |x: i32| -> i32 { x * x };
4347-
// |i32| -> i32
4346+
let square = |&: x: i32| -> i32 { x * x };
4347+
// |i32| -> i32
43484348
```
43494349
43504350
This function takes an `i32` and returns an `i32`.
@@ -4358,7 +4358,7 @@ Finally, `twice` returns an `i32` as well.
43584358
Okay, let's look at the body of `twice`:
43594359
43604360
```{rust}
4361-
fn twice(x: i32, f: |i32| -> i32) -> i32 {
4361+
fn twice<F: Fn(i32) -> i32>(x: i32, f: F) -> i32 {
43624362
f(x) + f(x)
43634363
}
43644364
```
@@ -4376,7 +4376,7 @@ If we didn't want to give `square` a name, we could just define it inline.
43764376
This example is the same as the previous one:
43774377
43784378
```{rust}
4379-
fn twice(x: i32, f: |i32| -> i32) -> i32 {
4379+
fn twice<F: Fn(i32) -> i32>(x: i32, f: F) -> i32 {
43804380
f(x) + f(x)
43814381
}
43824382
@@ -4389,7 +4389,7 @@ A named function's name can be used wherever you'd use a closure. Another
43894389
way of writing the previous example:
43904390
43914391
```{rust}
4392-
fn twice(x: i32, f: |i32| -> i32) -> i32 {
4392+
fn twice<F: Fn(i32) -> i32>(x: i32, f: F) -> i32 {
43934393
f(x) + f(x)
43944394
}
43954395

branches/beta/src/doc/reference.md

Lines changed: 28 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ functions](#generic-functions).
15631563
trait Seq<T> {
15641564
fn len(&self) -> uint;
15651565
fn elt_at(&self, n: uint) -> T;
1566-
fn iter(&self, |T|);
1566+
fn iter<F>(&self, F) where F: Fn(T);
15671567
}
15681568
```
15691569

@@ -3218,7 +3218,7 @@ In this example, we define a function `ten_times` that takes a higher-order
32183218
function argument, and call it with a lambda expression as an argument.
32193219

32203220
```
3221-
fn ten_times(f: |int|) {
3221+
fn ten_times<F>(f: F) where F: Fn(int) {
32223222
let mut i = 0;
32233223
while i < 10 {
32243224
f(i);
@@ -3828,7 +3828,7 @@ fn add(x: int, y: int) -> int {
38283828
38293829
let mut x = add(5,7);
38303830
3831-
type Binop<'a> = |int,int|: 'a -> int;
3831+
type Binop = fn(int, int) -> int;
38323832
let bo: Binop = add;
38333833
x = bo(5,7);
38343834
```
@@ -3852,14 +3852,14 @@ An example of creating and calling a closure:
38523852
```rust
38533853
let captured_var = 10i;
38543854

3855-
let closure_no_args = || println!("captured_var={}", captured_var);
3855+
let closure_no_args = |&:| println!("captured_var={}", captured_var);
38563856

3857-
let closure_args = |arg: int| -> int {
3857+
let closure_args = |&: arg: int| -> int {
38583858
println!("captured_var={}, arg={}", captured_var, arg);
38593859
arg // Note lack of semicolon after 'arg'
38603860
};
38613861

3862-
fn call_closure(c1: ||, c2: |int| -> int) {
3862+
fn call_closure<F: Fn(), G: Fn(int) -> int>(c1: F, c2: G) {
38633863
c1();
38643864
c2(2);
38653865
}
@@ -4316,73 +4316,28 @@ fine-grained control is desired over the output format of a Rust crate.
43164316

43174317
*TODO*.
43184318

4319-
# Appendix: Influences and further references
4320-
4321-
## Influences
4322-
4323-
> The essential problem that must be solved in making a fault-tolerant
4324-
> software system is therefore that of fault-isolation. Different programmers
4325-
> will write different modules, some modules will be correct, others will have
4326-
> errors. We do not want the errors in one module to adversely affect the
4327-
> behaviour of a module which does not have any errors.
4328-
>
4329-
> &mdash; Joe Armstrong
4330-
4331-
> In our approach, all data is private to some process, and processes can
4332-
> only communicate through communications channels. *Security*, as used
4333-
> in this paper, is the property which guarantees that processes in a system
4334-
> cannot affect each other except by explicit communication.
4335-
>
4336-
> When security is absent, nothing which can be proven about a single module
4337-
> in isolation can be guaranteed to hold when that module is embedded in a
4338-
> system [...]
4339-
>
4340-
> &mdash; Robert Strom and Shaula Yemini
4341-
4342-
> Concurrent and applicative programming complement each other. The
4343-
> ability to send messages on channels provides I/O without side effects,
4344-
> while the avoidance of shared data helps keep concurrent processes from
4345-
> colliding.
4346-
>
4347-
> &mdash; Rob Pike
4348-
4349-
Rust is not a particularly original language. It may however appear unusual by
4350-
contemporary standards, as its design elements are drawn from a number of
4351-
"historical" languages that have, with a few exceptions, fallen out of favour.
4352-
Five prominent lineages contribute the most, though their influences have come
4353-
and gone during the course of Rust's development:
4354-
4355-
* The NIL (1981) and Hermes (1990) family. These languages were developed by
4356-
Robert Strom, Shaula Yemini, David Bacon and others in their group at IBM
4357-
Watson Research Center (Yorktown Heights, NY, USA).
4358-
4359-
* The Erlang (1987) language, developed by Joe Armstrong, Robert Virding, Claes
4360-
Wikstr&ouml;m, Mike Williams and others in their group at the Ericsson Computer
4361-
Science Laboratory (&Auml;lvsj&ouml;, Stockholm, Sweden) .
4362-
4363-
* The Sather (1990) language, developed by Stephen Omohundro, Chu-Cheow Lim,
4364-
Heinz Schmidt and others in their group at The International Computer
4365-
Science Institute of the University of California, Berkeley (Berkeley, CA,
4366-
USA).
4367-
4368-
* The Newsqueak (1988), Alef (1995), and Limbo (1996) family. These
4369-
languages were developed by Rob Pike, Phil Winterbottom, Sean Dorward and
4370-
others in their group at Bell Labs Computing Sciences Research Center
4371-
(Murray Hill, NJ, USA).
4372-
4373-
* The Napier (1985) and Napier88 (1988) family. These languages were
4374-
developed by Malcolm Atkinson, Ron Morrison and others in their group at
4375-
the University of St. Andrews (St. Andrews, Fife, UK).
4376-
4377-
Additional specific influences can be seen from the following languages:
4378-
4379-
* The structural algebraic types and compilation manager of SML.
4380-
* The attribute and assembly systems of C#.
4381-
* The references and deterministic destructor system of C++.
4382-
* The memory region systems of the ML Kit and Cyclone.
4383-
* The typeclass system of Haskell.
4384-
* The lexical identifier rule of Python.
4385-
* The block syntax of Ruby.
4319+
# Appendix: Influences
4320+
4321+
Rust is not a particularly original language, with design elements coming from
4322+
a wide range of sources. Some of these are listed below (including elements
4323+
that have since been removed):
4324+
4325+
* SML, OCaml: algebraic datatypes, pattern matching, type inference,
4326+
semicolon statement separation
4327+
* C++: references, RAII, smart pointers, move semantics, monomorphisation,
4328+
memory model
4329+
* ML Kit, Cyclone: region based memory management
4330+
* Haskell (GHC): typeclasses, type families
4331+
* Newsqueak, Alef, Limbo: channels, concurrency
4332+
* Erlang: message passing, task failure, ~~linked task failure~~,
4333+
~~lightweight concurrency~~
4334+
* Swift: optional bindings
4335+
* Scheme: hygienic macros
4336+
* C#: attributes
4337+
* Ruby: ~~block syntax~~
4338+
* NIL, Hermes: ~~typestate~~
4339+
* [Unicode Annex #31](http://www.unicode.org/reports/tr31/): identifier and
4340+
pattern syntax
43864341

43874342
[ffi]: guide-ffi.html
43884343
[plugin]: guide-plugin.html

branches/beta/src/libcollections/bit.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,6 @@ pub struct Bitv {
164164
nbits: uint
165165
}
166166

167-
// NOTE(stage0): remove impl after a snapshot
168-
#[cfg(stage0)]
169-
// FIXME(Gankro): NopeNopeNopeNopeNope (wait for IndexGet to be a thing)
170-
impl Index<uint,bool> for Bitv {
171-
#[inline]
172-
fn index(&self, i: &uint) -> &bool {
173-
if self.get(*i).expect("index out of bounds") {
174-
&TRUE
175-
} else {
176-
&FALSE
177-
}
178-
}
179-
}
180-
181-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
182167
// FIXME(Gankro): NopeNopeNopeNopeNope (wait for IndexGet to be a thing)
183168
impl Index<uint> for Bitv {
184169
type Output = bool;

branches/beta/src/libcollections/btree/map.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -877,18 +877,6 @@ impl<K: Show, V: Show> Show for BTreeMap<K, V> {
877877
}
878878
}
879879

880-
// NOTE(stage0): remove impl after a snapshot
881-
#[cfg(stage0)]
882-
#[stable]
883-
impl<K: Ord, Sized? Q, V> Index<Q, V> for BTreeMap<K, V>
884-
where Q: BorrowFrom<K> + Ord
885-
{
886-
fn index(&self, key: &Q) -> &V {
887-
self.get(key).expect("no entry found for key")
888-
}
889-
}
890-
891-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
892880
#[stable]
893881
impl<K: Ord, Sized? Q, V> Index<Q> for BTreeMap<K, V>
894882
where Q: BorrowFrom<K> + Ord
@@ -900,18 +888,6 @@ impl<K: Ord, Sized? Q, V> Index<Q> for BTreeMap<K, V>
900888
}
901889
}
902890

903-
// NOTE(stage0): remove impl after a snapshot
904-
#[cfg(stage0)]
905-
#[stable]
906-
impl<K: Ord, Sized? Q, V> IndexMut<Q, V> for BTreeMap<K, V>
907-
where Q: BorrowFrom<K> + Ord
908-
{
909-
fn index_mut(&mut self, key: &Q) -> &mut V {
910-
self.get_mut(key).expect("no entry found for key")
911-
}
912-
}
913-
914-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
915891
#[stable]
916892
impl<K: Ord, Sized? Q, V> IndexMut<Q> for BTreeMap<K, V>
917893
where Q: BorrowFrom<K> + Ord

0 commit comments

Comments
 (0)