Skip to content

Commit a7c8a0e

Browse files
committed
---
yaml --- r: 273821 b: refs/heads/beta c: c2fe137 h: refs/heads/master i: 273819: 283fb35
1 parent d1456d3 commit a7c8a0e

File tree

160 files changed

+802
-888
lines changed

Some content is hidden

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

160 files changed

+802
-888
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: e72c8fb754658b5d0cfcefbd1443d9d0911f244e
26+
refs/heads/beta: c2fe137823d78f5741e8a9289f322efbb398bdb7
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,11 @@ To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md).
177177
Rust has an [IRC] culture and most real-time collaboration happens in a
178178
variety of channels on Mozilla's IRC network, irc.mozilla.org. The
179179
most popular channel is [#rust], a venue for general discussion about
180-
Rust, and a good place to ask for help.
180+
Rust. And a good place to ask for help would be [#rust-beginners].
181181
182182
[IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat
183183
[#rust]: irc://irc.mozilla.org/rust
184+
[#rust-beginners]: irc://irc.mozilla.org/rust-beginners
184185
185186
## License
186187

branches/beta/src/doc/book/getting-started.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,15 @@ installed. Doing so will depend on your specific system, consult its
164164
documentation for more details.
165165

166166
If not, there are a number of places where we can get help. The easiest is
167-
[the #rust IRC channel on irc.mozilla.org][irc], which we can access through
168-
[Mibbit][mibbit]. Click that link, and we'll be chatting with other Rustaceans
169-
(a silly nickname we call ourselves) who can help us out. Other great resources
170-
include [the user’s forum][users], and [Stack Overflow][stackoverflow].
167+
[the #rust-beginners IRC channel on irc.mozilla.org][irc-beginners] and for
168+
general discussion [the #rust IRC channel on irc.mozilla.org][irc], which we
169+
can access through [Mibbit][mibbit]. Then we'll be chatting with other
170+
Rustaceans (a silly nickname we call ourselves) who can help us out. Other great
171+
resources include [the user’s forum][users] and [Stack Overflow][stackoverflow].
171172

173+
[irc-beginners]: irc://irc.mozilla.org/#rust-beginners
172174
[irc]: irc://irc.mozilla.org/#rust
173-
[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
175+
[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-beginners,%23rust
174176
[users]: https://users.rust-lang.org/
175177
[stackoverflow]: http://stackoverflow.com/questions/tagged/rust
176178

branches/beta/src/doc/nomicon/vec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
To bring everything together, we're going to write `std::Vec` from scratch.
44
Because all the best tools for writing unsafe code are unstable, this
5-
project will only work on nightly (as of Rust 1.2.0). With the exception of the
5+
project will only work on nightly (as of Rust 1.9.0). With the exception of the
66
allocator API, much of the unstable code we'll use is expected to be stabilized
77
in a similar form as it is today.
88

branches/beta/src/libcollections/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#![feature(placement_new_protocol)]
4949
#![feature(shared)]
5050
#![feature(slice_patterns)]
51+
#![feature(specialization)]
5152
#![feature(staged_api)]
5253
#![feature(step_by)]
5354
#![feature(str_char)]

branches/beta/src/libcollections/string.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ pub trait ToString {
17551755
#[stable(feature = "rust1", since = "1.0.0")]
17561756
impl<T: fmt::Display + ?Sized> ToString for T {
17571757
#[inline]
1758-
fn to_string(&self) -> String {
1758+
default fn to_string(&self) -> String {
17591759
use core::fmt::Write;
17601760
let mut buf = String::new();
17611761
let _ = buf.write_fmt(format_args!("{}", self));
@@ -1764,6 +1764,14 @@ impl<T: fmt::Display + ?Sized> ToString for T {
17641764
}
17651765
}
17661766

1767+
#[stable(feature = "str_to_string_specialization", since = "1.9.0")]
1768+
impl ToString for str {
1769+
#[inline]
1770+
fn to_string(&self) -> String {
1771+
String::from(self)
1772+
}
1773+
}
1774+
17671775
#[stable(feature = "rust1", since = "1.0.0")]
17681776
impl AsRef<str> for String {
17691777
#[inline]

branches/beta/src/libcore/cell.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,6 @@ impl<T:Copy> Cell<T> {
216216

217217
/// Returns a reference to the underlying `UnsafeCell`.
218218
///
219-
/// # Safety
220-
///
221-
/// This function is `unsafe` because `UnsafeCell`'s field is public.
222-
///
223219
/// # Examples
224220
///
225221
/// ```
@@ -229,11 +225,11 @@ impl<T:Copy> Cell<T> {
229225
///
230226
/// let c = Cell::new(5);
231227
///
232-
/// let uc = unsafe { c.as_unsafe_cell() };
228+
/// let uc = c.as_unsafe_cell();
233229
/// ```
234230
#[inline]
235231
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
236-
pub unsafe fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
232+
pub fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
237233
&self.value
238234
}
239235
}

branches/beta/src/librustc/diagnostics.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,47 @@ fn main() {
10331033
some_func(5i32); // ok!
10341034
}
10351035
```
1036+
1037+
Or in a generic context, an erroneous code example would look like:
1038+
```compile_fail
1039+
fn some_func<T>(foo: T) {
1040+
println!("{:?}", foo); // error: the trait `core::fmt::Debug` is not
1041+
// implemented for the type `T`
1042+
}
1043+
1044+
fn main() {
1045+
// We now call the method with the i32 type,
1046+
// which *does* implement the Debug trait.
1047+
some_func(5i32);
1048+
}
1049+
```
1050+
1051+
Note that the error here is in the definition of the generic function: Although
1052+
we only call it with a parameter that does implement `Debug`, the compiler
1053+
still rejects the function: It must work with all possible input types. In
1054+
order to make this example compile, we need to restrict the generic type we're
1055+
accepting:
1056+
```
1057+
use std::fmt;
1058+
1059+
// Restrict the input type to types that implement Debug.
1060+
fn some_func<T: fmt::Debug>(foo: T) {
1061+
println!("{:?}", foo);
1062+
}
1063+
1064+
fn main() {
1065+
// Calling the method is still fine, as i32 implements Debug.
1066+
some_func(5i32);
1067+
1068+
// This would fail to compile now:
1069+
// struct WithoutDebug;
1070+
// some_func(WithoutDebug);
1071+
}
1072+
1073+
Rust only looks at the signature of the called function, as such it must
1074+
already specify all requirements that will be used for every type parameter.
1075+
```
1076+
10361077
"##,
10371078

10381079
E0281: r##"

branches/beta/src/librustc/front/map/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -581,14 +581,6 @@ impl<'ast> Map<'ast> {
581581
}
582582
}
583583

584-
pub fn get_foreign_vis(&self, id: NodeId) -> Visibility {
585-
let vis = self.expect_foreign_item(id).vis; // read recorded by `expect_foreign_item`
586-
match self.find(self.get_parent(id)) { // read recorded by `find`
587-
Some(NodeItem(i)) => vis.inherit_from(i.vis),
588-
_ => vis
589-
}
590-
}
591-
592584
pub fn expect_item(&self, id: NodeId) -> &'ast Item {
593585
match self.find(id) { // read recorded by `find`
594586
Some(NodeItem(item)) => item,

branches/beta/src/librustc/middle/cstore.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use mir::repr::Mir;
3232
use mir::mir_map::MirMap;
3333
use session::Session;
3434
use session::search_paths::PathKind;
35-
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};
35+
use util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
3636
use std::any::Any;
3737
use std::cell::RefCell;
3838
use std::rc::Rc;
@@ -169,6 +169,7 @@ pub trait CrateStore<'tcx> : Any {
169169
fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId)
170170
-> ty::TypeScheme<'tcx>;
171171
fn relative_item_path(&self, def: DefId) -> Vec<hir_map::PathElem>;
172+
fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>>;
172173
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem>;
173174
fn item_name(&self, def: DefId) -> ast::Name;
174175
fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
@@ -347,6 +348,9 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
347348
fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId)
348349
-> ty::TypeScheme<'tcx> { unimplemented!() }
349350
fn relative_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { unimplemented!() }
351+
fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>> {
352+
unimplemented!()
353+
}
350354
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { unimplemented!() }
351355
fn item_name(&self, def: DefId) -> ast::Name { unimplemented!() }
352356
fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)

branches/beta/src/librustc/ty/item_path.rs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use front::map::DefPathData;
1212
use middle::cstore::LOCAL_CRATE;
13-
use middle::def_id::DefId;
13+
use middle::def_id::{DefId, CRATE_DEF_INDEX};
1414
use ty::{self, Ty, TyCtxt};
1515
use syntax::ast;
1616

@@ -75,9 +75,51 @@ impl<'tcx> TyCtxt<'tcx> {
7575
}
7676
}
7777

78+
/// If possible, this pushes a global path resolving to `external_def_id` that is visible
79+
/// from at least one local module and returns true. If the crate defining `external_def_id` is
80+
/// declared with an `extern crate`, the path is guarenteed to use the `extern crate`.
81+
pub fn try_push_visible_item_path<T>(&self, buffer: &mut T, external_def_id: DefId) -> bool
82+
where T: ItemPathBuffer
83+
{
84+
let visible_parent_map = self.sess.cstore.visible_parent_map();
85+
86+
let (mut cur_def, mut cur_path) = (external_def_id, Vec::<ast::Name>::new());
87+
loop {
88+
// If `cur_def` is a direct or injected extern crate, push the path to the crate
89+
// followed by the path to the item within the crate and return.
90+
if cur_def.index == CRATE_DEF_INDEX {
91+
match self.sess.cstore.extern_crate(cur_def.krate) {
92+
Some(extern_crate) if extern_crate.direct => {
93+
self.push_item_path(buffer, extern_crate.def_id);
94+
cur_path.iter().rev().map(|segment| buffer.push(&segment.as_str())).count();
95+
return true;
96+
}
97+
None => {
98+
buffer.push(&self.crate_name(cur_def.krate));
99+
cur_path.iter().rev().map(|segment| buffer.push(&segment.as_str())).count();
100+
return true;
101+
}
102+
_ => {},
103+
}
104+
}
105+
106+
cur_path.push(self.sess.cstore.item_name(cur_def));
107+
match visible_parent_map.get(&cur_def) {
108+
Some(&def) => cur_def = def,
109+
None => return false,
110+
};
111+
}
112+
}
113+
78114
pub fn push_item_path<T>(&self, buffer: &mut T, def_id: DefId)
79115
where T: ItemPathBuffer
80116
{
117+
match *buffer.root_mode() {
118+
RootMode::Local if !def_id.is_local() =>
119+
if self.try_push_visible_item_path(buffer, def_id) { return },
120+
_ => {}
121+
}
122+
81123
let key = self.def_key(def_id);
82124
match key.disambiguated_data.data {
83125
DefPathData::CrateRoot => {

branches/beta/src/librustc_metadata/csearch.rs

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ use decoder;
1313
use encoder;
1414
use loader;
1515

16-
use middle::cstore::{CrateStore, CrateSource, ChildItem, ExternCrate, FoundAst};
16+
use middle::cstore::{CrateStore, CrateSource, ChildItem, ExternCrate, FoundAst, DefLike};
1717
use middle::cstore::{NativeLibraryKind, LinkMeta, LinkagePreference};
1818
use middle::def;
1919
use middle::lang_items;
2020
use rustc::ty::{self, Ty, TyCtxt, VariantKind};
21-
use middle::def_id::{DefId, DefIndex};
21+
use middle::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
2222

2323
use rustc::front::map as hir_map;
2424
use rustc::mir::repr::Mir;
2525
use rustc::mir::mir_map::MirMap;
26-
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet};
26+
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
2727

2828
use std::cell::RefCell;
2929
use std::rc::Rc;
@@ -544,4 +544,60 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
544544
{
545545
encoder::metadata_encoding_version
546546
}
547+
548+
/// Returns a map from a sufficiently visible external item (i.e. an external item that is
549+
/// visible from at least one local module) to a sufficiently visible parent (considering
550+
/// modules that re-export the external item to be parents).
551+
fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>> {
552+
let mut visible_parent_map = self.visible_parent_map.borrow_mut();
553+
if !visible_parent_map.is_empty() { return visible_parent_map; }
554+
555+
use rustc_front::hir;
556+
use rustc::middle::cstore::{CrateStore, ChildItem};
557+
use std::collections::vec_deque::VecDeque;
558+
use std::collections::hash_map::Entry;
559+
for cnum in 1 .. self.next_crate_num() {
560+
let cdata = self.get_crate_data(cnum);
561+
562+
match cdata.extern_crate.get() {
563+
// Ignore crates without a corresponding local `extern crate` item.
564+
Some(extern_crate) if !extern_crate.direct => continue,
565+
_ => {},
566+
}
567+
568+
let mut bfs_queue = &mut VecDeque::new();
569+
let mut add_child = |bfs_queue: &mut VecDeque<_>, child: ChildItem, parent: DefId| {
570+
let child = match child.def {
571+
DefLike::DlDef(def) if child.vis == hir::Public => def.def_id(),
572+
_ => return,
573+
};
574+
575+
match visible_parent_map.entry(child) {
576+
Entry::Occupied(mut entry) => {
577+
// If `child` is defined in crate `cnum`, ensure
578+
// that it is mapped to a parent in `cnum`.
579+
if child.krate == cnum && entry.get().krate != cnum {
580+
entry.insert(parent);
581+
}
582+
}
583+
Entry::Vacant(entry) => {
584+
entry.insert(parent);
585+
bfs_queue.push_back(child);
586+
}
587+
}
588+
};
589+
590+
let croot = DefId { krate: cnum, index: CRATE_DEF_INDEX };
591+
for child in self.crate_top_level_items(cnum) {
592+
add_child(bfs_queue, child, croot);
593+
}
594+
while let Some(def) = bfs_queue.pop_front() {
595+
for child in self.item_children(def) {
596+
add_child(bfs_queue, child, def);
597+
}
598+
}
599+
}
600+
601+
visible_parent_map
602+
}
547603
}

branches/beta/src/librustc_metadata/cstore.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ use loader;
2222

2323
use rustc::back::svh::Svh;
2424
use rustc::middle::cstore::{ExternCrate};
25-
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet};
25+
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
26+
use rustc::middle::def_id::DefId;
2627

2728
use std::cell::{RefCell, Ref, Cell};
2829
use std::rc::Rc;
@@ -92,6 +93,7 @@ pub struct CStore {
9293
used_link_args: RefCell<Vec<String>>,
9394
statically_included_foreign_items: RefCell<NodeSet>,
9495
pub intr: Rc<IdentInterner>,
96+
pub visible_parent_map: RefCell<DefIdMap<DefId>>,
9597
}
9698

9799
impl CStore {
@@ -104,6 +106,7 @@ impl CStore {
104106
used_link_args: RefCell::new(Vec::new()),
105107
intr: intr,
106108
statically_included_foreign_items: RefCell::new(NodeSet()),
109+
visible_parent_map: RefCell::new(FnvHashMap()),
107110
}
108111
}
109112

0 commit comments

Comments
 (0)