Skip to content

Commit 99867ee

Browse files
authored
Auto merge of #35607 - alexcrichton:stabilize-1.12, r=brson
std: Stabilize APIs for the 1.12 release Stabilized * `Cell::as_ptr` * `RefCell::as_ptr` * `IpAddr::is_{unspecified,loopback,multicast}` * `Ipv6Addr::octets` * `LinkedList::contains` * `VecDeque::contains` * `ExitStatusExt::from_raw` - both on Unix and Windows * `Receiver::recv_timeout` * `RecvTimeoutError` * `BinaryHeap::peek_mut` * `PeekMut` * `iter::Product` * `iter::Sum` * `OccupiedEntry::remove_entry` * `VacantEntry::into_key` Deprecated * `Cell::as_unsafe_cell` * `RefCell::as_unsafe_cell` * `OccupiedEntry::remove_pair` Closes #27708 cc #27709 Closes #32313 Closes #32630 Closes #32713 Closes #34029 Closes #34392 Closes #34285 Closes #34529
2 parents 38fa82a + afeeade commit 99867ee

File tree

15 files changed

+94
-66
lines changed

15 files changed

+94
-66
lines changed

src/libcollections/binary_heap.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -223,27 +223,27 @@ pub struct BinaryHeap<T> {
223223
/// on `BinaryHeap`. See its documentation for details.
224224
///
225225
/// [`peek_mut()`]: struct.BinaryHeap.html#method.peek_mut
226-
#[unstable(feature = "binary_heap_peek_mut", issue = "34392")]
226+
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
227227
pub struct PeekMut<'a, T: 'a + Ord> {
228228
heap: &'a mut BinaryHeap<T>
229229
}
230230

231-
#[unstable(feature = "binary_heap_peek_mut", issue = "34392")]
231+
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
232232
impl<'a, T: Ord> Drop for PeekMut<'a, T> {
233233
fn drop(&mut self) {
234234
self.heap.sift_down(0);
235235
}
236236
}
237237

238-
#[unstable(feature = "binary_heap_peek_mut", issue = "34392")]
238+
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
239239
impl<'a, T: Ord> Deref for PeekMut<'a, T> {
240240
type Target = T;
241241
fn deref(&self) -> &T {
242242
&self.heap.data[0]
243243
}
244244
}
245245

246-
#[unstable(feature = "binary_heap_peek_mut", issue = "34392")]
246+
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
247247
impl<'a, T: Ord> DerefMut for PeekMut<'a, T> {
248248
fn deref_mut(&mut self) -> &mut T {
249249
&mut self.heap.data[0]
@@ -366,7 +366,6 @@ impl<T: Ord> BinaryHeap<T> {
366366
/// Basic usage:
367367
///
368368
/// ```
369-
/// #![feature(binary_heap_peek_mut)]
370369
/// use std::collections::BinaryHeap;
371370
/// let mut heap = BinaryHeap::new();
372371
/// assert!(heap.peek_mut().is_none());
@@ -380,7 +379,7 @@ impl<T: Ord> BinaryHeap<T> {
380379
/// }
381380
/// assert_eq!(heap.peek(), Some(&2));
382381
/// ```
383-
#[unstable(feature = "binary_heap_peek_mut", issue = "34392")]
382+
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
384383
pub fn peek_mut(&mut self) -> Option<PeekMut<T>> {
385384
if self.is_empty() {
386385
None

src/libcollections/btree/map.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -1981,8 +1981,6 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
19811981
/// # Examples
19821982
///
19831983
/// ```
1984-
/// #![feature(map_entry_recover_keys)]
1985-
///
19861984
/// use std::collections::BTreeMap;
19871985
/// use std::collections::btree_map::Entry;
19881986
///
@@ -1992,7 +1990,7 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
19921990
/// v.into_key();
19931991
/// }
19941992
/// ```
1995-
#[unstable(feature = "map_entry_recover_keys", issue = "34285")]
1993+
#[stable(feature = "map_entry_recover_keys2", since = "1.12.0")]
19961994
pub fn into_key(self) -> K {
19971995
self.key
19981996
}
@@ -2074,13 +2072,18 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
20742072
self.handle.reborrow().into_kv().0
20752073
}
20762074

2075+
/// Deprecated, renamed to `remove_entry`
2076+
#[unstable(feature = "map_entry_recover_keys", issue = "34285")]
2077+
#[rustc_deprecated(since = "1.12.0", reason = "renamed to `remove_entry`")]
2078+
pub fn remove_pair(self) -> (K, V) {
2079+
self.remove_entry()
2080+
}
2081+
20772082
/// Take ownership of the key and value from the map.
20782083
///
20792084
/// # Examples
20802085
///
20812086
/// ```
2082-
/// #![feature(map_entry_recover_keys)]
2083-
///
20842087
/// use std::collections::BTreeMap;
20852088
/// use std::collections::btree_map::Entry;
20862089
///
@@ -2089,14 +2092,14 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
20892092
///
20902093
/// if let Entry::Occupied(o) = map.entry("poneyland") {
20912094
/// // We delete the entry from the map.
2092-
/// o.remove_pair();
2095+
/// o.remove_entry();
20932096
/// }
20942097
///
20952098
/// // If now try to get the value, it will panic:
20962099
/// // println!("{}", map["poneyland"]);
20972100
/// ```
2098-
#[unstable(feature = "map_entry_recover_keys", issue = "34285")]
2099-
pub fn remove_pair(self) -> (K, V) {
2101+
#[stable(feature = "map_entry_recover_keys2", since = "1.12.0")]
2102+
pub fn remove_entry(self) -> (K, V) {
21002103
self.remove_kv()
21012104
}
21022105

src/libcollections/linked_list.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,6 @@ impl<T> LinkedList<T> {
379379
/// # Examples
380380
///
381381
/// ```
382-
/// #![feature(linked_list_contains)]
383-
///
384382
/// use std::collections::LinkedList;
385383
///
386384
/// let mut list: LinkedList<u32> = LinkedList::new();
@@ -392,8 +390,7 @@ impl<T> LinkedList<T> {
392390
/// assert_eq!(list.contains(&0), true);
393391
/// assert_eq!(list.contains(&10), false);
394392
/// ```
395-
#[unstable(feature = "linked_list_contains", reason = "recently added",
396-
issue = "32630")]
393+
#[stable(feature = "linked_list_contains", since = "1.12.0")]
397394
pub fn contains(&self, x: &T) -> bool
398395
where T: PartialEq<T>
399396
{

src/libcollections/vec_deque.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -939,8 +939,6 @@ impl<T> VecDeque<T> {
939939
/// # Examples
940940
///
941941
/// ```
942-
/// #![feature(vec_deque_contains)]
943-
///
944942
/// use std::collections::VecDeque;
945943
///
946944
/// let mut vector: VecDeque<u32> = VecDeque::new();
@@ -951,8 +949,7 @@ impl<T> VecDeque<T> {
951949
/// assert_eq!(vector.contains(&1), true);
952950
/// assert_eq!(vector.contains(&10), false);
953951
/// ```
954-
#[unstable(feature = "vec_deque_contains", reason = "recently added",
955-
issue = "32630")]
952+
#[stable(feature = "vec_deque_contains", since = "1.12.0")]
956953
pub fn contains(&self, x: &T) -> bool
957954
where T: PartialEq<T>
958955
{

src/libcollectionstest/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,20 @@
1111
#![deny(warnings)]
1212

1313
#![feature(binary_heap_extras)]
14-
#![feature(binary_heap_peek_mut)]
1514
#![feature(box_syntax)]
1615
#![feature(btree_range)]
1716
#![feature(collections)]
1817
#![feature(collections_bound)]
1918
#![feature(const_fn)]
2019
#![feature(fn_traits)]
2120
#![feature(enumset)]
22-
#![feature(linked_list_contains)]
2321
#![feature(pattern)]
2422
#![feature(rand)]
2523
#![feature(step_by)]
2624
#![feature(str_escape)]
2725
#![feature(test)]
2826
#![feature(unboxed_closures)]
2927
#![feature(unicode)]
30-
#![feature(vec_deque_contains)]
3128
#![feature(vec_into_iter_as_slice)]
3229

3330
extern crate collections;

src/libcore/cell.rs

+36
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,28 @@ impl<T:Copy> Cell<T> {
233233
/// ```
234234
#[inline]
235235
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
236+
#[rustc_deprecated(since = "1.12.0", reason = "renamed to as_ptr")]
236237
pub fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
237238
&self.value
238239
}
239240

241+
/// Returns a raw pointer to the underlying data in this cell.
242+
///
243+
/// # Examples
244+
///
245+
/// ```
246+
/// use std::cell::Cell;
247+
///
248+
/// let c = Cell::new(5);
249+
///
250+
/// let ptr = c.as_ptr();
251+
/// ```
252+
#[inline]
253+
#[stable(feature = "cell_as_ptr", since = "1.12.0")]
254+
pub fn as_ptr(&self) -> *mut T {
255+
self.value.get()
256+
}
257+
240258
/// Returns a mutable reference to the underlying data.
241259
///
242260
/// This call borrows `Cell` mutably (at compile-time) which guarantees
@@ -653,10 +671,28 @@ impl<T: ?Sized> RefCell<T> {
653671
/// ```
654672
#[inline]
655673
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
674+
#[rustc_deprecated(since = "1.12.0", reason = "renamed to as_ptr")]
656675
pub unsafe fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
657676
&self.value
658677
}
659678

679+
/// Returns a raw pointer to the underlying data in this cell.
680+
///
681+
/// # Examples
682+
///
683+
/// ```
684+
/// use std::cell::RefCell;
685+
///
686+
/// let c = RefCell::new(5);
687+
///
688+
/// let ptr = c.as_ptr();
689+
/// ```
690+
#[inline]
691+
#[stable(feature = "cell_as_ptr", since = "1.12.0")]
692+
pub fn as_ptr(&self) -> *mut T {
693+
self.value.get()
694+
}
695+
660696
/// Returns a mutable reference to the underlying data.
661697
///
662698
/// This call borrows `RefCell` mutably (at compile-time) so there is no

src/libcore/iter/traits.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,11 @@ impl<'a, I: ExactSizeIterator + ?Sized> ExactSizeIterator for &'a mut I {}
563563
/// implement the trait can be generated by the `sum` method. Like
564564
/// `FromIterator` this trait should rarely be called directly and instead
565565
/// interacted with through `Iterator::sum`.
566-
#[unstable(feature = "iter_arith_traits", issue = "34529")]
566+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
567567
pub trait Sum<A = Self>: Sized {
568568
/// Method which takes an iterator and generates `Self` from the elements by
569569
/// "summing up" the items.
570+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
570571
fn sum<I: Iterator<Item=A>>(iter: I) -> Self;
571572
}
572573

@@ -577,16 +578,17 @@ pub trait Sum<A = Self>: Sized {
577578
/// which implement the trait can be generated by the `product` method. Like
578579
/// `FromIterator` this trait should rarely be called directly and instead
579580
/// interacted with through `Iterator::product`.
580-
#[unstable(feature = "iter_arith_traits", issue = "34529")]
581+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
581582
pub trait Product<A = Self>: Sized {
582583
/// Method which takes an iterator and generates `Self` from the elements by
583584
/// multiplying the items.
585+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
584586
fn product<I: Iterator<Item=A>>(iter: I) -> Self;
585587
}
586588

587589
macro_rules! integer_sum_product {
588590
($($a:ident)*) => ($(
589-
#[unstable(feature = "iter_arith_traits", issue = "34529")]
591+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
590592
impl Sum for $a {
591593
fn sum<I: Iterator<Item=$a>>(iter: I) -> $a {
592594
iter.fold(0, |a, b| {
@@ -595,7 +597,7 @@ macro_rules! integer_sum_product {
595597
}
596598
}
597599

598-
#[unstable(feature = "iter_arith_traits", issue = "34529")]
600+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
599601
impl Product for $a {
600602
fn product<I: Iterator<Item=$a>>(iter: I) -> $a {
601603
iter.fold(1, |a, b| {
@@ -604,7 +606,7 @@ macro_rules! integer_sum_product {
604606
}
605607
}
606608

607-
#[unstable(feature = "iter_arith_traits", issue = "34529")]
609+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
608610
impl<'a> Sum<&'a $a> for $a {
609611
fn sum<I: Iterator<Item=&'a $a>>(iter: I) -> $a {
610612
iter.fold(0, |a, b| {
@@ -613,7 +615,7 @@ macro_rules! integer_sum_product {
613615
}
614616
}
615617

616-
#[unstable(feature = "iter_arith_traits", issue = "34529")]
618+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
617619
impl<'a> Product<&'a $a> for $a {
618620
fn product<I: Iterator<Item=&'a $a>>(iter: I) -> $a {
619621
iter.fold(1, |a, b| {
@@ -626,28 +628,28 @@ macro_rules! integer_sum_product {
626628

627629
macro_rules! float_sum_product {
628630
($($a:ident)*) => ($(
629-
#[unstable(feature = "iter_arith_traits", issue = "34529")]
631+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
630632
impl Sum for $a {
631633
fn sum<I: Iterator<Item=$a>>(iter: I) -> $a {
632634
iter.fold(0.0, |a, b| a + b)
633635
}
634636
}
635637

636-
#[unstable(feature = "iter_arith_traits", issue = "34529")]
638+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
637639
impl Product for $a {
638640
fn product<I: Iterator<Item=$a>>(iter: I) -> $a {
639641
iter.fold(1.0, |a, b| a * b)
640642
}
641643
}
642644

643-
#[unstable(feature = "iter_arith_traits", issue = "34529")]
645+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
644646
impl<'a> Sum<&'a $a> for $a {
645647
fn sum<I: Iterator<Item=&'a $a>>(iter: I) -> $a {
646648
iter.fold(0.0, |a, b| a + *b)
647649
}
648650
}
649651

650-
#[unstable(feature = "iter_arith_traits", issue = "34529")]
652+
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
651653
impl<'a> Product<&'a $a> for $a {
652654
fn product<I: Iterator<Item=&'a $a>>(iter: I) -> $a {
653655
iter.fold(1.0, |a, b| a * *b)

src/libcoretest/cell.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,21 @@ fn ref_mut_map_accessor() {
176176
}
177177

178178
#[test]
179-
fn as_unsafe_cell() {
179+
fn as_ptr() {
180180
let c1: Cell<usize> = Cell::new(0);
181181
c1.set(1);
182-
assert_eq!(1, unsafe { *c1.as_unsafe_cell().get() });
182+
assert_eq!(1, unsafe { *c1.as_ptr() });
183183

184184
let c2: Cell<usize> = Cell::new(0);
185-
unsafe { *c2.as_unsafe_cell().get() = 1; }
185+
unsafe { *c2.as_ptr() = 1; }
186186
assert_eq!(1, c2.get());
187187

188188
let r1: RefCell<usize> = RefCell::new(0);
189189
*r1.borrow_mut() = 1;
190-
assert_eq!(1, unsafe { *r1.as_unsafe_cell().get() });
190+
assert_eq!(1, unsafe { *r1.as_ptr() });
191191

192192
let r2: RefCell<usize> = RefCell::new(0);
193-
unsafe { *r2.as_unsafe_cell().get() = 1; }
193+
unsafe { *r2.as_ptr() = 1; }
194194
assert_eq!(1, *r2.borrow());
195195
}
196196

src/libcoretest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#![deny(warnings)]
1212

13-
#![feature(as_unsafe_cell)]
1413
#![feature(borrow_state)]
1514
#![feature(box_syntax)]
1615
#![feature(cell_extras)]

0 commit comments

Comments
 (0)