Skip to content

Commit 865b0ab

Browse files
committed
---
yaml --- r: 225270 b: refs/heads/stable c: 8703883 h: refs/heads/master v: v3
1 parent eb5d4de commit 865b0ab

Some content is hidden

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

48 files changed

+634
-613
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 6a003abc374c912b4890b6cc1c61b5b1bd1efe60
32+
refs/heads/stable: 87038831f1d1eafe6978a823cdbb353d3a7d3f8d
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b

branches/stable/src/doc/trpl/installing-rust.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ Some people, and somewhat rightfully so, get very upset when we tell you to
4343
`curl | sh`. Basically, when you do this, you are trusting that the good
4444
people who maintain Rust aren't going to hack your computer and do bad things.
4545
That's a good instinct! If you're one of those people, please check out the
46-
documentation on [building Rust from Source][from-source], or [the official
47-
binary downloads][install-page].
46+
documentation on [building Rust from Source][from source], or [the official
47+
binary downloads][install page].
4848

49-
[from-source]: https://github.com/rust-lang/rust#building-from-source
50-
[install-page]: http://www.rust-lang.org/install.html
49+
[from source]: https://github.com/rust-lang/rust#building-from-source
50+
[install page]: http://www.rust-lang.org/install.html
5151

5252
Oh, we should also mention the officially supported platforms:
5353

branches/stable/src/doc/trpl/macros.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ mind.
3030

3131
# Defining a macro
3232

33-
You may have seen the `vec!` macro, used to initialize a [vector][vector] with
34-
any number of elements.
33+
You may have seen the `vec!` macro, used to initialize a [vector][] with any
34+
number of elements.
3535

3636
[vector]: vectors.html
3737

@@ -349,7 +349,7 @@ fn main() {
349349
}
350350
```
351351

352-
This holds for `let` bindings and loop labels, but not for [items][items].
352+
This holds for `let` bindings and loop labels, but not for [items][].
353353
So the following code does compile:
354354

355355
```rust
@@ -470,7 +470,7 @@ which syntactic form it matches.
470470
* `stmt`: a single statement. Example: `let x = 3`.
471471
* `block`: a brace-delimited sequence of statements. Example:
472472
`{ log(error, "hi"); return 12; }`.
473-
* `item`: an [item][item]. Examples: `fn foo() { }`; `struct Bar;`.
473+
* `item`: an [item][]. Examples: `fn foo() { }`; `struct Bar;`.
474474
* `meta`: a "meta item", as found in attributes. Example: `cfg(target_os = "windows")`.
475475
* `tt`: a single token tree.
476476

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ Some people, and somewhat rightfully so, get very upset when we tell you to
4646
`curl | sh`. Basically, when you do this, you are trusting that the good
4747
people who maintain Rust aren't going to hack your computer and do bad things.
4848
That's a good instinct! If you're one of those people, please check out the
49-
documentation on [building Rust from Source][from-source], or [the official
50-
binary downloads][install-page].
49+
documentation on [building Rust from Source][from source], or [the official
50+
binary downloads][install page].
5151

52-
[from-source]: https://github.com/rust-lang/rust#building-from-source
53-
[install-page]: http://www.rust-lang.org/install.html
52+
[from source]: https://github.com/rust-lang/rust#building-from-source
53+
[install page]: http://www.rust-lang.org/install.html
5454

5555
Oh, we should also mention the officially supported platforms:
5656

@@ -91,9 +91,9 @@ If not, there are a number of places where you can get help. The easiest is
9191
[the #rust IRC channel on irc.mozilla.org][irc], which you can access through
9292
[Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans
9393
(a silly nickname we call ourselves), and we can help you out. Other great
94-
resources include [the user’s forum][users], and [Stack Overflow][stackoverflow].
94+
resources include [the user’s forum][users], and [Stack Overflow][stack overflow].
9595

9696
[irc]: irc://irc.mozilla.org/#rust
9797
[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
9898
[users]: http://users.rust-lang.org/
99-
[stackoverflow]: http://stackoverflow.com/questions/tagged/rust
99+
[stack overflow]: http://stackoverflow.com/questions/tagged/rust

branches/stable/src/doc/trpl/strings.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,6 @@ fn main() {
4949
}
5050
```
5151

52-
This coercion does not happen for functions that accept one of `&str`’s traits
53-
instead of `&str`. For example, [`TcpStream::connect`][connect] has a parameter
54-
of type `ToSocketAddrs`. A `&str` is okay but a `String` must be explicitly
55-
converted using `&*`.
56-
57-
```rust,no_run
58-
use std::net::TcpStream;
59-
60-
TcpStream::connect("192.168.0.1:3000"); // &str parameter
61-
62-
let addr_string = "192.168.0.1:3000".to_string();
63-
TcpStream::connect(&*addr_string); // convert addr_string to &str
64-
```
65-
6652
Viewing a `String` as a `&str` is cheap, but converting the `&str` to a
6753
`String` involves allocating memory. No reason to do that unless you have to!
6854

@@ -141,4 +127,3 @@ This is because `&String` can automatically coerce to a `&str`. This is a
141127
feature called ‘[`Deref` coercions][dc]’.
142128

143129
[dc]: deref-coercions.html
144-
[connect]: ../std/net/struct.TcpStream.html#method.connect

branches/stable/src/liballoc/boxed.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,24 @@ impl<T : ?Sized> Box<T> {
139139
/// convert pointer back to `Box` with `Box::from_raw` function, because
140140
/// `Box` does not specify, how memory is allocated.
141141
///
142+
/// Function is unsafe, because result of this function is no longer
143+
/// automatically managed that may lead to memory or other resource
144+
/// leak.
145+
///
142146
/// # Examples
143147
/// ```
144148
/// # #![feature(alloc)]
145149
/// use std::boxed;
146150
///
147151
/// let seventeen = Box::new(17u32);
148-
/// let raw = boxed::into_raw(seventeen);
152+
/// let raw = unsafe { boxed::into_raw(seventeen) };
149153
/// let boxed_again = unsafe { Box::from_raw(raw) };
150154
/// ```
151155
#[unstable(feature = "alloc",
152156
reason = "may be renamed")]
153157
#[inline]
154-
pub fn into_raw<T : ?Sized>(b: Box<T>) -> *mut T {
155-
unsafe { mem::transmute(b) }
158+
pub unsafe fn into_raw<T : ?Sized>(b: Box<T>) -> *mut T {
159+
mem::transmute(b)
156160
}
157161

158162
#[stable(feature = "rust1", since = "1.0.0")]

branches/stable/src/libcore/iter.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -452,19 +452,20 @@ pub trait Iterator {
452452
Scan{iter: self, f: f, state: initial_state}
453453
}
454454

455-
/// Takes a function that maps each element to a new iterator and yields
456-
/// all the elements of the produced iterators.
457-
///
458-
/// This is useful for unraveling nested structures.
455+
/// Creates an iterator that maps each element to an iterator,
456+
/// and yields the elements of the produced iterators.
459457
///
460458
/// # Examples
461459
///
462460
/// ```
463-
/// let words = ["alpha", "beta", "gamma"];
464-
/// let merged: String = words.iter()
465-
/// .flat_map(|s| s.chars())
466-
/// .collect();
467-
/// assert_eq!(merged, "alphabetagamma");
461+
/// # #![feature(core)]
462+
/// let xs = [2, 3];
463+
/// let ys = [0, 1, 0, 1, 2];
464+
/// let it = xs.iter().flat_map(|&x| (0..).take(x));
465+
/// // Check that `it` has the same elements as `ys`
466+
/// for (i, x) in it.enumerate() {
467+
/// assert_eq!(x, ys[i]);
468+
/// }
468469
/// ```
469470
#[inline]
470471
#[stable(feature = "rust1", since = "1.0.0")]

branches/stable/src/librustc/metadata/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ enum_from_u32! {
146146
tag_table_closure_kinds = 0x65,
147147
tag_table_upvar_capture_map = 0x66,
148148
tag_table_capture_modes = 0x67,
149-
// GAP 0x68
149+
tag_table_object_cast_map = 0x68,
150150
tag_table_const_qualif = 0x69,
151151
tag_table_cast_kinds = 0x6a,
152152
}

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ pub fn get_impl_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
297297
decoder::get_impl_trait(&*cdata, def.node, tcx)
298298
}
299299

300+
// Given a def_id for an impl, return information about its vtables
301+
pub fn get_impl_vtables<'tcx>(tcx: &ty::ctxt<'tcx>,
302+
def: ast::DefId)
303+
-> ty::vtable_res<'tcx> {
304+
let cstore = &tcx.sess.cstore;
305+
let cdata = cstore.get_crate_data(def.krate);
306+
decoder::get_impl_vtables(&*cdata, def.node, tcx)
307+
}
308+
300309
pub fn get_native_libraries(cstore: &cstore::CStore, crate_num: ast::CrateNum)
301310
-> Vec<(cstore::NativeLibraryKind, String)> {
302311
let cdata = cstore.get_crate_data(crate_num);
@@ -380,20 +389,15 @@ pub fn is_const_fn(cstore: &cstore::CStore, did: ast::DefId) -> bool {
380389
decoder::is_const_fn(&*cdata, did.node)
381390
}
382391

383-
pub fn is_impl(cstore: &cstore::CStore, did: ast::DefId) -> bool {
384-
let cdata = cstore.get_crate_data(did.krate);
385-
decoder::is_impl(&*cdata, did.node)
386-
}
387-
388392
pub fn get_stability(cstore: &cstore::CStore,
389393
def: ast::DefId)
390394
-> Option<attr::Stability> {
391395
let cdata = cstore.get_crate_data(def.krate);
392396
decoder::get_stability(&*cdata, def.node)
393397
}
394398

395-
pub fn is_staged_api(cstore: &cstore::CStore, krate: ast::CrateNum) -> bool {
396-
let cdata = cstore.get_crate_data(krate);
399+
pub fn is_staged_api(cstore: &cstore::CStore, def: ast::DefId) -> bool {
400+
let cdata = cstore.get_crate_data(def.krate);
397401
let attrs = decoder::get_crate_attributes(cdata.data());
398402
for attr in &attrs {
399403
if &attr.name()[..] == "staged_api" {
@@ -410,6 +414,11 @@ pub fn get_repr_attrs(cstore: &cstore::CStore, def: ast::DefId)
410414
decoder::get_repr_attrs(&*cdata, def.node)
411415
}
412416

417+
pub fn is_associated_type(cstore: &cstore::CStore, def: ast::DefId) -> bool {
418+
let cdata = cstore.get_crate_data(def.krate);
419+
decoder::is_associated_type(&*cdata, def.node)
420+
}
421+
413422
pub fn is_defaulted_trait(cstore: &cstore::CStore, trait_def_id: ast::DefId) -> bool {
414423
let cdata = cstore.get_crate_data(trait_def_id.krate);
415424
decoder::is_defaulted_trait(&*cdata, trait_def_id.node)

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

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

3536
use std::cell::{Cell, RefCell};
@@ -521,6 +522,18 @@ pub fn get_impl_trait<'tcx>(cdata: Cmd,
521522
}
522523
}
523524

525+
pub fn get_impl_vtables<'tcx>(cdata: Cmd,
526+
id: ast::NodeId,
527+
tcx: &ty::ctxt<'tcx>)
528+
-> ty::vtable_res<'tcx>
529+
{
530+
let item_doc = lookup_item(id, cdata.data());
531+
let vtables_doc = reader::get_doc(item_doc, tag_item_impl_vtables);
532+
let mut decoder = reader::Decoder::new(vtables_doc);
533+
decoder.read_vtable_res(tcx, cdata)
534+
}
535+
536+
524537
pub fn get_symbol(data: &[u8], id: ast::NodeId) -> String {
525538
return item_symbol(lookup_item(id, data));
526539
}
@@ -1533,14 +1546,6 @@ pub fn is_const_fn(cdata: Cmd, id: ast::NodeId) -> bool {
15331546
}
15341547
}
15351548

1536-
pub fn is_impl(cdata: Cmd, id: ast::NodeId) -> bool {
1537-
let item_doc = lookup_item(id, cdata.data());
1538-
match item_family(item_doc) {
1539-
Impl => true,
1540-
_ => false,
1541-
}
1542-
}
1543-
15441549
fn doc_generics<'tcx>(base_doc: rbml::Doc,
15451550
tcx: &ty::ctxt<'tcx>,
15461551
cdata: Cmd,
@@ -1618,6 +1623,14 @@ fn doc_predicates<'tcx>(base_doc: rbml::Doc,
16181623
ty::GenericPredicates { predicates: predicates }
16191624
}
16201625

1626+
pub fn is_associated_type(cdata: Cmd, id: ast::NodeId) -> bool {
1627+
let items = reader::get_doc(rbml::Doc::new(cdata.data()), tag_items);
1628+
match maybe_find_item(id, items) {
1629+
None => false,
1630+
Some(item) => item_sort(item) == Some('t'),
1631+
}
1632+
}
1633+
16211634
pub fn is_defaulted_trait(cdata: Cmd, trait_id: ast::NodeId) -> bool {
16221635
let trait_doc = lookup_item(trait_id, cdata.data());
16231636
assert!(item_family(trait_doc) == Family::Trait);

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ fn encode_extension_implementations(ecx: &EncodeContext,
999999
});
10001000
}
10011001

1002-
fn encode_stability(rbml_w: &mut Encoder, stab_opt: Option<&attr::Stability>) {
1002+
fn encode_stability(rbml_w: &mut Encoder, stab_opt: Option<attr::Stability>) {
10031003
stab_opt.map(|stab| {
10041004
rbml_w.start_tag(tag_items_data_item_stability);
10051005
stab.encode(rbml_w).unwrap();
@@ -1215,11 +1215,11 @@ fn encode_info_for_item(ecx: &EncodeContext,
12151215
encode_name(rbml_w, item.ident.name);
12161216
encode_unsafety(rbml_w, unsafety);
12171217

1218-
let trait_ref = ty::impl_trait_ref(tcx, local_def(item.id)).unwrap();
1218+
let trait_ref = ty::impl_id_to_trait_ref(tcx, item.id);
12191219
encode_trait_ref(rbml_w, ecx, trait_ref, tag_item_trait_ref);
12201220
rbml_w.end_tag();
12211221
}
1222-
ast::ItemImpl(unsafety, polarity, _, _, ref ty, ref ast_items) => {
1222+
ast::ItemImpl(unsafety, polarity, _, ref opt_trait, ref ty, ref ast_items) => {
12231223
// We need to encode information about the default methods we
12241224
// have inherited, so we drive this based on the impl structure.
12251225
let impl_items = tcx.impl_items.borrow();
@@ -1269,7 +1269,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
12691269
}
12701270
rbml_w.end_tag();
12711271
}
1272-
if let Some(trait_ref) = ty::impl_trait_ref(tcx, local_def(item.id)) {
1272+
if opt_trait.is_some() {
1273+
let trait_ref = ty::impl_id_to_trait_ref(tcx, item.id);
12731274
encode_trait_ref(rbml_w, ecx, trait_ref, tag_item_trait_ref);
12741275
}
12751276
encode_path(rbml_w, path.clone());

0 commit comments

Comments
 (0)