Skip to content

Commit b893f08

Browse files
committed
---
yaml --- r: 194568 b: refs/heads/snap-stage3 c: e6166b7 h: refs/heads/master v: v3
1 parent 2cf8da3 commit b893f08

Some content is hidden

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

74 files changed

+1583
-265
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 242ed0b7c0f6a21096f2cc3e1ad1bdb176d02545
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: dd8cf9238940b7b0dc54cc05d0788d8d7282aa27
4+
refs/heads/snap-stage3: e6166b74988d7d5201152ae4e142f04a3d3a0e5b
55
refs/heads/try: 961e0358e1a5c0faaef606e31e9965742c1643bf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/mk/tests.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,11 @@ ifeq ($(CFG_OSTYPE),apple-darwin)
569569
CTEST_DISABLE_debuginfo-gdb = "gdb on darwin needs root"
570570
endif
571571

572+
ifeq ($(findstring android, $(CFG_TARGET)), android)
573+
CTEST_DISABLE_debuginfo-gdb =
574+
CTEST_DISABLE_debuginfo-lldb = "lldb tests are disabled on android"
575+
endif
576+
572577
# CTEST_DISABLE_NONSELFHOST_$(TEST_GROUP), if set, will cause that
573578
# test group to be disabled *unless* the target is able to build a
574579
# compiler (i.e. when the target triple is in the set of of host

branches/snap-stage3/src/doc/trpl/pointers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ fn add(x: &i32, y: &i32) -> i32 {
568568
fn main() {
569569
let x = Box::new(5);
570570
571-
println!("{}", add(&x, &x));
572-
println!("{}", add(&x, &x));
571+
println!("{}", add(&*x, &*x));
572+
println!("{}", add(&*x, &*x));
573573
}
574574
```
575575

branches/snap-stage3/src/liballoc/arc.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ impl<T> Drop for Arc<T> {
354354
// more than once (but it is guaranteed to be zeroed after the first if
355355
// it's run more than once)
356356
let ptr = *self._ptr;
357-
if ptr.is_null() { return }
357+
// if ptr.is_null() { return }
358+
if ptr.is_null() || ptr as usize == mem::POST_DROP_USIZE { return }
358359

359360
// Because `fetch_sub` is already atomic, we do not need to synchronize
360361
// with other threads unless we are going to delete the object. This
@@ -485,7 +486,7 @@ impl<T> Drop for Weak<T> {
485486
let ptr = *self._ptr;
486487

487488
// see comments above for why this check is here
488-
if ptr.is_null() { return }
489+
if ptr.is_null() || ptr as usize == mem::POST_DROP_USIZE { return }
489490

490491
// If we find out that we were the last weak pointer, then its time to
491492
// deallocate the data entirely. See the discussion in Arc::drop() about

branches/snap-stage3/src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
#![feature(box_syntax)]
7676
#![feature(optin_builtin_traits)]
7777
#![feature(unboxed_closures)]
78-
#![feature(unsafe_no_drop_flag)]
78+
#![feature(unsafe_no_drop_flag, filling_drop)]
7979
#![feature(core)]
8080
#![feature(unique)]
8181
#![cfg_attr(test, feature(test, alloc, rustc_private))]

branches/snap-stage3/src/liballoc/rc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ use core::default::Default;
160160
use core::fmt;
161161
use core::hash::{Hasher, Hash};
162162
use core::marker;
163-
use core::mem::{min_align_of, size_of, forget};
163+
use core::mem::{self, min_align_of, size_of, forget};
164164
use core::nonzero::NonZero;
165165
use core::ops::{Deref, Drop};
166166
use core::option::Option;
@@ -407,7 +407,7 @@ impl<T> Drop for Rc<T> {
407407
fn drop(&mut self) {
408408
unsafe {
409409
let ptr = *self._ptr;
410-
if !ptr.is_null() {
410+
if !ptr.is_null() && ptr as usize != mem::POST_DROP_USIZE {
411411
self.dec_strong();
412412
if self.strong() == 0 {
413413
ptr::read(&**self); // destroy the contained object
@@ -718,7 +718,7 @@ impl<T> Drop for Weak<T> {
718718
fn drop(&mut self) {
719719
unsafe {
720720
let ptr = *self._ptr;
721-
if !ptr.is_null() {
721+
if !ptr.is_null() && ptr as usize != mem::POST_DROP_USIZE {
722722
self.dec_weak();
723723
// the weak count starts at 1, and will only go to zero if all
724724
// the strong pointers have disappeared.

branches/snap-stage3/src/libcollections/btree/map.rs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,15 +1143,39 @@ impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> {
11431143
}
11441144

11451145
impl<'a, K: Ord, V> Entry<'a, K, V> {
1146-
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
11471146
#[unstable(feature = "std_misc",
11481147
reason = "will soon be replaced by or_insert")]
1148+
#[deprecated(since = "1.0",
1149+
reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
1150+
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
11491151
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
11501152
match self {
11511153
Occupied(entry) => Ok(entry.into_mut()),
11521154
Vacant(entry) => Err(entry),
11531155
}
11541156
}
1157+
1158+
#[unstable(feature = "collections",
1159+
reason = "matches entry v3 specification, waiting for dust to settle")]
1160+
/// Ensures a value is in the entry by inserting the default if empty, and returns
1161+
/// a mutable reference to the value in the entry.
1162+
pub fn or_insert(self, default: V) -> &'a mut V {
1163+
match self {
1164+
Occupied(entry) => entry.into_mut(),
1165+
Vacant(entry) => entry.insert(default),
1166+
}
1167+
}
1168+
1169+
#[unstable(feature = "collections",
1170+
reason = "matches entry v3 specification, waiting for dust to settle")]
1171+
/// Ensures a value is in the entry by inserting the result of the default function if empty,
1172+
/// and returns a mutable reference to the value in the entry.
1173+
pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
1174+
match self {
1175+
Occupied(entry) => entry.into_mut(),
1176+
Vacant(entry) => entry.insert(default()),
1177+
}
1178+
}
11551179
}
11561180

11571181
impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
@@ -1563,21 +1587,12 @@ impl<K: Ord, V> BTreeMap<K, V> {
15631587
/// ```
15641588
/// # #![feature(collections)]
15651589
/// use std::collections::BTreeMap;
1566-
/// use std::collections::btree_map::Entry;
15671590
///
15681591
/// let mut count: BTreeMap<&str, usize> = BTreeMap::new();
15691592
///
15701593
/// // count the number of occurrences of letters in the vec
1571-
/// for x in vec!["a","b","a","c","a","b"].iter() {
1572-
/// match count.entry(*x) {
1573-
/// Entry::Vacant(view) => {
1574-
/// view.insert(1);
1575-
/// },
1576-
/// Entry::Occupied(mut view) => {
1577-
/// let v = view.get_mut();
1578-
/// *v += 1;
1579-
/// },
1580-
/// }
1594+
/// for x in vec!["a","b","a","c","a","b"] {
1595+
/// *count.entry(x).or_insert(0) += 1;
15811596
/// }
15821597
///
15831598
/// assert_eq!(count["a"], 3);

branches/snap-stage3/src/libcollections/btree/node.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,11 @@ impl<T> Drop for RawItems<T> {
280280
#[unsafe_destructor]
281281
impl<K, V> Drop for Node<K, V> {
282282
fn drop(&mut self) {
283-
if self.keys.is_null() {
283+
if self.keys.is_null() ||
284+
(unsafe { self.keys.get() as *const K as usize == mem::POST_DROP_USIZE })
285+
{
284286
// Since we have #[unsafe_no_drop_flag], we have to watch
285-
// out for a null value being stored in self.keys. (Using
287+
// out for the sentinel value being stored in self.keys. (Using
286288
// null is technically a violation of the `Unique`
287289
// requirements, though.)
288290
return;

branches/snap-stage3/src/libcollections/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#![feature(unicode)]
3737
#![feature(unsafe_destructor)]
3838
#![feature(unique)]
39-
#![feature(unsafe_no_drop_flag)]
39+
#![feature(unsafe_no_drop_flag, filling_drop)]
4040
#![feature(step_by)]
4141
#![feature(str_char)]
4242
#![feature(convert)]

branches/snap-stage3/src/libcollections/vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ impl<T> Drop for Vec<T> {
16941694
fn drop(&mut self) {
16951695
// This is (and should always remain) a no-op if the fields are
16961696
// zeroed (when moving out, because of #[unsafe_no_drop_flag]).
1697-
if self.cap != 0 {
1697+
if self.cap != 0 && self.cap != mem::POST_DROP_USIZE {
16981698
unsafe {
16991699
for x in &*self {
17001700
ptr::read(x);
@@ -1977,7 +1977,7 @@ impl<'a, T> ExactSizeIterator for Drain<'a, T> {}
19771977
#[stable(feature = "rust1", since = "1.0.0")]
19781978
impl<'a, T> Drop for Drain<'a, T> {
19791979
fn drop(&mut self) {
1980-
// self.ptr == self.end == null if drop has already been called,
1980+
// self.ptr == self.end == mem::POST_DROP_USIZE if drop has already been called,
19811981
// so we can use #[unsafe_no_drop_flag].
19821982

19831983
// destroy the remaining elements

branches/snap-stage3/src/libcollections/vec_map.rs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -632,21 +632,12 @@ impl<V> VecMap<V> {
632632
/// ```
633633
/// # #![feature(collections)]
634634
/// use std::collections::VecMap;
635-
/// use std::collections::vec_map::Entry;
636635
///
637636
/// let mut count: VecMap<u32> = VecMap::new();
638637
///
639638
/// // count the number of occurrences of numbers in the vec
640-
/// for x in vec![1, 2, 1, 2, 3, 4, 1, 2, 4].iter() {
641-
/// match count.entry(*x) {
642-
/// Entry::Vacant(view) => {
643-
/// view.insert(1);
644-
/// },
645-
/// Entry::Occupied(mut view) => {
646-
/// let v = view.get_mut();
647-
/// *v += 1;
648-
/// },
649-
/// }
639+
/// for x in vec![1, 2, 1, 2, 3, 4, 1, 2, 4] {
640+
/// *count.entry(x).or_insert(0) += 1;
650641
/// }
651642
///
652643
/// assert_eq!(count[1], 3);
@@ -675,13 +666,37 @@ impl<V> VecMap<V> {
675666
impl<'a, V> Entry<'a, V> {
676667
#[unstable(feature = "collections",
677668
reason = "will soon be replaced by or_insert")]
669+
#[deprecated(since = "1.0",
670+
reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
678671
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
679672
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, V>> {
680673
match self {
681674
Occupied(entry) => Ok(entry.into_mut()),
682675
Vacant(entry) => Err(entry),
683676
}
684677
}
678+
679+
#[unstable(feature = "collections",
680+
reason = "matches entry v3 specification, waiting for dust to settle")]
681+
/// Ensures a value is in the entry by inserting the default if empty, and returns
682+
/// a mutable reference to the value in the entry.
683+
pub fn or_insert(self, default: V) -> &'a mut V {
684+
match self {
685+
Occupied(entry) => entry.into_mut(),
686+
Vacant(entry) => entry.insert(default),
687+
}
688+
}
689+
690+
#[unstable(feature = "collections",
691+
reason = "matches entry v3 specification, waiting for dust to settle")]
692+
/// Ensures a value is in the entry by inserting the result of the default function if empty,
693+
/// and returns a mutable reference to the value in the entry.
694+
pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
695+
match self {
696+
Occupied(entry) => entry.into_mut(),
697+
Vacant(entry) => entry.insert(default()),
698+
}
699+
}
685700
}
686701

687702
impl<'a, V> VacantEntry<'a, V> {

branches/snap-stage3/src/libcore/array.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use clone::Clone;
2020
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
21+
use convert::{AsRef, AsMut};
2122
use fmt;
2223
use hash::{Hash, self};
2324
use iter::IntoIterator;
@@ -53,6 +54,24 @@ macro_rules! array_impls {
5354
}
5455
}
5556

57+
#[unstable(feature = "array_as_ref",
58+
reason = "should ideally be implemented for all fixed-sized arrays")]
59+
impl<T> AsRef<[T]> for [T; $N] {
60+
#[inline]
61+
fn as_ref(&self) -> &[T] {
62+
&self[..]
63+
}
64+
}
65+
66+
#[unstable(feature = "array_as_ref",
67+
reason = "should ideally be implemented for all fixed-sized arrays")]
68+
impl<T> AsMut<[T]> for [T; $N] {
69+
#[inline]
70+
fn as_mut(&mut self) -> &mut [T] {
71+
&mut self[..]
72+
}
73+
}
74+
5675
#[stable(feature = "rust1", since = "1.0.0")]
5776
impl<T:Copy> Clone for [T; $N] {
5877
fn clone(&self) -> [T; $N] {

branches/snap-stage3/src/libcore/intrinsics.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,35 @@ extern "rust-intrinsic" {
191191
/// crate it is invoked in.
192192
pub fn type_id<T: ?Sized + 'static>() -> u64;
193193

194+
/// Create a value initialized to so that its drop flag,
195+
/// if any, says that it has been dropped.
196+
///
197+
/// `init_dropped` is unsafe because it returns a datum with all
198+
/// of its bytes set to the drop flag, which generally does not
199+
/// correspond to a valid value.
200+
///
201+
/// This intrinsic is likely to be deprecated in the future when
202+
/// Rust moves to non-zeroing dynamic drop (and thus removes the
203+
/// embedded drop flags that are being established by this
204+
/// intrinsic).
205+
#[cfg(not(stage0))]
206+
pub fn init_dropped<T>() -> T;
207+
194208
/// Create a value initialized to zero.
195209
///
196210
/// `init` is unsafe because it returns a zeroed-out datum,
197-
/// which is unsafe unless T is Copy.
211+
/// which is unsafe unless T is `Copy`. Also, even if T is
212+
/// `Copy`, an all-zero value may not correspond to any legitimate
213+
/// state for the type in question.
198214
pub fn init<T>() -> T;
199215

200216
/// Create an uninitialized value.
217+
///
218+
/// `uninit` is unsafe because there is no guarantee of what its
219+
/// contents are. In particular its drop-flag may be set to any
220+
/// state, which means it may claim either dropped or
221+
/// undropped. In the general case one must use `ptr::write` to
222+
/// initialize memory previous set to the result of `uninit`.
201223
pub fn uninit<T>() -> T;
202224

203225
/// Move a value out of scope without running drop glue.

0 commit comments

Comments
 (0)