Skip to content

Commit 1afd83a

Browse files
committed
---
yaml --- r: 40471 b: refs/heads/dist-snap c: 7671247 h: refs/heads/master i: 40469: d2aa375 40467: 405df2a 40463: f40de06 v: v3
1 parent 988cfa9 commit 1afd83a

Some content is hidden

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

73 files changed

+949
-1240
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: 371be3c6c4c9be74ee224f74f41006fefa3dda1b
10+
refs/heads/dist-snap: 76712476c270c952d392d33626cc86f3c450e2cb
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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/dist-snap/doc/rust.md

Lines changed: 44 additions & 22 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.
@@ -1104,6 +1103,17 @@ 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 bits_r: &[uint] = &bits;
1115+
~~~~
1116+
11071117
### Traits
11081118

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

1188+
Trait methods may be static. Currently implementations of static methods behave like
1189+
functions declared in the implentation's module.
1190+
11781191
### Implementations
11791192

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

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.
1320+
Attributes terminated by a semi-colon apply to the entity that the attribute is declared
1321+
within. Attributes that are not terminated by a semi-colon apply to the next entity.
13101322

13111323
An example of attributes:
13121324

@@ -1326,9 +1338,9 @@ mod bar {
13261338
...
13271339
}
13281340
1329-
// A documentation attribute
1330-
#[doc = "Add two numbers together."]
1331-
fn add(x: int, y: int) { x + y }
1341+
// A lint attribute used to suppress a warning/error
1342+
#[allow(non_camel_case_types)]
1343+
pub type int8_t = i8;
13321344
~~~~~~~~
13331345

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

13451359
Other attributes may be added or removed during development of the language.
13461360

@@ -1546,7 +1560,9 @@ it is automatically derferenced to make the field access possible.
15461560
### Vector expressions
15471561

15481562
~~~~~~~~{.ebnf .gram}
1549-
vec_expr : '[' "mut" ? [ expr [ ',' expr ] * ] ? ']'
1563+
vec_expr : '[' "mut"? vec_elems? ']'
1564+
1565+
vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
15501566
~~~~~~~~
15511567

15521568
A [_vector_](#vector-types) _expression_ is written by enclosing zero or
@@ -1558,6 +1574,7 @@ When no mutability is specified, the vector is immutable.
15581574
~~~~
15591575
[1, 2, 3, 4];
15601576
["a", "b", "c", "d"];
1577+
[0, ..128]; // vector with 128 zeros
15611578
[mut 0u8, 0u8, 0u8, 0u8];
15621579
~~~~
15631580

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

18901907
~~~~~~~~ {.abnf .gram}
18911908
ident_list : [ ident [ ',' ident ]* ] ? ;
1892-
lambda_expr : '|' ident_list '| expr ;
1909+
lambda_expr : '|' ident_list '|' expr ;
18931910
~~~~~~~~
18941911

18951912
A _lambda expression_ (a.k.a. "anonymous function expression") defines a function and denotes it as a value,
@@ -2169,17 +2186,6 @@ Records and structures can also be pattern-matched and their fields bound to var
21692186
When matching fields of a record,
21702187
the fields being matched are specified first,
21712188
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.
21832189

21842190
~~~~
21852191
# type options = {choose: bool, size: ~str};
@@ -2212,6 +2218,22 @@ fn main() {
22122218
}
22132219
~~~~
22142220

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

branches/dist-snap/src/libcore/char.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,16 @@ pub pure fn to_digit(c: char, radix: uint) -> Option<uint> {
126126
* - chars in [0x100,0xffff] get 4-digit escapes: `\\uNNNN`
127127
* - chars above 0x10000 get 8-digit escapes: `\\UNNNNNNNN`
128128
*/
129-
pub pure fn escape_unicode(c: char) -> ~str {
129+
pub fn escape_unicode(c: char) -> ~str {
130130
let s = u32::to_str(c as u32, 16u);
131131
let (c, pad) = (if c <= '\xff' { ('x', 2u) }
132132
else if c <= '\uffff' { ('u', 4u) }
133133
else { ('U', 8u) });
134134
assert str::len(s) <= pad;
135135
let mut out = ~"\\";
136-
unsafe {
137-
str::push_str(&mut out, str::from_char(c));
138-
for uint::range(str::len(s), pad) |_i|
139-
{ str::push_str(&mut out, ~"0"); }
140-
str::push_str(&mut out, s);
141-
}
136+
str::push_str(&mut out, str::from_char(c));
137+
for uint::range(str::len(s), pad) |_i| { str::push_str(&mut out, ~"0"); }
138+
str::push_str(&mut out, s);
142139
move out
143140
}
144141

@@ -154,7 +151,7 @@ pub pure fn escape_unicode(c: char) -> ~str {
154151
* - Any other chars in the range [0x20,0x7e] are not escaped.
155152
* - Any other chars are given hex unicode escapes; see `escape_unicode`.
156153
*/
157-
pub pure fn escape_default(c: char) -> ~str {
154+
pub fn escape_default(c: char) -> ~str {
158155
match c {
159156
'\t' => ~"\\t",
160157
'\r' => ~"\\r",

branches/dist-snap/src/libcore/extfmt.rs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
1-
#[doc(hidden)];
1+
//! Support for fmt! expressions.
2+
//!
3+
//! The syntax is close to that of Posix format strings:
4+
//!
5+
//! ~~~~~~
6+
//! Format := '%' Parameter? Flag* Width? Precision? Type
7+
//! Parameter := [0-9]+ '$'
8+
//! Flag := [ 0#+-]
9+
//! Width := Parameter | [0-9]+
10+
//! Precision := '.' [0-9]+
11+
//! Type := [bcdfiostuxX?]
12+
//! ~~~~~~
13+
//!
14+
//! * Parameter is the 1-based argument to apply the format to. Currently not
15+
//! implemented.
16+
//! * Flag 0 causes leading zeros to be used for padding when converting
17+
//! numbers.
18+
//! * Flag # causes the conversion to be done in an *alternative* manner.
19+
//! Currently not implemented.
20+
//! * Flag + causes signed numbers to always be prepended with a sign
21+
//! character.
22+
//! * Flag - left justifies the result
23+
//! * Width specifies the minimum field width of the result. By default
24+
//! leading spaces are added.
25+
//! * Precision specifies the minimum number of digits for integral types
26+
//! and the minimum number
27+
//! of decimal places for float.
28+
//!
29+
//! The types currently supported are:
30+
//!
31+
//! * b - bool
32+
//! * c - char
33+
//! * d - int
34+
//! * f - float
35+
//! * i - int (same as d)
36+
//! * o - uint as octal
37+
//! * t - uint as binary
38+
//! * u - uint
39+
//! * x - uint as lower-case hexadecimal
40+
//! * X - uint as upper-case hexadecimal
41+
//! * s - str (any flavor)
42+
//! * ? - arbitrary type (does not use the to_str trait)
43+
244
// NB: transitionary, de-mode-ing.
345
#[forbid(deprecated_mode)];
446
#[forbid(deprecated_pattern)];
@@ -44,6 +86,7 @@ use option::{Some, None};
4486
*/
4587

4688
// Functions used by the fmt extension at compile time
89+
#[doc(hidden)]
4790
pub mod ct {
4891
pub enum Signedness { Signed, Unsigned, }
4992
pub enum Caseness { CaseUpper, CaseLower, }
@@ -277,6 +320,7 @@ pub mod ct {
277320
// decisions made a runtime. If it proves worthwhile then some of these
278321
// conditions can be evaluated at compile-time. For now though it's cleaner to
279322
// implement it 0this way, I think.
323+
#[doc(hidden)]
280324
pub mod rt {
281325
pub const flag_none : u32 = 0u32;
282326
pub const flag_left_justify : u32 = 0b00000000000001u32;
@@ -464,6 +508,7 @@ pub mod rt {
464508
}
465509
}
466510

511+
// Bulk of the tests are in src/test/run-pass/syntax-extension-fmt.rs
467512
#[cfg(test)]
468513
mod test {
469514
#[test]

branches/dist-snap/src/libcore/from_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
use option::Option;
88

99
pub trait FromStr {
10-
static pure fn from_str(s: &str) -> Option<self>;
10+
static fn from_str(s: &str) -> Option<self>;
1111
}
1212

branches/dist-snap/src/libcore/int-template.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl T: iter::Times {
106106
* * buf - A byte buffer
107107
* * radix - The base of the number
108108
*/
109-
pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
109+
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
110110
if vec::len(buf) == 0u { return None; }
111111
let mut i = vec::len(buf) - 1u;
112112
let mut start = 0u;
@@ -129,13 +129,10 @@ pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
129129
}
130130

131131
/// Parse a string to an int
132-
pub pure fn from_str(s: &str) -> Option<T>
133-
{
134-
parse_bytes(str::to_bytes(s), 10u)
135-
}
132+
pub fn from_str(s: &str) -> Option<T> { parse_bytes(str::to_bytes(s), 10u) }
136133

137134
impl T : FromStr {
138-
static pure fn from_str(s: &str) -> Option<T> { from_str(s) }
135+
static fn from_str(s: &str) -> Option<T> { from_str(s) }
139136
}
140137

141138
/// Convert to a string in a given base

branches/dist-snap/src/libcore/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ pub pure fn with_bytes_reader<t>(bytes: &[u8], f: fn(Reader) -> t) -> t {
512512
f(BytesReader { bytes: bytes, pos: 0u } as Reader)
513513
}
514514

515-
pub pure fn with_str_reader<T>(s: &str, f: fn(Reader) -> T) -> T {
515+
pub fn with_str_reader<T>(s: &str, f: fn(Reader) -> T) -> T {
516516
str::byte_slice(s, |bytes| with_bytes_reader(bytes, f))
517517
}
518518

branches/dist-snap/src/libcore/mutable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<T> Data<T> {
4848
}
4949
}
5050

51-
pure fn borrow_const<R>(op: &fn(t: &const T) -> R) -> R {
51+
fn borrow_const<R>(op: &fn(t: &const T) -> R) -> R {
5252
op(&const self.value)
5353
}
5454

branches/dist-snap/src/libcore/result.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ pub fn map_err<T: Copy, E, F: Copy>(res: &Result<T, E>, op: fn((&E)) -> F)
204204
}
205205

206206
impl<T, E> Result<T, E> {
207-
pure fn get_ref(&self) -> &self/T { get_ref(self) }
207+
fn get_ref(&self) -> &self/T { get_ref(self) }
208208

209-
pure fn is_ok() -> bool { is_ok(&self) }
209+
fn is_ok() -> bool { is_ok(&self) }
210210

211-
pure fn is_err() -> bool { is_err(&self) }
211+
fn is_err() -> bool { is_err(&self) }
212212

213-
pure fn iter(f: fn((&T))) {
213+
fn iter(f: fn((&T))) {
214214
match self {
215215
Ok(ref t) => f(t),
216216
Err(_) => ()
@@ -226,7 +226,7 @@ impl<T, E> Result<T, E> {
226226
}
227227

228228
impl<T: Copy, E> Result<T, E> {
229-
pure fn get() -> T { get(&self) }
229+
fn get() -> T { get(&self) }
230230

231231
fn map_err<F:Copy>(op: fn((&E)) -> F) -> Result<T,F> {
232232
match self {
@@ -237,7 +237,7 @@ impl<T: Copy, E> Result<T, E> {
237237
}
238238

239239
impl<T, E: Copy> Result<T, E> {
240-
pure fn get_err() -> E { get_err(&self) }
240+
fn get_err() -> E { get_err(&self) }
241241

242242
fn map<U:Copy>(op: fn((&T)) -> U) -> Result<U,E> {
243243
match self {

branches/dist-snap/src/libcore/uint-template.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl T: iter::Times {
100100
*
101101
* `buf` must not be empty
102102
*/
103-
pub pure fn parse_bytes(buf: &[const u8], radix: uint) -> Option<T> {
103+
pub fn parse_bytes(buf: &[const u8], radix: uint) -> Option<T> {
104104
if vec::len(buf) == 0u { return None; }
105105
let mut i = vec::len(buf) - 1u;
106106
let mut power = 1u as T;
@@ -117,13 +117,10 @@ pub pure fn parse_bytes(buf: &[const u8], radix: uint) -> Option<T> {
117117
}
118118

119119
/// Parse a string to an int
120-
pub pure fn from_str(s: &str) -> Option<T>
121-
{
122-
parse_bytes(str::to_bytes(s), 10u)
123-
}
120+
pub fn from_str(s: &str) -> Option<T> { parse_bytes(str::to_bytes(s), 10u) }
124121

125122
impl T : FromStr {
126-
static pure fn from_str(s: &str) -> Option<T> { from_str(s) }
123+
static fn from_str(s: &str) -> Option<T> { from_str(s) }
127124
}
128125

129126
/// Parse a string as an unsigned integer.

0 commit comments

Comments
 (0)