Skip to content

Commit 4873a79

Browse files
committed
---
yaml --- r: 210870 b: refs/heads/try c: 724b6ed h: refs/heads/master v: v3
1 parent 81eb647 commit 4873a79

23 files changed

+205
-163
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: 8fdb3a4ad902162f3f6809e007a79342c2ce19db
5+
refs/heads/try: 724b6ed751a0070d5c0904895e25578ca97f3fc7
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# The Rust Programming Language
22

3-
Rust is a systems programming language that is fast, memory safe and
4-
multithreaded, but does not employ a garbage collector or otherwise
5-
impose significant runtime overhead.
6-
7-
This repo contains the code for `rustc`, the Rust compiler, as well
8-
as standard libraries, tools and documentation for Rust.
3+
This is a compiler for Rust, including standard libraries, tools and
4+
documentation. Rust is a systems programming language that is fast,
5+
memory safe and multithreaded, but does not employ a garbage collector
6+
or otherwise impose significant runtime overhead.
97

108
## Quick Start
119

branches/try/mk/main.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
######################################################################
1414

1515
# The version number
16-
CFG_RELEASE_NUM=1.2.0
16+
CFG_RELEASE_NUM=1.1.0
1717

1818
# An optional number to put after the label, e.g. '.2' -> '-beta.2'
1919
# NB Make sure it starts with a dot to conform to semver pre-release

branches/try/src/doc/complement-design-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ feature.
7979
A nice replacement is the [lazy constructor macro][lcm] by [Marvin
8080
Löbel][kim].
8181

82-
[fqa]: http://yosefk.com/c++fqa/ctors.html#fqa-10.12
82+
[fqa]: https://mail.mozilla.org/pipermail/rust-dev/2013-April/003815.html
8383
[elp]: http://ericlippert.com/2013/02/06/static-constructors-part-one/
8484
[lcm]: https://gist.github.com/Kimundi/8782487
8585
[kim]: https://github.com/Kimundi

branches/try/src/doc/trpl/const-and-static.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ static N: i32 = 5;
3131

3232
Unlike [`let`][let] bindings, you must annotate the type of a `static`.
3333

34+
[let]: variable-bindings.html
35+
3436
Statics live for the entire lifetime of a program, and therefore any
35-
reference stored in a constant has a [`'static` lifetime][lifetimes]:
37+
reference stored in a constant has a [`static` lifetime][lifetimes]:
3638

3739
```rust
3840
static NAME: &'static str = "Steve";

branches/try/src/doc/trpl/dining-philosophers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ let handles: Vec<_> = philosophers.into_iter().map(|p| {
396396
}).collect();
397397
```
398398

399-
While this is only five lines, they’re a dense five. Let’s break it down.
399+
While this is only five lines, they’re a dense four. Let’s break it down.
400400

401401
```rust,ignore
402402
let handles: Vec<_> =

branches/try/src/doc/trpl/guessing-game.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Check out the generated `Cargo.toml`:
2727
[package]
2828

2929
name = "guessing_game"
30-
version = "0.1.0"
30+
version = "0.0.1"
3131
authors = ["Your Name <[email protected]>"]
3232
```
3333

@@ -46,7 +46,7 @@ Let’s try compiling what Cargo gave us:
4646

4747
```{bash}
4848
$ cargo build
49-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
49+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
5050
```
5151

5252
Excellent! Open up your `src/main.rs` again. We’ll be writing all of
@@ -58,7 +58,7 @@ Try it out:
5858

5959
```bash
6060
$ cargo run
61-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
61+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
6262
Running `target/debug/guessing_game`
6363
Hello, world!
6464
```
@@ -727,7 +727,7 @@ Let’s try our program out!
727727
728728
```bash
729729
$ cargo run
730-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
730+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
731731
Running `target/guessing_game`
732732
Guess the number!
733733
The secret number is: 58
@@ -792,7 +792,7 @@ and quit. Observe:
792792
793793
```bash
794794
$ cargo run
795-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
795+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
796796
Running `target/guessing_game`
797797
Guess the number!
798798
The secret number is: 59
@@ -929,7 +929,7 @@ Now we should be good! Let’s try:
929929
930930
```bash
931931
$ cargo run
932-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
932+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
933933
Running `target/guessing_game`
934934
Guess the number!
935935
The secret number is: 61

branches/try/src/doc/trpl/method-syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn main() {
156156

157157
This ‘associated function’ builds a new `Circle` for us. Note that associated
158158
functions are called with the `Struct::function()` syntax, rather than the
159-
`ref.method()` syntax. Some other languages call associated functions ‘static
159+
`ref.method()` syntax. Some other langauges call associated functions ‘static
160160
methods’.
161161

162162
# Builder Pattern

branches/try/src/doc/trpl/nightly-rust.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ $ sh rustup.sh --channel=nightly
2626
If you're on Windows, please download either the [32-bit installer][win32] or
2727
the [64-bit installer][win64] and run it.
2828

29-
[win32]: https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.msi
30-
[win64]: https://static.rust-lang.org/dist/rust-nightly-x86_64-pc-windows-gnu.msi
29+
[win32]: https://static.rust-lang.org/dist/rust-1.0.0-beta-i686-pc-windows-gnu.msi
30+
[win64]: https://static.rust-lang.org/dist/rust-1.0.0-beta-x86_64-pc-windows-gnu.msi
3131

3232
## Uninstalling
3333

branches/try/src/doc/trpl/traits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ let result = f.write("whatever".as_bytes());
208208

209209
This will compile without error.
210210

211-
This means that even if someone does something bad like add methods to `i32`,
211+
This means that even if someone does something bad like add methods to `int`,
212212
it won’t affect you, unless you `use` that trait.
213213

214214
There’s one more restriction on implementing traits. Either the trait or the

branches/try/src/libstd/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
//! [`FromStr`](str/trait.FromStr.html) trait.
6161
//!
6262
//! Data may be shared by placing it in a reference-counted box or the
63-
//! [`Rc`](rc/index.html) type, and if further contained in a [`Cell`
63+
//! [`Rc`][rc/index.html] type, and if further contained in a [`Cell`
6464
//! or `RefCell`](cell/index.html), may be mutated as well as shared.
6565
//! Likewise, in a concurrent setting it is common to pair an
6666
//! atomically-reference-counted box, [`Arc`](sync/struct.Arc.html),

branches/try/src/libsyntax/ext/quote.rs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ pub mod rt {
2828
use ast;
2929
use codemap::Spanned;
3030
use ext::base::ExtCtxt;
31-
use parse::{self, token, classify};
31+
use parse::token;
32+
use parse;
3233
use ptr::P;
3334
use std::rc::Rc;
3435

@@ -93,18 +94,6 @@ pub mod rt {
9394
}
9495
}
9596

96-
impl ToTokens for ast::Generics {
97-
fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
98-
vec![ast::TtToken(DUMMY_SP, token::Interpolated(token::NtGenerics(self.clone())))]
99-
}
100-
}
101-
102-
impl ToTokens for ast::WhereClause {
103-
fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
104-
vec![ast::TtToken(DUMMY_SP, token::Interpolated(token::NtWhereClause(self.clone())))]
105-
}
106-
}
107-
10897
impl ToTokens for P<ast::Item> {
10998
fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
11099
vec![ast::TtToken(self.span, token::Interpolated(token::NtItem(self.clone())))]
@@ -125,16 +114,7 @@ pub mod rt {
125114

126115
impl ToTokens for P<ast::Stmt> {
127116
fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
128-
let mut tts = vec![
129-
ast::TtToken(self.span, token::Interpolated(token::NtStmt(self.clone())))
130-
];
131-
132-
// Some statements require a trailing semicolon.
133-
if classify::stmt_ends_with_semi(&self.node) {
134-
tts.push(ast::TtToken(self.span, token::Semi));
135-
}
136-
137-
tts
117+
vec![ast::TtToken(self.span, token::Interpolated(token::NtStmt(self.clone())))]
138118
}
139119
}
140120

branches/try/src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 78 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -325,42 +325,55 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
325325
last = match *token {
326326
TtToken(sp, MatchNt(ref name, ref frag_spec, _, _)) => {
327327
// ii. If T is a simple NT, look ahead to the next token T' in
328-
// M.
329-
let next_token = match tokens.peek() {
330-
// If T' closes a complex NT, replace T' with F
331-
Some(&&TtToken(_, CloseDelim(_))) => follow.clone(),
332-
Some(&&TtToken(_, ref tok)) => tok.clone(),
333-
Some(&&TtSequence(sp, _)) => {
334-
cx.span_err(sp,
335-
&format!("`${0}:{1}` is followed by a \
336-
sequence repetition, which is not \
337-
allowed for `{1}` fragments",
338-
name.as_str(), frag_spec.as_str())
328+
// M. If T' is in the set FOLLOW(NT), continue. Else; reject.
329+
if can_be_followed_by_any(frag_spec.as_str()) {
330+
continue
331+
} else {
332+
let next_token = match tokens.peek() {
333+
// If T' closes a complex NT, replace T' with F
334+
Some(&&TtToken(_, CloseDelim(_))) => follow.clone(),
335+
Some(&&TtToken(_, ref tok)) => tok.clone(),
336+
Some(&&TtSequence(sp, _)) => {
337+
// Be conservative around sequences: to be
338+
// more specific, we would need to
339+
// consider FIRST sets, but also the
340+
// possibility that the sequence occurred
341+
// zero times (in which case we need to
342+
// look at the token that follows the
343+
// sequence, which may itself a sequence,
344+
// and so on).
345+
cx.span_err(sp,
346+
&format!("`${0}:{1}` is followed by a \
347+
sequence repetition, which is not \
348+
allowed for `{1}` fragments",
349+
name.as_str(), frag_spec.as_str())
339350
);
340-
Eof
341-
},
342-
// die next iteration
343-
Some(&&TtDelimited(_, ref delim)) => delim.close_token(),
344-
// else, we're at the end of the macro or sequence
345-
None => follow.clone()
346-
};
347-
348-
let tok = if let TtToken(_, ref tok) = *token { tok } else { unreachable!() };
349-
// If T' is in the set FOLLOW(NT), continue. Else, reject.
350-
match (&next_token, is_in_follow(cx, &next_token, frag_spec.as_str())) {
351-
(_, Err(msg)) => {
352-
cx.span_err(sp, &msg);
353-
continue
351+
Eof
352+
},
353+
// die next iteration
354+
Some(&&TtDelimited(_, ref delim)) => delim.close_token(),
355+
// else, we're at the end of the macro or sequence
356+
None => follow.clone()
357+
};
358+
359+
let tok = if let TtToken(_, ref tok) = *token { tok } else { unreachable!() };
360+
361+
// If T' is in the set FOLLOW(NT), continue. Else, reject.
362+
match (&next_token, is_in_follow(cx, &next_token, frag_spec.as_str())) {
363+
(_, Err(msg)) => {
364+
cx.span_err(sp, &msg);
365+
continue
366+
}
367+
(&Eof, _) => return Some((sp, tok.clone())),
368+
(_, Ok(true)) => continue,
369+
(next, Ok(false)) => {
370+
cx.span_err(sp, &format!("`${0}:{1}` is followed by `{2}`, which \
371+
is not allowed for `{1}` fragments",
372+
name.as_str(), frag_spec.as_str(),
373+
token_to_string(next)));
374+
continue
375+
},
354376
}
355-
(&Eof, _) => return Some((sp, tok.clone())),
356-
(_, Ok(true)) => continue,
357-
(next, Ok(false)) => {
358-
cx.span_err(sp, &format!("`${0}:{1}` is followed by `{2}`, which \
359-
is not allowed for `{1}` fragments",
360-
name.as_str(), frag_spec.as_str(),
361-
token_to_string(next)));
362-
continue
363-
},
364377
}
365378
},
366379
TtSequence(sp, ref seq) => {
@@ -427,8 +440,39 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
427440
last
428441
}
429442

443+
/// True if a fragment of type `frag` can be followed by any sort of
444+
/// token. We use this (among other things) as a useful approximation
445+
/// for when `frag` can be followed by a repetition like `$(...)*` or
446+
/// `$(...)+`. In general, these can be a bit tricky to reason about,
447+
/// so we adopt a conservative position that says that any fragment
448+
/// specifier which consumes at most one token tree can be followed by
449+
/// a fragment specifier (indeed, these fragments can be followed by
450+
/// ANYTHING without fear of future compatibility hazards).
451+
fn can_be_followed_by_any(frag: &str) -> bool {
452+
match frag {
453+
"item" | // always terminated by `}` or `;`
454+
"block" | // exactly one token tree
455+
"ident" | // exactly one token tree
456+
"meta" | // exactly one token tree
457+
"tt" => // exactly one token tree
458+
true,
459+
460+
_ =>
461+
false,
462+
}
463+
}
464+
465+
/// True if `frag` can legally be followed by the token `tok`. For
466+
/// fragments that can consume an unbounded numbe of tokens, `tok`
467+
/// must be within a well-defined follow set. This is intended to
468+
/// guarantee future compatibility: for example, without this rule, if
469+
/// we expanded `expr` to include a new binary operator, we might
470+
/// break macros that were relying on that binary operator as a
471+
/// separator.
430472
fn is_in_follow(_: &ExtCtxt, tok: &Token, frag: &str) -> Result<bool, String> {
431473
if let &CloseDelim(_) = tok {
474+
// closing a token tree can never be matched by any fragment;
475+
// iow, we always require that `(` and `)` match, etc.
432476
Ok(true)
433477
} else {
434478
match frag {

branches/try/src/libsyntax/fold.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,6 @@ pub fn noop_fold_interpolated<T: Folder>(nt: token::Nonterminal, fld: &mut T)
689689
token::NtTraitItem(arm) =>
690690
token::NtTraitItem(fld.fold_trait_item(arm)
691691
.expect_one("expected fold to produce exactly one item")),
692-
token::NtGenerics(generics) => token::NtGenerics(fld.fold_generics(generics)),
693-
token::NtWhereClause(where_clause) =>
694-
token::NtWhereClause(fld.fold_where_clause(where_clause)),
695692
}
696693
}
697694

0 commit comments

Comments
 (0)