Skip to content

Commit c73c8f8

Browse files
committed
---
yaml --- r: 206295 b: refs/heads/beta c: 4aab003 h: refs/heads/master i: 206293: 1010a04 206291: 037f8e8 206287: 935293b v: v3
1 parent 7de6f5c commit c73c8f8

Some content is hidden

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

59 files changed

+808
-412
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3030
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3131
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
32-
refs/heads/beta: 585c7e2a0acc0fb99790764364ba9aa5c7ad41c2
32+
refs/heads/beta: 4aab003b60943885e340567a6d9cb4bc652614b8
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3535
refs/heads/tmp: 579e31929feff51dcaf8d444648eff8de735f91a

branches/beta/src/doc/grammar.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,15 @@ excluded from the `ident` rule.
176176

177177
```antlr
178178
lit_suffix : ident;
179-
literal : [ string_lit | char_lit | byte_string_lit | byte_lit | num_lit ] lit_suffix ?;
179+
literal : [ string_lit | char_lit | byte_string_lit | byte_lit | num_lit | bool_lit ] lit_suffix ?;
180180
```
181181

182+
The optional `lit_suffix` production is only used for certain numeric literals,
183+
but is reserved for future extension. That is, the above gives the lexical
184+
grammar, but a Rust parser will reject everything but the 12 special cases
185+
mentioned in [Number literals](reference.html#number-literals) in the
186+
reference.
187+
182188
#### Character and string literals
183189

184190
```antlr
@@ -238,7 +244,9 @@ dec_lit : [ dec_digit | '_' ] + ;
238244

239245
#### Boolean literals
240246

241-
**FIXME:** write grammar
247+
```antlr
248+
bool_lit : [ "true" | "false" ] ;
249+
```
242250

243251
The two values of the boolean type are written `true` and `false`.
244252

@@ -297,7 +305,7 @@ transcriber : '(' transcriber * ')' | '[' transcriber * ']'
297305

298306
```antlr
299307
item : mod_item | fn_item | type_item | struct_item | enum_item
300-
| static_item | trait_item | impl_item | extern_block ;
308+
| const_item | static_item | trait_item | impl_item | extern_block ;
301309
```
302310

303311
### Type Parameters
@@ -369,6 +377,10 @@ path_item : ident | "mod" ;
369377

370378
**FIXME:** grammar?
371379

380+
### Enumerations
381+
382+
**FIXME:** grammar?
383+
372384
### Constant items
373385

374386
```antlr

branches/beta/src/doc/reference.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ of tokens, that immediately and directly denotes the value it evaluates to,
130130
rather than referring to it by name or some other evaluation rule. A literal is
131131
a form of constant expression, so is evaluated (primarily) at compile time.
132132

133-
The optional suffix is only used for certain numeric literals, but is
134-
reserved for future extension, that is, the above gives the lexical
135-
grammar, but a Rust parser will reject everything but the 12 special
136-
cases mentioned in [Number literals](#number-literals) below.
137-
138133
#### Examples
139134

140135
##### Characters and strings
@@ -1562,8 +1557,7 @@ warnings are generated, or otherwise "you used a private item of another module
15621557
and weren't allowed to."
15631558

15641559
By default, everything in Rust is *private*, with one exception. Enum variants
1565-
in a `pub` enum are also public by default. You are allowed to alter this
1566-
default visibility with the `priv` keyword. When an item is declared as `pub`,
1560+
in a `pub` enum are also public by default. When an item is declared as `pub`,
15671561
it can be thought of as being accessible to the outside world. For example:
15681562

15691563
```
@@ -2431,11 +2425,18 @@ Tuples are written by enclosing zero or more comma-separated expressions in
24312425
parentheses. They are used to create [tuple-typed](#tuple-types) values.
24322426

24332427
```{.tuple}
2434-
(0,);
24352428
(0.0, 4.5);
24362429
("a", 4usize, true);
24372430
```
24382431

2432+
You can disambiguate a single-element tuple from a value in parentheses with a
2433+
comma:
2434+
2435+
```
2436+
(0,); // single-element tuple
2437+
(0); // zero in parentheses
2438+
```
2439+
24392440
### Unit expressions
24402441

24412442
The expression `()` denotes the _unit value_, the only value of the type with

branches/beta/src/doc/trpl/iterators.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -235,26 +235,15 @@ Ranges are one of two basic iterators that you'll see. The other is `iter()`.
235235
in turn:
236236

237237
```rust
238-
let nums = [1, 2, 3];
238+
let nums = vec![1, 2, 3];
239239

240240
for num in nums.iter() {
241241
println!("{}", num);
242242
}
243243
```
244244

245245
These two basic iterators should serve you well. There are some more
246-
advanced iterators, including ones that are infinite. Like using range syntax
247-
and `step_by`:
248-
249-
```rust
250-
# #![feature(step_by)]
251-
(1..).step_by(5);
252-
```
253-
254-
This iterator counts up from one, adding five each time. It will give
255-
you a new integer every time, forever (well, technically, until it reaches the
256-
maximum number representable by an `i32`). But since iterators are lazy,
257-
that's okay! You probably don't want to use `collect()` on it, though...
246+
advanced iterators, including ones that are infinite.
258247

259248
That's enough about iterators. Iterator adapters are the last concept
260249
we need to talk about with regards to iterators. Let's get to it!

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ If not, there are a number of places where you can get help. The easiest is
9393
[the #rust IRC channel on irc.mozilla.org][irc], which you can access through
9494
[Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans
9595
(a silly nickname we call ourselves), and we can help you out. Other great
96-
resources include [the user’s forum][users], and [Stack Overflow][stack
97-
overflow].
96+
resources include [the user’s forum][users], and [Stack Overflow][stack overflow].
9897

9998
[irc]: irc://irc.mozilla.org/#rust
10099
[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust

branches/beta/src/doc/trpl/primitive-types.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,14 @@ or “breaks up” the tuple, and assigns the bits to three bindings.
248248

249249
This pattern is very powerful, and we’ll see it repeated more later.
250250

251+
You can disambiguate a single-element tuple from a value in parentheses with a
252+
comma:
253+
254+
```
255+
(0,); // single-element tuple
256+
(0); // zero in parentheses
257+
```
258+
251259
## Tuple Indexing
252260

253261
You can also access fields of a tuple with indexing syntax:

branches/beta/src/doc/trpl/unsized-types.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ impl Foo for &str {
3838
```
3939

4040
Meaning, this implementation would only work for [references][ref], and not
41-
other types of pointers. With this `impl`, all pointers, including (at some
42-
point, there are some bugs to fix first) user-defined custom smart pointers,
43-
can use this `impl`.
41+
other types of pointers. With the `impl for str`, all pointers, including (at
42+
some point, there are some bugs to fix first) user-defined custom smart
43+
pointers, can use this `impl`.
44+
45+
[ref]: references-and-borrowing.html
4446

4547
# ?Sized
4648

branches/beta/src/liballoc/boxed.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ impl<T: ?Sized + Hash> Hash for Box<T> {
240240
impl Box<Any> {
241241
#[inline]
242242
#[stable(feature = "rust1", since = "1.0.0")]
243+
/// Attempt to downcast the box to a concrete type.
243244
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
244245
if self.is::<T>() {
245246
unsafe {
@@ -257,11 +258,15 @@ impl Box<Any> {
257258
}
258259
}
259260

260-
impl Box<Any+Send> {
261+
impl Box<Any + Send> {
261262
#[inline]
262263
#[stable(feature = "rust1", since = "1.0.0")]
263-
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
264-
<Box<Any>>::downcast(self)
264+
/// Attempt to downcast the box to a concrete type.
265+
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any + Send>> {
266+
<Box<Any>>::downcast(self).map_err(|s| unsafe {
267+
// reapply the Send marker
268+
mem::transmute::<Box<Any>, Box<Any + Send>>(s)
269+
})
265270
}
266271
}
267272

branches/beta/src/libcore/any.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ pub trait Any: Reflect + 'static {
9797
fn get_type_id(&self) -> TypeId;
9898
}
9999

100-
impl<T> Any for T
101-
where T: Reflect + 'static
102-
{
100+
impl<T: Reflect + 'static> Any for T {
103101
fn get_type_id(&self) -> TypeId { TypeId::of::<T>() }
104102
}
105103

@@ -222,7 +220,7 @@ impl TypeId {
222220
/// Returns the `TypeId` of the type this generic function has been
223221
/// instantiated with
224222
#[stable(feature = "rust1", since = "1.0.0")]
225-
pub fn of<T: ?Sized + Any>() -> TypeId {
223+
pub fn of<T: ?Sized + Reflect + 'static>() -> TypeId {
226224
TypeId {
227225
t: unsafe { intrinsics::type_id::<T>() },
228226
}

branches/beta/src/libcore/marker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ mod impls {
416416
#[rustc_reflect_like]
417417
#[unstable(feature = "core", reason = "requires RFC and more experience")]
418418
#[allow(deprecated)]
419+
#[rustc_on_unimplemented = "`{Self}` does not implement `Any`; \
420+
ensure all type parameters are bounded by `Any`"]
419421
pub trait Reflect {}
420422

421423
impl Reflect for .. { }

branches/beta/src/librustc/diagnostics.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,31 @@ This error indicates that an attempt was made to divide by zero (or take the
227227
remainder of a zero divisor) in a static or constant expression.
228228
"##,
229229

230+
E0079: r##"
231+
Enum variants which contain no data can be given a custom integer
232+
representation. This error indicates that the value provided is not an
233+
integer literal and is therefore invalid.
234+
"##,
235+
236+
E0080: r##"
237+
This error indicates that the compiler was unable to sensibly evaluate an
238+
integer expression provided as an enum discriminant. Attempting to divide by 0
239+
or causing integer overflow are two ways to induce this error. For example:
240+
241+
```
242+
enum Enum {
243+
X = (1 << 500),
244+
Y = (1 / 0)
245+
}
246+
```
247+
248+
Ensure that the expressions given can be evaluated as the desired integer type.
249+
See the FFI section of the Reference for more information about using a custom
250+
integer type:
251+
252+
http://doc.rust-lang.org/reference.html#ffi-attributes
253+
"##,
254+
230255
E0133: r##"
231256
Using unsafe functionality, such as dereferencing raw pointers and calling
232257
functions via FFI or marked as unsafe, is potentially dangerous and disallowed
@@ -507,8 +532,6 @@ register_diagnostics! {
507532
E0017,
508533
E0019,
509534
E0022,
510-
E0079, // enum variant: expected signed integer constant
511-
E0080, // enum variant: constant evaluation error
512535
E0109,
513536
E0110,
514537
E0134,

branches/beta/src/librustc/metadata/csearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
283283
// if there is one.
284284
pub fn get_impl_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
285285
def: ast::DefId)
286-
-> Option<Rc<ty::TraitRef<'tcx>>> {
286+
-> Option<ty::TraitRef<'tcx>> {
287287
let cstore = &tcx.sess.cstore;
288288
let cdata = cstore.get_crate_data(def.krate);
289289
decoder::get_impl_trait(&*cdata, def.node, tcx)

branches/beta/src/librustc/metadata/decoder.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ use middle::subst;
3030
use middle::ty::{ImplContainer, TraitContainer};
3131
use middle::ty::{self, Ty};
3232
use middle::astencode::vtable_decoder_helpers;
33+
use util::nodemap::FnvHashMap;
3334

35+
use std::cell::{Cell, RefCell};
3436
use std::collections::HashMap;
3537
use std::hash::{self, Hash, SipHasher};
3638
use std::io::prelude::*;
@@ -247,13 +249,13 @@ pub fn item_type<'tcx>(_item_id: ast::DefId, item: rbml::Doc,
247249
}
248250

249251
fn doc_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
250-
-> Rc<ty::TraitRef<'tcx>> {
252+
-> ty::TraitRef<'tcx> {
251253
parse_trait_ref_data(doc.data, cdata.cnum, doc.start, tcx,
252254
|_, did| translate_def_id(cdata, did))
253255
}
254256

255257
fn item_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
256-
-> Rc<ty::TraitRef<'tcx>> {
258+
-> ty::TraitRef<'tcx> {
257259
let tp = reader::get_doc(doc, tag_item_trait_ref);
258260
doc_trait_ref(tp, tcx, cdata)
259261
}
@@ -420,6 +422,9 @@ pub fn get_trait_def<'tcx>(cdata: Cmd,
420422
generics: generics,
421423
trait_ref: item_trait_ref(item_doc, tcx, cdata),
422424
associated_type_names: associated_type_names,
425+
nonblanket_impls: RefCell::new(FnvHashMap()),
426+
blanket_impls: RefCell::new(vec![]),
427+
flags: Cell::new(ty::TraitFlags::NO_TRAIT_FLAGS)
423428
}
424429
}
425430

@@ -490,7 +495,7 @@ pub fn get_impl_polarity<'tcx>(cdata: Cmd,
490495
pub fn get_impl_trait<'tcx>(cdata: Cmd,
491496
id: ast::NodeId,
492497
tcx: &ty::ctxt<'tcx>)
493-
-> Option<Rc<ty::TraitRef<'tcx>>>
498+
-> Option<ty::TraitRef<'tcx>>
494499
{
495500
let item_doc = lookup_item(id, cdata.data());
496501
let fam = item_family(item_doc);

branches/beta/src/librustc/metadata/encoder.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct entry<T> {
103103

104104
fn encode_trait_ref<'a, 'tcx>(rbml_w: &mut Encoder,
105105
ecx: &EncodeContext<'a, 'tcx>,
106-
trait_ref: &ty::TraitRef<'tcx>,
106+
trait_ref: ty::TraitRef<'tcx>,
107107
tag: usize) {
108108
let ty_str_ctxt = &tyencode::ctxt {
109109
diag: ecx.diag,
@@ -191,7 +191,7 @@ pub fn write_trait_ref<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
191191
tcx: ecx.tcx,
192192
abbrevs: &ecx.type_abbrevs
193193
};
194-
tyencode::enc_trait_ref(rbml_w, ty_str_ctxt, trait_ref);
194+
tyencode::enc_trait_ref(rbml_w, ty_str_ctxt, *trait_ref);
195195
}
196196

197197
pub fn write_region(ecx: &EncodeContext,
@@ -974,16 +974,14 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
974974
fn encode_extension_implementations(ecx: &EncodeContext,
975975
rbml_w: &mut Encoder,
976976
trait_def_id: DefId) {
977-
match ecx.tcx.trait_impls.borrow().get(&trait_def_id) {
978-
None => {}
979-
Some(implementations) => {
980-
for &impl_def_id in &*implementations.borrow() {
981-
rbml_w.start_tag(tag_items_data_item_extension_impl);
982-
encode_def_id(rbml_w, impl_def_id);
983-
rbml_w.end_tag();
984-
}
985-
}
986-
}
977+
assert!(ast_util::is_local(trait_def_id));
978+
let def = ty::lookup_trait_def(ecx.tcx, trait_def_id);
979+
980+
def.for_each_impl(ecx.tcx, |impl_def_id| {
981+
rbml_w.start_tag(tag_items_data_item_extension_impl);
982+
encode_def_id(rbml_w, impl_def_id);
983+
rbml_w.end_tag();
984+
});
987985
}
988986

989987
fn encode_stability(rbml_w: &mut Encoder, stab_opt: Option<attr::Stability>) {
@@ -1201,7 +1199,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
12011199
encode_unsafety(rbml_w, unsafety);
12021200

12031201
let trait_ref = ty::impl_id_to_trait_ref(tcx, item.id);
1204-
encode_trait_ref(rbml_w, ecx, &*trait_ref, tag_item_trait_ref);
1202+
encode_trait_ref(rbml_w, ecx, trait_ref, tag_item_trait_ref);
12051203
rbml_w.end_tag();
12061204
}
12071205
ast::ItemImpl(unsafety, polarity, _, ref opt_trait, ref ty, ref ast_items) => {
@@ -1246,7 +1244,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
12461244
}
12471245
if opt_trait.is_some() {
12481246
let trait_ref = ty::impl_id_to_trait_ref(tcx, item.id);
1249-
encode_trait_ref(rbml_w, ecx, &*trait_ref, tag_item_trait_ref);
1247+
encode_trait_ref(rbml_w, ecx, trait_ref, tag_item_trait_ref);
12501248
}
12511249
encode_path(rbml_w, path.clone());
12521250
encode_stability(rbml_w, stab);
@@ -1314,7 +1312,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
13141312
tag_item_generics);
13151313
encode_predicates(rbml_w, ecx, &ty::lookup_super_predicates(tcx, def_id),
13161314
tag_item_super_predicates);
1317-
encode_trait_ref(rbml_w, ecx, &*trait_def.trait_ref, tag_item_trait_ref);
1315+
encode_trait_ref(rbml_w, ecx, trait_def.trait_ref, tag_item_trait_ref);
13181316
encode_name(rbml_w, item.ident.name);
13191317
encode_attributes(rbml_w, &item.attrs);
13201318
encode_visibility(rbml_w, vis);

0 commit comments

Comments
 (0)