Skip to content

Commit 12ec515

Browse files
committed
---
yaml --- r: 195163 b: refs/heads/tmp c: 8eb918e h: refs/heads/master i: 195161: c30e9fc 195159: b34d450 v: v3
1 parent dc9de08 commit 12ec515

Some content is hidden

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

82 files changed

+2025
-380
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: d8be84eb4499e21bd98a3500c8760540996df23b
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: c153fc1da1c16fd7673aa70af06652f9161bf9e7
37+
refs/heads/tmp: 8eb918e9701f927fde42d0f2ea0ab4438bbd6c79
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3939
refs/tags/homu-tmp: 53a183f0274316596bf9405944d4f0468d8c93e4
4040
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/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/tmp/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/tmp/src/liballoc/boxed.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,13 @@ pub trait BoxAny {
244244
/// Returns the boxed value if it is of type `T`, or
245245
/// `Err(Self)` if it isn't.
246246
#[stable(feature = "rust1", since = "1.0.0")]
247-
fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>>;
247+
fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>>;
248248
}
249249

250250
#[stable(feature = "rust1", since = "1.0.0")]
251251
impl BoxAny for Box<Any> {
252252
#[inline]
253-
fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
253+
fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
254254
if self.is::<T>() {
255255
unsafe {
256256
// Get the raw representation of the trait object
@@ -270,7 +270,7 @@ impl BoxAny for Box<Any> {
270270
#[stable(feature = "rust1", since = "1.0.0")]
271271
impl BoxAny for Box<Any+Send> {
272272
#[inline]
273-
fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
273+
fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
274274
<Box<Any>>::downcast(self)
275275
}
276276
}

branches/tmp/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/tmp/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/tmp/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/tmp/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/tmp/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/tmp/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/tmp/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/tmp/src/libcore/any.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
//! }
5656
//!
5757
//! // This function wants to log its parameter out prior to doing work with it.
58-
//! fn do_work<T: Debug + 'static>(value: &T) {
58+
//! fn do_work<T: Any + Debug>(value: &T) {
5959
//! log(value);
6060
//! // ...do some other work
6161
//! }
@@ -76,7 +76,7 @@ use mem::transmute;
7676
use option::Option::{self, Some, None};
7777
use raw::TraitObject;
7878
use intrinsics;
79-
use marker::Sized;
79+
use marker::{Reflect, Sized};
8080

8181
///////////////////////////////////////////////////////////////////////////////
8282
// Any trait
@@ -88,14 +88,16 @@ use marker::Sized;
8888
///
8989
/// [mod]: ../index.html
9090
#[stable(feature = "rust1", since = "1.0.0")]
91-
pub trait Any: 'static {
91+
pub trait Any: Reflect + 'static {
9292
/// Get the `TypeId` of `self`
9393
#[unstable(feature = "core",
9494
reason = "this method will likely be replaced by an associated static")]
9595
fn get_type_id(&self) -> TypeId;
9696
}
9797

98-
impl<T: 'static> Any for T {
98+
impl<T> Any for T
99+
where T: Reflect + 'static
100+
{
99101
fn get_type_id(&self) -> TypeId { TypeId::of::<T>() }
100102
}
101103

@@ -107,7 +109,7 @@ impl Any {
107109
/// Returns true if the boxed type is the same as `T`
108110
#[stable(feature = "rust1", since = "1.0.0")]
109111
#[inline]
110-
pub fn is<T: 'static>(&self) -> bool {
112+
pub fn is<T: Any>(&self) -> bool {
111113
// Get TypeId of the type this function is instantiated with
112114
let t = TypeId::of::<T>();
113115

@@ -122,7 +124,7 @@ impl Any {
122124
/// `None` if it isn't.
123125
#[stable(feature = "rust1", since = "1.0.0")]
124126
#[inline]
125-
pub fn downcast_ref<T: 'static>(&self) -> Option<&T> {
127+
pub fn downcast_ref<T: Any>(&self) -> Option<&T> {
126128
if self.is::<T>() {
127129
unsafe {
128130
// Get the raw representation of the trait object
@@ -140,7 +142,7 @@ impl Any {
140142
/// `None` if it isn't.
141143
#[stable(feature = "rust1", since = "1.0.0")]
142144
#[inline]
143-
pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> {
145+
pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> {
144146
if self.is::<T>() {
145147
unsafe {
146148
// Get the raw representation of the trait object
@@ -159,21 +161,21 @@ impl Any+Send {
159161
/// Forwards to the method defined on the type `Any`.
160162
#[stable(feature = "rust1", since = "1.0.0")]
161163
#[inline]
162-
pub fn is<T: 'static>(&self) -> bool {
164+
pub fn is<T: Any>(&self) -> bool {
163165
Any::is::<T>(self)
164166
}
165167

166168
/// Forwards to the method defined on the type `Any`.
167169
#[stable(feature = "rust1", since = "1.0.0")]
168170
#[inline]
169-
pub fn downcast_ref<T: 'static>(&self) -> Option<&T> {
171+
pub fn downcast_ref<T: Any>(&self) -> Option<&T> {
170172
Any::downcast_ref::<T>(self)
171173
}
172174

173175
/// Forwards to the method defined on the type `Any`.
174176
#[stable(feature = "rust1", since = "1.0.0")]
175177
#[inline]
176-
pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> {
178+
pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> {
177179
Any::downcast_mut::<T>(self)
178180
}
179181
}
@@ -202,7 +204,7 @@ impl TypeId {
202204
/// instantiated with
203205
#[unstable(feature = "core",
204206
reason = "may grow a `Reflect` bound soon via marker traits")]
205-
pub fn of<T: ?Sized + 'static>() -> TypeId {
207+
pub fn of<T: ?Sized + Any>() -> TypeId {
206208
TypeId {
207209
t: unsafe { intrinsics::type_id::<T>() },
208210
}

branches/tmp/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] {

0 commit comments

Comments
 (0)