Skip to content

Commit a4a371a

Browse files
committed
---
yaml --- r: 33755 b: refs/heads/snap-stage3 c: e46de53 h: refs/heads/master i: 33753: 48c3b8c 33751: 1c5c10f v: v3
1 parent 6b65985 commit a4a371a

Some content is hidden

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

62 files changed

+871
-1093
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: 68c73dc5f29bf75d6c76054ebfaf2fbb3751a71b
4+
refs/heads/snap-stage3: e46de5381b7d16797ff690e7770acf8ba49ba8c3
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: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,9 +1304,8 @@ Attributes may appear as any of
13041304
* An identifier followed by the equals sign '=' and a literal, providing a key/value pair
13051305
* An identifier followed by a parenthesized list of sub-attribute arguments
13061306

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

13111310
An example of attributes:
13121311

@@ -1326,9 +1325,9 @@ mod bar {
13261325
...
13271326
}
13281327
1329-
// A documentation attribute
1330-
#[doc = "Add two numbers together."]
1331-
fn add(x: int, y: int) { x + y }
1328+
// A lint attribute used to suppress a warning/error
1329+
#[allow(non_camel_case_types)]
1330+
pub type int8_t = i8;
13321331
~~~~~~~~
13331332

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

13451346
Other attributes may be added or removed during development of the language.
13461347

@@ -1546,7 +1547,9 @@ it is automatically derferenced to make the field access possible.
15461547
### Vector expressions
15471548

15481549
~~~~~~~~{.ebnf .gram}
1549-
vec_expr : '[' "mut" ? [ expr [ ',' expr ] * ] ? ']'
1550+
vec_expr : '[' "mut"? vec_elems? ']'
1551+
1552+
vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
15501553
~~~~~~~~
15511554

15521555
A [_vector_](#vector-types) _expression_ is written by enclosing zero or
@@ -1556,8 +1559,10 @@ indicate that the elements of the resulting vector may be mutated.
15561559
When no mutability is specified, the vector is immutable.
15571560

15581561
~~~~
1562+
[]
15591563
[1, 2, 3, 4];
15601564
["a", "b", "c", "d"];
1565+
[0, ..128]; // vector with 128 zeros
15611566
[mut 0u8, 0u8, 0u8, 0u8];
15621567
~~~~
15631568

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

18901895
~~~~~~~~ {.abnf .gram}
18911896
ident_list : [ ident [ ',' ident ]* ] ? ;
1892-
lambda_expr : '|' ident_list '| expr ;
1897+
lambda_expr : '|' ident_list '|' expr ;
18931898
~~~~~~~~
18941899

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

21842178
~~~~
21852179
# type options = {choose: bool, size: ~str};
@@ -2212,6 +2206,17 @@ fn main() {
22122206
}
22132207
~~~~
22142208

2209+
A pattern that's just a variable binding,
2210+
like `Nil` in the previous answer,
2211+
could either refer to an enum variant that's in scope,
2212+
or bind a new variable.
2213+
The compiler resolves this ambiguity by forbidding variable bindings that occur in ```match``` patterns from shadowing names of variants that are in scope.
2214+
For example, wherever ```List``` is in scope,
2215+
a ```match``` pattern would not be able to bind ```Nil``` as a new name.
2216+
The compiler interprets a variable pattern `x` as a binding _only_ if there is no variant named `x` in scope.
2217+
A convention you can use to avoid conflicts is simply to name variants with upper-case letters,
2218+
and local variables with lower-case letters.
2219+
22152220
Multiple match patterns may be joined with the `|` operator. A
22162221
range of values may be specified with `..`. For example:
22172222

branches/snap-stage3/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/snap-stage3/src/libcore/extfmt.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
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 implemented.
15+
//! * Flag 0 causes leading zeros to be used for padding when converting numbers.
16+
//! * Flag # causes the conversion to be done in an *alternative* manner. Currently not implemented.
17+
//! * Flag + causes signed numbers to always be prepended with a sign character.
18+
//! * Flag - left justifies the result
19+
//! * Width specifies the minimum field width of the result. By default leading spaces are added.
20+
//! * Precision specifies the minimum number of digits for integral types and the minimum number
21+
//! of decimal places for float.
22+
//!
23+
//! The types currently supported are:
24+
//!
25+
//! * b - bool
26+
//! * c - char
27+
//! * d - int
28+
//! * f - float
29+
//! * i - int (same as d)
30+
//! * o - uint as octal
31+
//! * t - uint as binary
32+
//! * u - uint
33+
//! * x - uint as lower-case hexadecimal
34+
//! * X - uint as upper-case hexadecimal
35+
//! * s - str (any flavor)
36+
//! * ? - arbitrary type (does not use the to_str trait)
37+
238
// NB: transitionary, de-mode-ing.
339
#[forbid(deprecated_mode)];
440
#[forbid(deprecated_pattern)];
@@ -44,6 +80,7 @@ use option::{Some, None};
4480
*/
4581

4682
// Functions used by the fmt extension at compile time
83+
#[doc(hidden)]
4784
pub mod ct {
4885
pub enum Signedness { Signed, Unsigned, }
4986
pub enum Caseness { CaseUpper, CaseLower, }
@@ -277,6 +314,7 @@ pub mod ct {
277314
// decisions made a runtime. If it proves worthwhile then some of these
278315
// conditions can be evaluated at compile-time. For now though it's cleaner to
279316
// implement it 0this way, I think.
317+
#[doc(hidden)]
280318
pub mod rt {
281319
pub const flag_none : u32 = 0u32;
282320
pub const flag_left_justify : u32 = 0b00000000000001u32;
@@ -464,6 +502,7 @@ pub mod rt {
464502
}
465503
}
466504

505+
// Bulk of the tests are in src/test/run-pass/syntax-extension-fmt.rs
467506
#[cfg(test)]
468507
mod test {
469508
#[test]

branches/snap-stage3/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/snap-stage3/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/snap-stage3/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/snap-stage3/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/snap-stage3/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/snap-stage3/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.

branches/snap-stage3/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],

branches/snap-stage3/src/librustc/driver/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ fn pretty_print_input(sess: Session, cfg: ast::crate_cfg, input: input,
366366
ppm_expanded | ppm_normal => pprust::no_ann()
367367
};
368368
let is_expanded = upto != cu_parse;
369-
let src = sess.codemap.get_filemap(source_name(input)).src;
369+
let src = codemap::get_filemap(sess.codemap, source_name(input)).src;
370370
do io::with_str_reader(*src) |rdr| {
371371
pprust::print_crate(sess.codemap, sess.parse_sess.interner,
372372
sess.span_diagnostic, crate,
@@ -586,7 +586,7 @@ fn build_session_options(binary: ~str,
586586

587587
fn build_session(sopts: @session::options,
588588
demitter: diagnostic::emitter) -> Session {
589-
let codemap = @codemap::CodeMap::new();
589+
let codemap = codemap::new_codemap();
590590
let diagnostic_handler =
591591
diagnostic::mk_handler(Some(demitter));
592592
let span_diagnostic_handler =
@@ -595,7 +595,7 @@ fn build_session(sopts: @session::options,
595595
}
596596

597597
fn build_session_(sopts: @session::options,
598-
cm: @codemap::CodeMap,
598+
cm: codemap::CodeMap,
599599
demitter: diagnostic::emitter,
600600
span_diagnostic_handler: diagnostic::span_handler)
601601
-> Session {

branches/snap-stage3/src/librustc/driver/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ type Session_ = {targ_cfg: @config,
131131
opts: @options,
132132
cstore: metadata::cstore::CStore,
133133
parse_sess: parse_sess,
134-
codemap: @codemap::CodeMap,
134+
codemap: codemap::CodeMap,
135135
// For a library crate, this is always none
136136
mut main_fn: Option<(node_id, codemap::span)>,
137137
span_diagnostic: diagnostic::span_handler,

branches/snap-stage3/src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Serializer,
557557
let add_to_index = |copy ebml_w| add_to_index_(item, ebml_w, index);
558558

559559
debug!("encoding info for item at %s",
560-
ecx.tcx.sess.codemap.span_to_str(item.span));
560+
syntax::codemap::span_to_str(item.span, ecx.tcx.sess.codemap));
561561

562562
match item.node {
563563
item_const(_, _) => {

0 commit comments

Comments
 (0)