Skip to content

Commit eacff05

Browse files
committed
---
yaml --- r: 210872 b: refs/heads/try c: 63b000b h: refs/heads/master v: v3
1 parent 3ac1ffa commit eacff05

21 files changed

+151
-72
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: 7a5d74828bf6350c72f0330d7799e0cccd2e968f
5+
refs/heads/try: 63b000b1b81ecc197112a60d9b79901cffa4e0bb
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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# The Rust Programming Language
22

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.
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.
79

810
## Quick Start
911

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.1.0
16+
CFG_RELEASE_NUM=1.2.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]: https://mail.mozilla.org/pipermail/rust-dev/2013-April/003815.html
82+
[fqa]: http://yosefk.com/c++fqa/ctors.html#fqa-10.12
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: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ 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-
3634
Statics live for the entire lifetime of a program, and therefore any
37-
reference stored in a constant has a [`static` lifetime][lifetimes]:
35+
reference stored in a constant has a [`'static` lifetime][lifetimes]:
3836

3937
```rust
4038
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 four. Let’s break it down.
399+
While this is only five lines, they’re a dense five. 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.0.1"
30+
version = "0.1.0"
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.0.1 (file:///home/you/projects/guessing_game)
49+
Compiling guessing_game v0.1.0 (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.0.1 (file:///home/you/projects/guessing_game)
61+
Compiling guessing_game v0.1.0 (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.0.1 (file:///home/you/projects/guessing_game)
730+
Compiling guessing_game v0.1.0 (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.0.1 (file:///home/you/projects/guessing_game)
795+
Compiling guessing_game v0.1.0 (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.0.1 (file:///home/you/projects/guessing_game)
932+
Compiling guessing_game v0.1.0 (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 langauges call associated functions ‘static
159+
`ref.method()` syntax. Some other languages 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-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
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
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 `int`,
211+
This means that even if someone does something bad like add methods to `i32`,
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: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ pub mod rt {
2828
use ast;
2929
use codemap::Spanned;
3030
use ext::base::ExtCtxt;
31-
use parse::token;
32-
use parse;
31+
use parse::{self, token, classify};
3332
use ptr::P;
3433
use std::rc::Rc;
3534

@@ -94,6 +93,18 @@ pub mod rt {
9493
}
9594
}
9695

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+
97108
impl ToTokens for P<ast::Item> {
98109
fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
99110
vec![ast::TtToken(self.span, token::Interpolated(token::NtItem(self.clone())))]
@@ -114,7 +125,16 @@ pub mod rt {
114125

115126
impl ToTokens for P<ast::Stmt> {
116127
fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
117-
vec![ast::TtToken(self.span, token::Interpolated(token::NtStmt(self.clone())))]
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
118138
}
119139
}
120140

branches/try/src/libsyntax/fold.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,9 @@ 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)),
692695
}
693696
}
694697

branches/try/src/libsyntax/parse/lexer/mod.rs

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -403,45 +403,51 @@ impl<'a> StringReader<'a> {
403403
Some('/') => {
404404
self.bump();
405405
self.bump();
406+
406407
// line comments starting with "///" or "//!" are doc-comments
407-
if self.curr_is('/') || self.curr_is('!') {
408-
let start_bpos = self.pos - BytePos(3);
409-
while !self.is_eof() {
410-
match self.curr.unwrap() {
411-
'\n' => break,
412-
'\r' => {
413-
if self.nextch_is('\n') {
414-
// CRLF
415-
break
416-
} else {
417-
self.err_span_(self.last_pos, self.pos,
418-
"bare CR not allowed in doc-comment");
419-
}
408+
let doc_comment = self.curr_is('/') || self.curr_is('!');
409+
let start_bpos = if doc_comment {
410+
self.pos - BytePos(3)
411+
} else {
412+
self.last_pos - BytePos(2)
413+
};
414+
415+
while !self.is_eof() {
416+
match self.curr.unwrap() {
417+
'\n' => break,
418+
'\r' => {
419+
if self.nextch_is('\n') {
420+
// CRLF
421+
break
422+
} else if doc_comment {
423+
self.err_span_(self.last_pos, self.pos,
424+
"bare CR not allowed in doc-comment");
420425
}
421-
_ => ()
422426
}
423-
self.bump();
427+
_ => ()
424428
}
425-
return self.with_str_from(start_bpos, |string| {
426-
// but comments with only more "/"s are not
429+
self.bump();
430+
}
431+
432+
return if doc_comment {
433+
self.with_str_from(start_bpos, |string| {
434+
// comments with only more "/"s are not doc comments
427435
let tok = if is_doc_comment(string) {
428436
token::DocComment(token::intern(string))
429437
} else {
430438
token::Comment
431439
};
432440

433-
return Some(TokenAndSpan{
441+
Some(TokenAndSpan {
434442
tok: tok,
435443
sp: codemap::mk_sp(start_bpos, self.last_pos)
436-
});
437-
});
444+
})
445+
})
438446
} else {
439-
let start_bpos = self.last_pos - BytePos(2);
440-
while !self.curr_is('\n') && !self.is_eof() { self.bump(); }
441-
return Some(TokenAndSpan {
447+
Some(TokenAndSpan {
442448
tok: token::Comment,
443449
sp: codemap::mk_sp(start_bpos, self.last_pos)
444-
});
450+
})
445451
}
446452
}
447453
Some('*') => {
@@ -1563,4 +1569,13 @@ mod tests {
15631569
assert_eq!(lexer.next_token().tok, token::Literal(token::Char(token::intern("a")), None));
15641570
}
15651571

1572+
#[test] fn crlf_comments() {
1573+
let sh = mk_sh();
1574+
let mut lexer = setup(&sh, "// test\r\n/// test\r\n".to_string());
1575+
let comment = lexer.next_token();
1576+
assert_eq!(comment.tok, token::Comment);
1577+
assert_eq!(comment.sp, ::codemap::mk_sp(BytePos(0), BytePos(7)));
1578+
assert_eq!(lexer.next_token().tok, token::Whitespace);
1579+
assert_eq!(lexer.next_token().tok, token::DocComment(token::intern("/// test")));
1580+
}
15661581
}

branches/try/src/libsyntax/parse/parser.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,8 @@ impl<'a> Parser<'a> {
20262026
return self.parse_block_expr(lo, DefaultBlock);
20272027
},
20282028
token::BinOp(token::Or) | token::OrOr => {
2029-
return self.parse_lambda_expr(CaptureByRef);
2029+
let lo = self.span.lo;
2030+
return self.parse_lambda_expr(lo, CaptureByRef);
20302031
},
20312032
token::Ident(id @ ast::Ident {
20322033
name: token::SELF_KEYWORD_NAME,
@@ -2081,7 +2082,8 @@ impl<'a> Parser<'a> {
20812082
return Ok(self.mk_expr(lo, hi, ExprPath(Some(qself), path)));
20822083
}
20832084
if try!(self.eat_keyword(keywords::Move) ){
2084-
return self.parse_lambda_expr(CaptureByValue);
2085+
let lo = self.last_span.lo;
2086+
return self.parse_lambda_expr(lo, CaptureByValue);
20852087
}
20862088
if try!(self.eat_keyword(keywords::If)) {
20872089
return self.parse_if_expr();
@@ -2840,10 +2842,9 @@ impl<'a> Parser<'a> {
28402842
}
28412843

28422844
// `|args| expr`
2843-
pub fn parse_lambda_expr(&mut self, capture_clause: CaptureClause)
2845+
pub fn parse_lambda_expr(&mut self, lo: BytePos, capture_clause: CaptureClause)
28442846
-> PResult<P<Expr>>
28452847
{
2846-
let lo = self.span.lo;
28472848
let decl = try!(self.parse_fn_block_decl());
28482849
let body = match decl.output {
28492850
DefaultReturn(_) => {
@@ -3808,6 +3809,8 @@ impl<'a> Parser<'a> {
38083809
/// | ( < lifetimes , typaramseq ( , )? > )
38093810
/// where typaramseq = ( typaram ) | ( typaram , typaramseq )
38103811
pub fn parse_generics(&mut self) -> PResult<ast::Generics> {
3812+
maybe_whole!(self, NtGenerics);
3813+
38113814
if try!(self.eat(&token::Lt) ){
38123815
let lifetime_defs = try!(self.parse_lifetime_defs());
38133816
let mut seen_default = false;
@@ -3928,6 +3931,8 @@ impl<'a> Parser<'a> {
39283931
/// where T : Trait<U, V> + 'b, 'a : 'b
39293932
/// ```
39303933
pub fn parse_where_clause(&mut self) -> PResult<ast::WhereClause> {
3934+
maybe_whole!(self, NtWhereClause);
3935+
39313936
let mut where_clause = WhereClause {
39323937
id: ast::DUMMY_NODE_ID,
39333938
predicates: Vec::new(),
@@ -5262,11 +5267,7 @@ impl<'a> Parser<'a> {
52625267
return Ok(Some(try!(self.parse_item_foreign_mod(lo, opt_abi, visibility, attrs))));
52635268
}
52645269

5265-
let span = self.span;
5266-
let token_str = self.this_token_to_string();
5267-
return Err(self.span_fatal(span,
5268-
&format!("expected `{}` or `fn`, found `{}`", "{",
5269-
token_str)))
5270+
try!(self.expect_one_of(&[], &[]));
52705271
}
52715272

52725273
if try!(self.eat_keyword_noexpect(keywords::Virtual) ){

branches/try/src/libsyntax/parse/token.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ pub enum Nonterminal {
385385
NtArm(ast::Arm),
386386
NtImplItem(P<ast::ImplItem>),
387387
NtTraitItem(P<ast::TraitItem>),
388+
NtGenerics(ast::Generics),
389+
NtWhereClause(ast::WhereClause),
388390
}
389391

390392
impl fmt::Debug for Nonterminal {
@@ -403,6 +405,8 @@ impl fmt::Debug for Nonterminal {
403405
NtArm(..) => f.pad("NtArm(..)"),
404406
NtImplItem(..) => f.pad("NtImplItem(..)"),
405407
NtTraitItem(..) => f.pad("NtTraitItem(..)"),
408+
NtGenerics(..) => f.pad("NtGenerics(..)"),
409+
NtWhereClause(..) => f.pad("NtWhereClause(..)"),
406410
}
407411
}
408412
}

0 commit comments

Comments
 (0)