Skip to content

Commit 4b6440e

Browse files
committed
---
yaml --- r: 272178 b: refs/heads/auto c: 9a28d4e h: refs/heads/master
1 parent 872c209 commit 4b6440e

File tree

158 files changed

+901
-768
lines changed

Some content is hidden

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

158 files changed

+901
-768
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 53498eca50e25d8a11f9dc5859770715fa906fa7
11+
refs/heads/auto: 9a28d4edc9375e5bf606c453d1e03a45ae8be0af
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/liballoc/arc.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<T> Arc<T> {
223223
#[stable(feature = "arc_unique", since = "1.4.0")]
224224
pub fn try_unwrap(this: Self) -> Result<T, Self> {
225225
// See `drop` for why all these atomics are like this
226-
if this.inner().strong.compare_and_swap(1, 0, Release) != 1 {
226+
if this.inner().strong.compare_exchange(1, 0, Release, Relaxed).is_err() {
227227
return Err(this);
228228
}
229229

@@ -256,11 +256,11 @@ impl<T: ?Sized> Arc<T> {
256256
/// ```
257257
#[stable(feature = "arc_weak", since = "1.4.0")]
258258
pub fn downgrade(this: &Self) -> Weak<T> {
259-
loop {
260-
// This Relaxed is OK because we're checking the value in the CAS
261-
// below.
262-
let cur = this.inner().weak.load(Relaxed);
259+
// This Relaxed is OK because we're checking the value in the CAS
260+
// below.
261+
let mut cur = this.inner().weak.load(Relaxed);
263262

263+
loop {
264264
// check if the weak counter is currently "locked"; if so, spin.
265265
if cur == usize::MAX {
266266
continue;
@@ -273,8 +273,9 @@ impl<T: ?Sized> Arc<T> {
273273
// Unlike with Clone(), we need this to be an Acquire read to
274274
// synchronize with the write coming from `is_unique`, so that the
275275
// events prior to that write happen before this read.
276-
if this.inner().weak.compare_and_swap(cur, cur + 1, Acquire) == cur {
277-
return Weak { _ptr: this._ptr };
276+
match this.inner().weak.compare_exchange_weak(cur, cur + 1, Acquire, Relaxed) {
277+
Ok(_) => return Weak { _ptr: this._ptr },
278+
Err(old) => cur = old,
278279
}
279280
}
280281
}
@@ -416,7 +417,7 @@ impl<T: Clone> Arc<T> {
416417
// before release writes (i.e., decrements) to `strong`. Since we hold a
417418
// weak count, there's no chance the ArcInner itself could be
418419
// deallocated.
419-
if this.inner().strong.compare_and_swap(1, 0, Acquire) != 1 {
420+
if this.inner().strong.compare_exchange(1, 0, Acquire, Relaxed).is_err() {
420421
// Another strong pointer exists; clone
421422
*this = Arc::new((**this).clone());
422423
} else if this.inner().weak.load(Relaxed) != 1 {
@@ -506,7 +507,7 @@ impl<T: ?Sized> Arc<T> {
506507
// The acquire label here ensures a happens-before relationship with any
507508
// writes to `strong` prior to decrements of the `weak` count (via drop,
508509
// which uses Release).
509-
if self.inner().weak.compare_and_swap(1, usize::MAX, Acquire) == 1 {
510+
if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() {
510511
// Due to the previous acquire read, this will observe any writes to
511512
// `strong` that were due to upgrading weak pointers; only strong
512513
// clones remain, which require that the strong count is > 1 anyway.
@@ -618,12 +619,14 @@ impl<T: ?Sized> Weak<T> {
618619
// We use a CAS loop to increment the strong count instead of a
619620
// fetch_add because once the count hits 0 it must never be above 0.
620621
let inner = self.inner();
622+
623+
// Relaxed load because any write of 0 that we can observe
624+
// leaves the field in a permanently zero state (so a
625+
// "stale" read of 0 is fine), and any other value is
626+
// confirmed via the CAS below.
627+
let mut n = inner.strong.load(Relaxed);
628+
621629
loop {
622-
// Relaxed load because any write of 0 that we can observe
623-
// leaves the field in a permanently zero state (so a
624-
// "stale" read of 0 is fine), and any other value is
625-
// confirmed via the CAS below.
626-
let n = inner.strong.load(Relaxed);
627630
if n == 0 {
628631
return None;
629632
}
@@ -634,9 +637,9 @@ impl<T: ?Sized> Weak<T> {
634637
}
635638

636639
// Relaxed is valid for the same reason it is on Arc's Clone impl
637-
let old = inner.strong.compare_and_swap(n, n + 1, Relaxed);
638-
if old == n {
639-
return Some(Arc { _ptr: self._ptr });
640+
match inner.strong.compare_exchange_weak(n, n + 1, Relaxed, Relaxed) {
641+
Ok(_) => return Some(Arc { _ptr: self._ptr }),
642+
Err(old) => n = old,
640643
}
641644
}
642645
}

branches/auto/src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
#![feature(unique)]
9191
#![feature(unsafe_no_drop_flag, filling_drop)]
9292
#![feature(unsize)]
93+
#![feature(extended_compare_and_swap)]
9394

9495
#![cfg_attr(not(test), feature(raw, fn_traits, placement_new_protocol))]
9596
#![cfg_attr(test, feature(test, box_heap))]

branches/auto/src/libcollections/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#![feature(placement_new_protocol)]
4949
#![feature(shared)]
5050
#![feature(slice_patterns)]
51-
#![feature(specialization)]
5251
#![feature(staged_api)]
5352
#![feature(step_by)]
5453
#![feature(str_char)]

branches/auto/src/libcollections/string.rs

Lines changed: 1 addition & 9 deletions
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-
default fn to_string(&self) -> String {
1758+
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,14 +1764,6 @@ 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-
17751767
#[stable(feature = "rust1", since = "1.0.0")]
17761768
impl AsRef<str> for String {
17771769
#[inline]

branches/auto/src/libcore/cell.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ 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+
///
219223
/// # Examples
220224
///
221225
/// ```
@@ -225,11 +229,11 @@ impl<T:Copy> Cell<T> {
225229
///
226230
/// let c = Cell::new(5);
227231
///
228-
/// let uc = c.as_unsafe_cell();
232+
/// let uc = unsafe { c.as_unsafe_cell() };
229233
/// ```
230234
#[inline]
231235
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
232-
pub fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
236+
pub unsafe fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
233237
&self.value
234238
}
235239
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,14 @@ 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+
584592
pub fn expect_item(&self, id: NodeId) -> &'ast Item {
585593
match self.find(id) { // read recorded by `find`
586594
Some(NodeItem(item)) => item,

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

Lines changed: 1 addition & 5 deletions
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, DefIdMap};
35+
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};
3636
use std::any::Any;
3737
use std::cell::RefCell;
3838
use std::rc::Rc;
@@ -169,7 +169,6 @@ 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>>;
173172
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem>;
174173
fn item_name(&self, def: DefId) -> ast::Name;
175174
fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
@@ -348,9 +347,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
348347
fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId)
349348
-> ty::TypeScheme<'tcx> { unimplemented!() }
350349
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-
}
354350
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { unimplemented!() }
355351
fn item_name(&self, def: DefId) -> ast::Name { unimplemented!() }
356352
fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)

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

Lines changed: 1 addition & 43 deletions
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, CRATE_DEF_INDEX};
13+
use middle::def_id::DefId;
1414
use ty::{self, Ty, TyCtxt};
1515
use syntax::ast;
1616

@@ -75,51 +75,9 @@ 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-
11478
pub fn push_item_path<T>(&self, buffer: &mut T, def_id: DefId)
11579
where T: ItemPathBuffer
11680
{
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-
12381
let key = self.def_key(def_id);
12482
match key.disambiguated_data.data {
12583
DefPathData::CrateRoot => {

branches/auto/src/librustc_metadata/csearch.rs

Lines changed: 3 additions & 59 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, DefLike};
16+
use middle::cstore::{CrateStore, CrateSource, ChildItem, ExternCrate, FoundAst};
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, CRATE_DEF_INDEX};
21+
use middle::def_id::{DefId, DefIndex};
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, DefIdMap};
26+
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet};
2727

2828
use std::cell::RefCell;
2929
use std::rc::Rc;
@@ -544,60 +544,4 @@ 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-
}
603547
}

branches/auto/src/librustc_metadata/cstore.rs

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

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

2827
use std::cell::{RefCell, Ref, Cell};
2928
use std::rc::Rc;
@@ -93,7 +92,6 @@ pub struct CStore {
9392
used_link_args: RefCell<Vec<String>>,
9493
statically_included_foreign_items: RefCell<NodeSet>,
9594
pub intr: Rc<IdentInterner>,
96-
pub visible_parent_map: RefCell<DefIdMap<DefId>>,
9795
}
9896

9997
impl CStore {
@@ -106,7 +104,6 @@ impl CStore {
106104
used_link_args: RefCell::new(Vec::new()),
107105
intr: intr,
108106
statically_included_foreign_items: RefCell::new(NodeSet()),
109-
visible_parent_map: RefCell::new(FnvHashMap()),
110107
}
111108
}
112109

0 commit comments

Comments
 (0)