Skip to content

Commit e38b913

Browse files
committed
---
yaml --- r: 210876 b: refs/heads/try c: 6403a2f h: refs/heads/master v: v3
1 parent e171ca0 commit e38b913

26 files changed

+371
-99
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: 0e21beb761e98d30a09c48e110eb0bb3d18fc5ea
5+
refs/heads/try: 6403a2fc3271b5c510307f09d98af8e6c8e15481
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/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/liballoc/rc.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,18 @@ impl<T: Default> Default for Rc<T> {
634634
}
635635

636636
#[stable(feature = "rust1", since = "1.0.0")]
637+
#[cfg(stage0)]
637638
impl<T: PartialEq> PartialEq for Rc<T> {
639+
#[inline(always)]
640+
fn eq(&self, other: &Rc<T>) -> bool { **self == **other }
641+
642+
#[inline(always)]
643+
fn ne(&self, other: &Rc<T>) -> bool { **self != **other }
644+
}
645+
646+
#[stable(feature = "rust1", since = "1.0.0")]
647+
#[cfg(not(stage0))]
648+
impl<T: ?Sized + PartialEq> PartialEq for Rc<T> {
638649
/// Equality for two `Rc<T>`s.
639650
///
640651
/// Two `Rc<T>`s are equal if their inner value are equal.
@@ -669,10 +680,35 @@ impl<T: PartialEq> PartialEq for Rc<T> {
669680
}
670681

671682
#[stable(feature = "rust1", since = "1.0.0")]
683+
#[cfg(stage0)]
672684
impl<T: Eq> Eq for Rc<T> {}
685+
#[stable(feature = "rust1", since = "1.0.0")]
686+
#[cfg(not(stage0))]
687+
impl<T: ?Sized + Eq> Eq for Rc<T> {}
673688

674689
#[stable(feature = "rust1", since = "1.0.0")]
690+
#[cfg(stage0)]
675691
impl<T: PartialOrd> PartialOrd for Rc<T> {
692+
#[inline(always)]
693+
fn partial_cmp(&self, other: &Rc<T>) -> Option<Ordering> {
694+
(**self).partial_cmp(&**other)
695+
}
696+
697+
#[inline(always)]
698+
fn lt(&self, other: &Rc<T>) -> bool { **self < **other }
699+
700+
#[inline(always)]
701+
fn le(&self, other: &Rc<T>) -> bool { **self <= **other }
702+
703+
#[inline(always)]
704+
fn gt(&self, other: &Rc<T>) -> bool { **self > **other }
705+
706+
#[inline(always)]
707+
fn ge(&self, other: &Rc<T>) -> bool { **self >= **other }
708+
}
709+
#[stable(feature = "rust1", since = "1.0.0")]
710+
#[cfg(not(stage0))]
711+
impl<T: ?Sized + PartialOrd> PartialOrd for Rc<T> {
676712
/// Partial comparison for two `Rc<T>`s.
677713
///
678714
/// The two are compared by calling `partial_cmp()` on their inner values.
@@ -757,7 +793,14 @@ impl<T: PartialOrd> PartialOrd for Rc<T> {
757793
}
758794

759795
#[stable(feature = "rust1", since = "1.0.0")]
796+
#[cfg(stage0)]
760797
impl<T: Ord> Ord for Rc<T> {
798+
#[inline]
799+
fn cmp(&self, other: &Rc<T>) -> Ordering { (**self).cmp(&**other) }
800+
}
801+
#[stable(feature = "rust1", since = "1.0.0")]
802+
#[cfg(not(stage0))]
803+
impl<T: ?Sized + Ord> Ord for Rc<T> {
761804
/// Comparison for two `Rc<T>`s.
762805
///
763806
/// The two are compared by calling `cmp()` on their inner values.
@@ -1399,4 +1442,9 @@ mod tests {
13991442
assert_eq!(format!("{:?}", foo), "75");
14001443
}
14011444

1445+
#[test]
1446+
fn test_unsized() {
1447+
let foo: Rc<[i32]> = Rc::new([1, 2, 3]);
1448+
assert_eq!(foo, foo.clone());
1449+
}
14021450
}

branches/try/src/libcollections/borrow.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,16 @@ impl<'a, T: ?Sized> BorrowMut<T> for &'a mut T {
116116
fn borrow_mut(&mut self) -> &mut T { &mut **self }
117117
}
118118

119+
#[cfg(stage0)]
119120
impl<T> Borrow<T> for rc::Rc<T> {
120121
fn borrow(&self) -> &T { &**self }
121122
}
122123

124+
#[cfg(not(stage0))]
125+
impl<T: ?Sized> Borrow<T> for rc::Rc<T> {
126+
fn borrow(&self) -> &T { &**self }
127+
}
128+
123129
impl<T> Borrow<T> for arc::Arc<T> {
124130
fn borrow(&self) -> &T { &**self }
125131
}

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/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: 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

0 commit comments

Comments
 (0)