Skip to content

Commit 01a7d7c

Browse files
committed
---
yaml --- r: 33842 b: refs/heads/snap-stage3 c: ca6970a h: refs/heads/master v: v3
1 parent 9db0641 commit 01a7d7c

File tree

216 files changed

+9454
-2087
lines changed

Some content is hidden

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

216 files changed

+9454
-2087
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d718bc292d342a99580ec971dc7e873e5fc6e5c4
4+
refs/heads/snap-stage3: ca6970a65ebdc153d53e9b6c2ccb224ee705ac94
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/README

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
The markdown docs are only generated by make when node is installed (use
2+
`make doc`). If you don't have node installed you can generate them yourself.
3+
Unfortunately there's no real standard for markdown and all the tools work
4+
differently. pandoc is one that seems to work well.
5+
6+
To generate an html version of a doc do something like:
7+
pandoc --from=markdown --to=html --number-sections -o build/doc/rust.html doc/rust.md && git web--browse build/doc/rust.html
8+
9+
The syntax for pandoc flavored markdown can be found at:
10+
http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown
11+
12+
A nice quick reference (for non-pandoc markdown) is at:
13+
http://kramdown.rubyforge.org/quickref.html

branches/snap-stage3/doc/rust.md

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,8 @@ For parsing reasons, delimiters must be balanced, but they are otherwise not spe
510510

511511
In the matcher, `$` _name_ `:` _designator_ matches the nonterminal in the
512512
Rust syntax named by _designator_. Valid designators are `item`, `block`,
513-
`stmt`, `pat`, `expr`, `ty`, `ident`, `path`, `tt`, `matchers`. The last two
514-
are the right-hand side and the left-hand side respectively of the `=>` in
515-
macro rules. In the transcriber, the designator is already known, and so only
513+
`stmt`, `pat`, `expr`, `ty` (type), `ident`, `path`, `matchers` (lhs of the `=>` in macro rules),
514+
`tt` (rhs of the `=>` in macro rules). In the transcriber, the designator is already known, and so only
516515
the name of a matched nonterminal comes after the dollar sign.
517516

518517
In both the matcher and transcriber, the Kleene star-like operator indicates repetition.
@@ -799,7 +798,7 @@ extern mod ruststd (name = "std"); // linking to 'std' under another name
799798
##### Use declarations
800799

801800
~~~~~~~~ {.ebnf .gram}
802-
use_decl : "use" ident [ '=' path
801+
use_decl : "pub"? "use" ident [ '=' path
803802
| "::" path_glob ] ;
804803
805804
path_glob : ident [ "::" path_glob ] ?
@@ -1104,6 +1103,27 @@ Constants are declared with the `const` keyword.
11041103
A constant item must have an expression giving its definition.
11051104
The definition expression of a constant is limited to expression forms that can be evaluated at compile time.
11061105

1106+
Constants must be explicitly typed. The type may be ```bool```, ```char```, a number, or a type derived from
1107+
those primitive types. The derived types are borrowed pointers, static arrays, tuples, and structs.
1108+
1109+
~~~~
1110+
const bit1: uint = 1 << 0;
1111+
const bit2: uint = 1 << 1;
1112+
1113+
const bits: [uint * 2] = [bit1, bit2];
1114+
const string: &str = "bitstring";
1115+
1116+
struct BitsNStrings {
1117+
mybits: [uint *2],
1118+
mystring: &str
1119+
}
1120+
1121+
const bits_n_strings: BitsNStrings = BitsNStrings {
1122+
mybits: bits,
1123+
mystring: string
1124+
};
1125+
~~~~
1126+
11071127
### Traits
11081128

11091129
A _trait_ describes a set of method types.
@@ -1175,6 +1195,9 @@ Values with a trait type can have [methods called](#method-call-expressions) on
11751195
for any method in the trait,
11761196
and can be used to instantiate type parameters that are bounded by the trait.
11771197

1198+
Trait methods may be static. Currently implementations of static methods behave like
1199+
functions declared in the implentation's module.
1200+
11781201
### Implementations
11791202

11801203
An _implementation_ is an item that implements a [trait](#traits) for a specific type.
@@ -1304,9 +1327,8 @@ Attributes may appear as any of
13041327
* An identifier followed by the equals sign '=' and a literal, providing a key/value pair
13051328
* An identifier followed by a parenthesized list of sub-attribute arguments
13061329

1307-
Attributes are applied to an entity by placing them within a hash-list
1308-
(`#[...]`) as either a prefix to the entity or as a semicolon-delimited
1309-
declaration within the entity body.
1330+
Attributes terminated by a semi-colon apply to the entity that the attribute is declared
1331+
within. Attributes that are not terminated by a semi-colon apply to the next entity.
13101332

13111333
An example of attributes:
13121334

@@ -1326,9 +1348,9 @@ mod bar {
13261348
...
13271349
}
13281350
1329-
// A documentation attribute
1330-
#[doc = "Add two numbers together."]
1331-
fn add(x: int, y: int) { x + y }
1351+
// A lint attribute used to suppress a warning/error
1352+
#[allow(non_camel_case_types)]
1353+
pub type int8_t = i8;
13321354
~~~~~~~~
13331355

13341356
> **Note:** In future versions of Rust, user-provided extensions to the compiler will be able to interpret attributes.
@@ -1341,6 +1363,8 @@ names are effectively reserved. Some significant attributes include:
13411363
* The `cfg` attribute, for conditional-compilation by build-configuration.
13421364
* The `link` attribute, for describing linkage metadata for a crate.
13431365
* The `test` attribute, for marking functions as unit tests.
1366+
* The `allow`, `warn`, `forbid`, and `deny` attributes, for controling lint checks. Lint checks supported
1367+
by the compiler can be found via `rustc -W help`.
13441368

13451369
Other attributes may be added or removed during development of the language.
13461370

@@ -1546,7 +1570,9 @@ it is automatically derferenced to make the field access possible.
15461570
### Vector expressions
15471571

15481572
~~~~~~~~{.ebnf .gram}
1549-
vec_expr : '[' "mut" ? [ expr [ ',' expr ] * ] ? ']'
1573+
vec_expr : '[' "mut"? vec_elems? ']'
1574+
1575+
vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
15501576
~~~~~~~~
15511577

15521578
A [_vector_](#vector-types) _expression_ is written by enclosing zero or
@@ -1558,6 +1584,7 @@ When no mutability is specified, the vector is immutable.
15581584
~~~~
15591585
[1, 2, 3, 4];
15601586
["a", "b", "c", "d"];
1587+
[0, ..128]; // vector with 128 zeros
15611588
[mut 0u8, 0u8, 0u8, 0u8];
15621589
~~~~
15631590

@@ -1889,7 +1916,7 @@ let x: int = add(1, 2);
18891916

18901917
~~~~~~~~ {.abnf .gram}
18911918
ident_list : [ ident [ ',' ident ]* ] ? ;
1892-
lambda_expr : '|' ident_list '| expr ;
1919+
lambda_expr : '|' ident_list '|' expr ;
18931920
~~~~~~~~
18941921

18951922
A _lambda expression_ (a.k.a. "anonymous function expression") defines a function and denotes it as a value,
@@ -2169,17 +2196,6 @@ Records and structures can also be pattern-matched and their fields bound to var
21692196
When matching fields of a record,
21702197
the fields being matched are specified first,
21712198
then a placeholder (`_`) represents the remaining fields.
2172-
2173-
A pattern that's just a variable binding,
2174-
like `Nil` in the previous answer,
2175-
could either refer to an enum variant that's in scope,
2176-
or bind a new variable.
2177-
The compiler resolves this ambiguity by forbidding variable bindings that occur in ```match``` patterns from shadowing names of variants that are in scope.
2178-
For example, wherever ```List``` is in scope,
2179-
a ```match``` pattern would not be able to bind ```Nil``` as a new name.
2180-
The compiler interprets a variable pattern `x` as a binding _only_ if there is no variant named `x` in scope.
2181-
A convention you can use to avoid conflicts is simply to name variants with upper-case letters,
2182-
and local variables with lower-case letters.
21832199

21842200
~~~~
21852201
# type options = {choose: bool, size: ~str};
@@ -2212,6 +2228,22 @@ fn main() {
22122228
}
22132229
~~~~
22142230

2231+
Patterns that bind variables default to binding to a copy of the matched value. This can be made
2232+
explicit using the ```copy``` keyword, changed to bind to a borrowed pointer by using the ```ref```
2233+
keyword, or to a mutable borrowed pointer using ```ref mut```, or the value can be moved into
2234+
the new binding using ```move```.
2235+
2236+
A pattern that's just an identifier,
2237+
like `Nil` in the previous answer,
2238+
could either refer to an enum variant that's in scope,
2239+
or bind a new variable.
2240+
The compiler resolves this ambiguity by forbidding variable bindings that occur in ```match``` patterns from shadowing names of variants that are in scope.
2241+
For example, wherever ```List``` is in scope,
2242+
a ```match``` pattern would not be able to bind ```Nil``` as a new name.
2243+
The compiler interprets a variable pattern `x` as a binding _only_ if there is no variant named `x` in scope.
2244+
A convention you can use to avoid conflicts is simply to name variants with upper-case letters,
2245+
and local variables with lower-case letters.
2246+
22152247
Multiple match patterns may be joined with the `|` operator. A
22162248
range of values may be specified with `..`. For example:
22172249

branches/snap-stage3/doc/tutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,8 +1540,7 @@ them. In the rare case where the compiler needs assistance, though, the
15401540
arguments and return types may be annotated.
15411541

15421542
~~~~
1543-
# type mygoodness = fn(~str) -> ~str; type what_the = int;
1544-
let bloop = |well, oh: mygoodness| -> what_the { fail oh(well) };
1543+
let square = |x: int| -> uint { x * x as uint };
15451544
~~~~
15461545

15471546
There are several forms of closure, each with its own role. The most
@@ -2043,8 +2042,9 @@ as in this version of `print_all` that copies elements.
20432042
fn print_all<T: Printable Copy>(printable_things: ~[T]) {
20442043
let mut i = 0;
20452044
while i < printable_things.len() {
2046-
let copy_of_thing = printable_things[0];
2045+
let copy_of_thing = printable_things[i];
20472046
copy_of_thing.print();
2047+
i += 1;
20482048
}
20492049
}
20502050
~~~

branches/snap-stage3/mk/tools.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ COMPILETEST_INPUTS := $(wildcard $(S)src/compiletest/*rs)
1010

1111
# Cargo, the package manager
1212
CARGO_LIB := $(S)src/libcargo/cargo.rc
13-
CARGO_INPUTS := $(wildcard $(S)src/cargo/*rs)
13+
CARGO_INPUTS := $(wildcard $(S)src/libcargo/*rs)
1414

1515
# Rustdoc, the documentation tool
1616
RUSTDOC_LIB := $(S)src/librustdoc/rustdoc.rc
17-
RUSTDOC_INPUTS := $(wildcard $(S)src/rustdoc/*.rs)
17+
RUSTDOC_INPUTS := $(wildcard $(S)src/librustdoc/*.rs)
1818

1919
# Rusti, the JIT REPL
2020
RUSTI_LIB := $(S)src/librusti/rusti.rc

branches/snap-stage3/src/compiletest/common.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, }
22

3+
#[cfg(stage0)]
34
impl mode : cmp::Eq {
45
pure fn eq(other: &mode) -> bool {
56
(*other) as int == self as int
67
}
78
pure fn ne(other: &mode) -> bool { !self.eq(other) }
89
}
10+
#[cfg(stage1)]
11+
#[cfg(stage2)]
12+
impl mode : cmp::Eq {
13+
pure fn eq(&self, other: &mode) -> bool {
14+
(*other) as int == (*self) as int
15+
}
16+
pure fn ne(&self, other: &mode) -> bool { !(*self).eq(other) }
17+
}
918

1019
type config = {
1120
// The library paths required for running the compiler

branches/snap-stage3/src/compiletest/compiletest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ fn parse_config(args: ~[~str]) -> config {
3535
assert (vec::is_not_empty(args));
3636
let args_ = vec::tail(args);
3737
let matches =
38-
match getopts::getopts(args_, opts) {
38+
&match getopts::getopts(args_, opts) {
3939
Ok(m) => m,
4040
Err(f) => fail getopts::fail_str(f)
4141
};
4242

43-
fn opt_path(m: getopts::Matches, nm: ~str) -> Path {
43+
fn opt_path(m: &getopts::Matches, nm: ~str) -> Path {
4444
Path(getopts::opt_str(m, nm))
4545
}
4646

branches/snap-stage3/src/libcargo/cargo.rs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct Package {
3030
}
3131

3232
impl Package : cmp::Ord {
33+
#[cfg(stage0)]
3334
pure fn lt(other: &Package) -> bool {
3435
if self.name.lt(&(*other).name) { return true; }
3536
if (*other).name.lt(&self.name) { return false; }
@@ -46,9 +47,39 @@ impl Package : cmp::Ord {
4647
if self.versions.lt(&(*other).versions) { return true; }
4748
return false;
4849
}
50+
#[cfg(stage1)]
51+
#[cfg(stage2)]
52+
pure fn lt(&self, other: &Package) -> bool {
53+
if (*self).name.lt(&(*other).name) { return true; }
54+
if (*other).name.lt(&(*self).name) { return false; }
55+
if (*self).uuid.lt(&(*other).uuid) { return true; }
56+
if (*other).uuid.lt(&(*self).uuid) { return false; }
57+
if (*self).url.lt(&(*other).url) { return true; }
58+
if (*other).url.lt(&(*self).url) { return false; }
59+
if (*self).method.lt(&(*other).method) { return true; }
60+
if (*other).method.lt(&(*self).method) { return false; }
61+
if (*self).description.lt(&(*other).description) { return true; }
62+
if (*other).description.lt(&(*self).description) { return false; }
63+
if (*self).tags.lt(&(*other).tags) { return true; }
64+
if (*other).tags.lt(&(*self).tags) { return false; }
65+
if (*self).versions.lt(&(*other).versions) { return true; }
66+
return false;
67+
}
68+
#[cfg(stage0)]
4969
pure fn le(other: &Package) -> bool { !(*other).lt(&self) }
70+
#[cfg(stage1)]
71+
#[cfg(stage2)]
72+
pure fn le(&self, other: &Package) -> bool { !(*other).lt(&(*self)) }
73+
#[cfg(stage0)]
5074
pure fn ge(other: &Package) -> bool { !self.lt(other) }
75+
#[cfg(stage1)]
76+
#[cfg(stage2)]
77+
pure fn ge(&self, other: &Package) -> bool { !(*self).lt(other) }
78+
#[cfg(stage0)]
5179
pure fn gt(other: &Package) -> bool { (*other).lt(&self) }
80+
#[cfg(stage1)]
81+
#[cfg(stage2)]
82+
pure fn gt(&self, other: &Package) -> bool { (*other).lt(&(*self)) }
5283
}
5384

5485
struct Source {
@@ -94,10 +125,20 @@ struct Options {
94125
enum Mode { SystemMode, UserMode, LocalMode }
95126

96127
impl Mode : cmp::Eq {
128+
#[cfg(stage0)]
97129
pure fn eq(other: &Mode) -> bool {
98130
(self as uint) == ((*other) as uint)
99131
}
132+
#[cfg(stage1)]
133+
#[cfg(stage2)]
134+
pure fn eq(&self, other: &Mode) -> bool {
135+
((*self) as uint) == ((*other) as uint)
136+
}
137+
#[cfg(stage0)]
100138
pure fn ne(other: &Mode) -> bool { !self.eq(other) }
139+
#[cfg(stage1)]
140+
#[cfg(stage2)]
141+
pure fn ne(&self, other: &Mode) -> bool { !(*self).eq(other) }
101142
}
102143

103144
fn opts() -> ~[getopts::Opt] {
@@ -620,7 +661,7 @@ fn load_source_packages(c: &Cargo, src: @Source) {
620661
}
621662

622663
fn build_cargo_options(argv: ~[~str]) -> Options {
623-
let matches = match getopts::getopts(argv, opts()) {
664+
let matches = &match getopts::getopts(argv, opts()) {
624665
result::Ok(m) => m,
625666
result::Err(f) => {
626667
fail fmt!("%s", getopts::fail_str(f));

branches/snap-stage3/src/libcore/bool.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,16 @@ pub fn all_values(blk: fn(v: bool)) {
6666
pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
6767

6868
impl bool : cmp::Eq {
69+
#[cfg(stage0)]
6970
pure fn eq(other: &bool) -> bool { self == (*other) }
71+
#[cfg(stage1)]
72+
#[cfg(stage2)]
73+
pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
74+
#[cfg(stage0)]
7075
pure fn ne(other: &bool) -> bool { self != (*other) }
76+
#[cfg(stage1)]
77+
#[cfg(stage2)]
78+
pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
7179
}
7280

7381
#[test]

branches/snap-stage3/src/libcore/box.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,39 @@ pub pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
2828
}
2929

3030
impl<T:Eq> @const T : Eq {
31+
#[cfg(stage0)]
3132
pure fn eq(other: &@const T) -> bool { *self == *(*other) }
33+
#[cfg(stage1)]
34+
#[cfg(stage2)]
35+
pure fn eq(&self, other: &@const T) -> bool { *(*self) == *(*other) }
36+
#[cfg(stage0)]
3237
pure fn ne(other: &@const T) -> bool { *self != *(*other) }
38+
#[cfg(stage1)]
39+
#[cfg(stage2)]
40+
pure fn ne(&self, other: &@const T) -> bool { *(*self) != *(*other) }
3341
}
3442

3543
impl<T:Ord> @const T : Ord {
44+
#[cfg(stage0)]
3645
pure fn lt(other: &@const T) -> bool { *self < *(*other) }
46+
#[cfg(stage1)]
47+
#[cfg(stage2)]
48+
pure fn lt(&self, other: &@const T) -> bool { *(*self) < *(*other) }
49+
#[cfg(stage0)]
3750
pure fn le(other: &@const T) -> bool { *self <= *(*other) }
51+
#[cfg(stage1)]
52+
#[cfg(stage2)]
53+
pure fn le(&self, other: &@const T) -> bool { *(*self) <= *(*other) }
54+
#[cfg(stage0)]
3855
pure fn ge(other: &@const T) -> bool { *self >= *(*other) }
56+
#[cfg(stage1)]
57+
#[cfg(stage2)]
58+
pure fn ge(&self, other: &@const T) -> bool { *(*self) >= *(*other) }
59+
#[cfg(stage0)]
3960
pure fn gt(other: &@const T) -> bool { *self > *(*other) }
61+
#[cfg(stage1)]
62+
#[cfg(stage2)]
63+
pure fn gt(&self, other: &@const T) -> bool { *(*self) > *(*other) }
4064
}
4165

4266
#[test]

0 commit comments

Comments
 (0)