Skip to content

Commit d5a4ef9

Browse files
committed
---
yaml --- r: 39037 b: refs/heads/incoming c: ddbff6f h: refs/heads/master i: 39035: 3cc58e6 v: v3
1 parent eaad63a commit d5a4ef9

Some content is hidden

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

64 files changed

+1093
-900
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: a24da7e254110dcd38183e73fa1bb9ef143a6b27
9+
refs/heads/incoming: ddbff6fd2a46b2b7073794d200140f0407208c07
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/doc/README

Lines changed: 0 additions & 13 deletions
This file was deleted.

branches/incoming/doc/rust.md

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,17 +1104,6 @@ Constants are declared with the `const` keyword.
11041104
A constant item must have an expression giving its definition.
11051105
The definition expression of a constant is limited to expression forms that can be evaluated at compile time.
11061106

1107-
Constants must be explicitly typed. The type may be ```bool```, ```char```, a number, or a type derived from
1108-
those primitive types. The derived types are borrowed pointers, static arrays, tuples, and structs.
1109-
1110-
~~~~
1111-
const bit1: uint = 1 << 0;
1112-
const bit2: uint = 1 << 1;
1113-
1114-
const bits: [uint * 2] = [bit1, bit2];
1115-
const bits_r: &[uint] = &bits;
1116-
~~~~
1117-
11181107
### Traits
11191108

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

1189-
Trait methods may be static. Currently implementations of static methods behave like
1190-
functions declared in the implentation's module.
1191-
11921178
### Implementations
11931179

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

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

13241311
An example of attributes:
13251312

@@ -1339,9 +1326,9 @@ mod bar {
13391326
...
13401327
}
13411328
1342-
// A lint attribute used to suppress a warning/error
1343-
#[allow(non_camel_case_types)]
1344-
pub type int8_t = i8;
1329+
// A documentation attribute
1330+
#[doc = "Add two numbers together."]
1331+
fn add(x: int, y: int) { x + y }
13451332
~~~~~~~~
13461333

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

13601345
Other attributes may be added or removed during development of the language.
13611346

@@ -1561,9 +1546,7 @@ it is automatically derferenced to make the field access possible.
15611546
### Vector expressions
15621547

15631548
~~~~~~~~{.ebnf .gram}
1564-
vec_expr : '[' "mut"? vec_elems? ']'
1565-
1566-
vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
1549+
vec_expr : '[' "mut" ? [ expr [ ',' expr ] * ] ? ']'
15671550
~~~~~~~~
15681551

15691552
A [_vector_](#vector-types) _expression_ is written by enclosing zero or
@@ -1575,7 +1558,6 @@ When no mutability is specified, the vector is immutable.
15751558
~~~~
15761559
[1, 2, 3, 4];
15771560
["a", "b", "c", "d"];
1578-
[0, ..128]; // vector with 128 zeros
15791561
[mut 0u8, 0u8, 0u8, 0u8];
15801562
~~~~
15811563

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

19081890
~~~~~~~~ {.abnf .gram}
19091891
ident_list : [ ident [ ',' ident ]* ] ? ;
1910-
lambda_expr : '|' ident_list '|' expr ;
1892+
lambda_expr : '|' ident_list '| expr ;
19111893
~~~~~~~~
19121894

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

21912184
~~~~
21922185
# type options = {choose: bool, size: ~str};
@@ -2219,22 +2212,6 @@ fn main() {
22192212
}
22202213
~~~~
22212214

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

branches/incoming/src/libcore/char.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,19 @@ 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 fn escape_unicode(c: char) -> ~str {
129+
pub pure 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-
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);
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+
}
139142
move out
140143
}
141144

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

branches/incoming/src/libcore/extfmt.rs

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,4 @@
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-
1+
#[doc(hidden)];
442
// NB: transitionary, de-mode-ing.
453
#[forbid(deprecated_mode)];
464
#[forbid(deprecated_pattern)];
@@ -86,7 +44,6 @@ use option::{Some, None};
8644
*/
8745

8846
// Functions used by the fmt extension at compile time
89-
#[doc(hidden)]
9047
pub mod ct {
9148
pub enum Signedness { Signed, Unsigned, }
9249
pub enum Caseness { CaseUpper, CaseLower, }
@@ -320,7 +277,6 @@ pub mod ct {
320277
// decisions made a runtime. If it proves worthwhile then some of these
321278
// conditions can be evaluated at compile-time. For now though it's cleaner to
322279
// implement it 0this way, I think.
323-
#[doc(hidden)]
324280
pub mod rt {
325281
pub const flag_none : u32 = 0u32;
326282
pub const flag_left_justify : u32 = 0b00000000000001u32;
@@ -508,7 +464,6 @@ pub mod rt {
508464
}
509465
}
510466

511-
// Bulk of the tests are in src/test/run-pass/syntax-extension-fmt.rs
512467
#[cfg(test)]
513468
mod test {
514469
#[test]

branches/incoming/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 fn from_str(s: &str) -> Option<self>;
10+
static pure fn from_str(s: &str) -> Option<self>;
1111
}
1212

branches/incoming/src/libcore/int-template.rs

Lines changed: 6 additions & 3 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 fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
109+
pub pure 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,10 +129,13 @@ pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
129129
}
130130

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

134137
impl T : FromStr {
135-
static fn from_str(s: &str) -> Option<T> { from_str(s) }
138+
static pure fn from_str(s: &str) -> Option<T> { from_str(s) }
136139
}
137140

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

branches/incoming/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 fn with_str_reader<T>(s: &str, f: fn(Reader) -> T) -> T {
515+
pub pure 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/incoming/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-
fn borrow_const<R>(op: &fn(t: &const T) -> R) -> R {
51+
pure fn borrow_const<R>(op: &fn(t: &const T) -> R) -> R {
5252
op(&const self.value)
5353
}
5454

branches/incoming/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-
fn get_ref(&self) -> &self/T { get_ref(self) }
207+
pure fn get_ref(&self) -> &self/T { get_ref(self) }
208208

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

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

213-
fn iter(f: fn((&T))) {
213+
pure 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-
fn get() -> T { get(&self) }
229+
pure 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-
fn get_err() -> E { get_err(&self) }
240+
pure fn get_err() -> E { get_err(&self) }
241241

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

branches/incoming/src/libcore/uint-template.rs

Lines changed: 6 additions & 3 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 fn parse_bytes(buf: &[const u8], radix: uint) -> Option<T> {
103+
pub pure 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,10 +117,13 @@ pub fn parse_bytes(buf: &[const u8], radix: uint) -> Option<T> {
117117
}
118118

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

122125
impl T : FromStr {
123-
static fn from_str(s: &str) -> Option<T> { from_str(s) }
126+
static pure fn from_str(s: &str) -> Option<T> { from_str(s) }
124127
}
125128

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

branches/incoming/src/libfuzzer/fuzzer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn as_str(f: fn@(+x: io::Writer)) -> ~str {
225225
io::with_str_writer(f)
226226
}
227227

228-
fn check_variants_of_ast(crate: ast::crate, codemap: codemap::CodeMap,
228+
fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
229229
filename: &Path, cx: context) {
230230
let stolen = steal(crate, cx.mode);
231231
let extra_exprs = vec::filter(common_exprs(),
@@ -239,7 +239,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: codemap::CodeMap,
239239

240240
fn check_variants_T<T: Copy>(
241241
crate: ast::crate,
242-
codemap: codemap::CodeMap,
242+
codemap: @codemap::CodeMap,
243243
filename: &Path,
244244
thing_label: ~str,
245245
things: ~[T],

0 commit comments

Comments
 (0)