Skip to content

Commit 1f965cc

Browse files
committed
Auto merge of #38369 - aturon:stab-1.15, r=alexcrichton
Library stabilizations/deprecations for 1.15 release Stabilized: - `std::iter::Iterator::{min_by, max_by}` - `std::os::*::fs::FileExt` - `std::sync::atomic::Atomic*::{get_mut, into_inner}` - `std::vec::IntoIter::{as_slice, as_mut_slice}` - `std::sync::mpsc::Receiver::try_iter` - `std::os::unix::process::CommandExt::before_exec` - `std::rc::Rc::{strong_count, weak_count}` - `std::sync::Arc::{strong_count, weak_count}` - `std::char::{encode_utf8, encode_utf16}` - `std::cell::Ref::clone` - `std::io::Take::into_inner` Deprecated: - `std::rc::Rc::{would_unwrap, is_unique}` - `std::cell::RefCell::borrow_state` Closes #23755 Closes #27733 Closes #27746 Closes #27784 Closes #28356 Closes #31398 Closes #34931 Closes #35601 Closes #35603 Closes #35918 Closes #36105
2 parents 8327b5a + 9a5cef4 commit 1f965cc

File tree

27 files changed

+83
-149
lines changed

27 files changed

+83
-149
lines changed

src/liballoc/arc.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,6 @@ impl<T: ?Sized> Arc<T> {
392392
/// # Examples
393393
///
394394
/// ```
395-
/// #![feature(arc_counts)]
396-
///
397395
/// use std::sync::Arc;
398396
///
399397
/// let five = Arc::new(5);
@@ -404,8 +402,7 @@ impl<T: ?Sized> Arc<T> {
404402
/// assert_eq!(1, Arc::weak_count(&five));
405403
/// ```
406404
#[inline]
407-
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy",
408-
issue = "28356")]
405+
#[stable(feature = "arc_counts", since = "1.15.0")]
409406
pub fn weak_count(this: &Self) -> usize {
410407
this.inner().weak.load(SeqCst) - 1
411408
}
@@ -421,8 +418,6 @@ impl<T: ?Sized> Arc<T> {
421418
/// # Examples
422419
///
423420
/// ```
424-
/// #![feature(arc_counts)]
425-
///
426421
/// use std::sync::Arc;
427422
///
428423
/// let five = Arc::new(5);
@@ -433,8 +428,7 @@ impl<T: ?Sized> Arc<T> {
433428
/// assert_eq!(2, Arc::strong_count(&five));
434429
/// ```
435430
#[inline]
436-
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy",
437-
issue = "28356")]
431+
#[stable(feature = "arc_counts", since = "1.15.0")]
438432
pub fn strong_count(this: &Self) -> usize {
439433
this.inner().strong.load(SeqCst)
440434
}

src/liballoc/rc.rs

+7-39
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<T> Rc<T> {
320320
#[inline]
321321
#[stable(feature = "rc_unique", since = "1.4.0")]
322322
pub fn try_unwrap(this: Self) -> Result<T, Self> {
323-
if Rc::would_unwrap(&this) {
323+
if Rc::strong_count(&this) == 1 {
324324
unsafe {
325325
let val = ptr::read(&*this); // copy the contained object
326326

@@ -343,26 +343,10 @@ impl<T> Rc<T> {
343343
///
344344
/// [try_unwrap]: struct.Rc.html#method.try_unwrap
345345
/// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
346-
///
347-
/// # Examples
348-
///
349-
/// ```
350-
/// #![feature(rc_would_unwrap)]
351-
///
352-
/// use std::rc::Rc;
353-
///
354-
/// let x = Rc::new(3);
355-
/// assert!(Rc::would_unwrap(&x));
356-
/// assert_eq!(Rc::try_unwrap(x), Ok(3));
357-
///
358-
/// let x = Rc::new(4);
359-
/// let _y = x.clone();
360-
/// assert!(!Rc::would_unwrap(&x));
361-
/// assert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
362-
/// ```
363346
#[unstable(feature = "rc_would_unwrap",
364347
reason = "just added for niche usecase",
365348
issue = "28356")]
349+
#[rustc_deprecated(since = "1.15.0", reason = "too niche; use `strong_count` instead")]
366350
pub fn would_unwrap(this: &Self) -> bool {
367351
Rc::strong_count(&this) == 1
368352
}
@@ -482,8 +466,6 @@ impl<T: ?Sized> Rc<T> {
482466
/// # Examples
483467
///
484468
/// ```
485-
/// #![feature(rc_counts)]
486-
///
487469
/// use std::rc::Rc;
488470
///
489471
/// let five = Rc::new(5);
@@ -492,8 +474,7 @@ impl<T: ?Sized> Rc<T> {
492474
/// assert_eq!(1, Rc::weak_count(&five));
493475
/// ```
494476
#[inline]
495-
#[unstable(feature = "rc_counts", reason = "not clearly useful",
496-
issue = "28356")]
477+
#[stable(feature = "rc_counts", since = "1.15.0")]
497478
pub fn weak_count(this: &Self) -> usize {
498479
this.weak() - 1
499480
}
@@ -503,8 +484,6 @@ impl<T: ?Sized> Rc<T> {
503484
/// # Examples
504485
///
505486
/// ```
506-
/// #![feature(rc_counts)]
507-
///
508487
/// use std::rc::Rc;
509488
///
510489
/// let five = Rc::new(5);
@@ -513,8 +492,7 @@ impl<T: ?Sized> Rc<T> {
513492
/// assert_eq!(2, Rc::strong_count(&five));
514493
/// ```
515494
#[inline]
516-
#[unstable(feature = "rc_counts", reason = "not clearly useful",
517-
issue = "28356")]
495+
#[stable(feature = "rc_counts", since = "1.15.0")]
518496
pub fn strong_count(this: &Self) -> usize {
519497
this.strong()
520498
}
@@ -523,21 +501,11 @@ impl<T: ?Sized> Rc<T> {
523501
/// this inner value.
524502
///
525503
/// [weak]: struct.Weak.html
526-
///
527-
/// # Examples
528-
///
529-
/// ```
530-
/// #![feature(rc_counts)]
531-
///
532-
/// use std::rc::Rc;
533-
///
534-
/// let five = Rc::new(5);
535-
///
536-
/// assert!(Rc::is_unique(&five));
537-
/// ```
538504
#[inline]
539-
#[unstable(feature = "rc_counts", reason = "uniqueness has unclear meaning",
505+
#[unstable(feature = "is_unique", reason = "uniqueness has unclear meaning",
540506
issue = "28356")]
507+
#[rustc_deprecated(since = "1.15.0",
508+
reason = "too niche; use `strong_count` and `weak_count` instead")]
541509
pub fn is_unique(this: &Self) -> bool {
542510
Rc::weak_count(this) == 0 && Rc::strong_count(this) == 1
543511
}

src/libcollections/vec.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1902,14 +1902,13 @@ impl<T> IntoIter<T> {
19021902
/// # Examples
19031903
///
19041904
/// ```
1905-
/// # #![feature(vec_into_iter_as_slice)]
19061905
/// let vec = vec!['a', 'b', 'c'];
19071906
/// let mut into_iter = vec.into_iter();
19081907
/// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
19091908
/// let _ = into_iter.next().unwrap();
19101909
/// assert_eq!(into_iter.as_slice(), &['b', 'c']);
19111910
/// ```
1912-
#[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
1911+
#[stable(feature = "vec_into_iter_as_slice", since = "1.15.0")]
19131912
pub fn as_slice(&self) -> &[T] {
19141913
unsafe {
19151914
slice::from_raw_parts(self.ptr, self.len())
@@ -1921,7 +1920,6 @@ impl<T> IntoIter<T> {
19211920
/// # Examples
19221921
///
19231922
/// ```
1924-
/// # #![feature(vec_into_iter_as_slice)]
19251923
/// let vec = vec!['a', 'b', 'c'];
19261924
/// let mut into_iter = vec.into_iter();
19271925
/// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
@@ -1930,7 +1928,7 @@ impl<T> IntoIter<T> {
19301928
/// assert_eq!(into_iter.next().unwrap(), 'b');
19311929
/// assert_eq!(into_iter.next().unwrap(), 'z');
19321930
/// ```
1933-
#[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
1931+
#[stable(feature = "vec_into_iter_as_slice", since = "1.15.0")]
19341932
pub fn as_mut_slice(&self) -> &mut [T] {
19351933
unsafe {
19361934
slice::from_raw_parts_mut(self.ptr as *mut T, self.len())

src/libcollectionstest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#![feature(test)]
3030
#![feature(unboxed_closures)]
3131
#![feature(unicode)]
32-
#![feature(vec_into_iter_as_slice)]
3332

3433
extern crate collections;
3534
extern crate test;

src/libcore/cell.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ pub struct RefCell<T: ?Sized> {
393393
/// An enumeration of values returned from the `state` method on a `RefCell<T>`.
394394
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
395395
#[unstable(feature = "borrow_state", issue = "27733")]
396+
#[rustc_deprecated(since = "1.15.0", reason = "use `try_borrow` instead")]
397+
#[allow(deprecated)]
396398
pub enum BorrowState {
397399
/// The cell is currently being read, there is at least one active `borrow`.
398400
Reading,
@@ -511,6 +513,8 @@ impl<T: ?Sized> RefCell<T> {
511513
/// }
512514
/// ```
513515
#[unstable(feature = "borrow_state", issue = "27733")]
516+
#[rustc_deprecated(since = "1.15.0", reason = "use `try_borrow` instead")]
517+
#[allow(deprecated)]
514518
#[inline]
515519
pub fn borrow_state(&self) -> BorrowState {
516520
match self.borrow.get() {
@@ -888,9 +892,7 @@ impl<'b, T: ?Sized> Ref<'b, T> {
888892
/// `Ref::clone(...)`. A `Clone` implementation or a method would interfere
889893
/// with the widespread use of `r.borrow().clone()` to clone the contents of
890894
/// a `RefCell`.
891-
#[unstable(feature = "cell_extras",
892-
reason = "likely to be moved to a method, pending language changes",
893-
issue = "27746")]
895+
#[stable(feature = "cell_extras", since = "1.15.0")]
894896
#[inline]
895897
pub fn clone(orig: &Ref<'b, T>) -> Ref<'b, T> {
896898
Ref {

src/libcore/char.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,9 @@ pub trait CharExt {
327327
fn len_utf8(self) -> usize;
328328
#[stable(feature = "core", since = "1.6.0")]
329329
fn len_utf16(self) -> usize;
330-
#[unstable(feature = "unicode", issue = "27784")]
330+
#[stable(feature = "unicode_encode_char", since = "1.15.0")]
331331
fn encode_utf8(self, dst: &mut [u8]) -> &mut str;
332-
#[unstable(feature = "unicode", issue = "27784")]
332+
#[stable(feature = "unicode_encode_char", since = "1.15.0")]
333333
fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16];
334334
}
335335

src/libcore/fmt/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414

15-
use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut, BorrowState};
15+
use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut};
1616
use marker::PhantomData;
1717
use mem;
1818
use num::flt2dec;
@@ -1634,13 +1634,13 @@ impl<T: Copy + Debug> Debug for Cell<T> {
16341634
#[stable(feature = "rust1", since = "1.0.0")]
16351635
impl<T: ?Sized + Debug> Debug for RefCell<T> {
16361636
fn fmt(&self, f: &mut Formatter) -> Result {
1637-
match self.borrow_state() {
1638-
BorrowState::Unused | BorrowState::Reading => {
1637+
match self.try_borrow() {
1638+
Ok(borrow) => {
16391639
f.debug_struct("RefCell")
1640-
.field("value", &self.borrow())
1640+
.field("value", &borrow)
16411641
.finish()
16421642
}
1643-
BorrowState::Writing => {
1643+
Err(_) => {
16441644
f.debug_struct("RefCell")
16451645
.field("value", &"<borrowed>")
16461646
.finish()

src/libcore/iter/iterator.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1696,12 +1696,11 @@ pub trait Iterator {
16961696
/// # Examples
16971697
///
16981698
/// ```
1699-
/// #![feature(iter_max_by)]
17001699
/// let a = [-3_i32, 0, 1, 5, -10];
17011700
/// assert_eq!(*a.iter().max_by(|x, y| x.cmp(y)).unwrap(), 5);
17021701
/// ```
17031702
#[inline]
1704-
#[unstable(feature = "iter_max_by", issue="36105")]
1703+
#[stable(feature = "iter_max_by", since = "1.15.0")]
17051704
fn max_by<F>(self, mut compare: F) -> Option<Self::Item>
17061705
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,
17071706
{
@@ -1746,12 +1745,11 @@ pub trait Iterator {
17461745
/// # Examples
17471746
///
17481747
/// ```
1749-
/// #![feature(iter_min_by)]
17501748
/// let a = [-3_i32, 0, 1, 5, -10];
17511749
/// assert_eq!(*a.iter().min_by(|x, y| x.cmp(y)).unwrap(), -10);
17521750
/// ```
17531751
#[inline]
1754-
#[unstable(feature = "iter_min_by", issue="36105")]
1752+
#[stable(feature = "iter_min_by", since = "1.15.0")]
17551753
fn min_by<F>(self, mut compare: F) -> Option<Self::Item>
17561754
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,
17571755
{

src/libcore/sync/atomic.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ impl AtomicBool {
203203
/// # Examples
204204
///
205205
/// ```
206-
/// #![feature(atomic_access)]
207206
/// use std::sync::atomic::{AtomicBool, Ordering};
208207
///
209208
/// let mut some_bool = AtomicBool::new(true);
@@ -212,7 +211,7 @@ impl AtomicBool {
212211
/// assert_eq!(some_bool.load(Ordering::SeqCst), false);
213212
/// ```
214213
#[inline]
215-
#[unstable(feature = "atomic_access", issue = "35603")]
214+
#[stable(feature = "atomic_access", since = "1.15.0")]
216215
pub fn get_mut(&mut self) -> &mut bool {
217216
unsafe { &mut *(self.v.get() as *mut bool) }
218217
}
@@ -225,14 +224,13 @@ impl AtomicBool {
225224
/// # Examples
226225
///
227226
/// ```
228-
/// #![feature(atomic_access)]
229227
/// use std::sync::atomic::AtomicBool;
230228
///
231229
/// let some_bool = AtomicBool::new(true);
232230
/// assert_eq!(some_bool.into_inner(), true);
233231
/// ```
234232
#[inline]
235-
#[unstable(feature = "atomic_access", issue = "35603")]
233+
#[stable(feature = "atomic_access", since = "1.15.0")]
236234
pub fn into_inner(self) -> bool {
237235
unsafe { self.v.into_inner() != 0 }
238236
}
@@ -588,15 +586,14 @@ impl<T> AtomicPtr<T> {
588586
/// # Examples
589587
///
590588
/// ```
591-
/// #![feature(atomic_access)]
592589
/// use std::sync::atomic::{AtomicPtr, Ordering};
593590
///
594591
/// let mut atomic_ptr = AtomicPtr::new(&mut 10);
595592
/// *atomic_ptr.get_mut() = &mut 5;
596593
/// assert_eq!(unsafe { *atomic_ptr.load(Ordering::SeqCst) }, 5);
597594
/// ```
598595
#[inline]
599-
#[unstable(feature = "atomic_access", issue = "35603")]
596+
#[stable(feature = "atomic_access", since = "1.15.0")]
600597
pub fn get_mut(&mut self) -> &mut *mut T {
601598
unsafe { &mut *self.p.get() }
602599
}
@@ -609,14 +606,13 @@ impl<T> AtomicPtr<T> {
609606
/// # Examples
610607
///
611608
/// ```
612-
/// #![feature(atomic_access)]
613609
/// use std::sync::atomic::AtomicPtr;
614610
///
615611
/// let atomic_ptr = AtomicPtr::new(&mut 5);
616612
/// assert_eq!(unsafe { *atomic_ptr.into_inner() }, 5);
617613
/// ```
618614
#[inline]
619-
#[unstable(feature = "atomic_access", issue = "35603")]
615+
#[stable(feature = "atomic_access", since = "1.15.0")]
620616
pub fn into_inner(self) -> *mut T {
621617
unsafe { self.p.into_inner() }
622618
}
@@ -883,7 +879,6 @@ macro_rules! atomic_int {
883879
/// # Examples
884880
///
885881
/// ```
886-
/// #![feature(atomic_access)]
887882
/// use std::sync::atomic::{AtomicIsize, Ordering};
888883
///
889884
/// let mut some_isize = AtomicIsize::new(10);
@@ -905,7 +900,6 @@ macro_rules! atomic_int {
905900
/// # Examples
906901
///
907902
/// ```
908-
/// #![feature(atomic_access)]
909903
/// use std::sync::atomic::AtomicIsize;
910904
///
911905
/// let some_isize = AtomicIsize::new(5);
@@ -1261,15 +1255,15 @@ atomic_int!{
12611255
stable(feature = "rust1", since = "1.0.0"),
12621256
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
12631257
stable(feature = "atomic_debug", since = "1.3.0"),
1264-
unstable(feature = "atomic_access", issue = "35603"),
1258+
stable(feature = "atomic_access", since = "1.15.0"),
12651259
isize AtomicIsize ATOMIC_ISIZE_INIT
12661260
}
12671261
#[cfg(target_has_atomic = "ptr")]
12681262
atomic_int!{
12691263
stable(feature = "rust1", since = "1.0.0"),
12701264
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
12711265
stable(feature = "atomic_debug", since = "1.3.0"),
1272-
unstable(feature = "atomic_access", issue = "35603"),
1266+
stable(feature = "atomic_access", since = "1.15.0"),
12731267
usize AtomicUsize ATOMIC_USIZE_INIT
12741268
}
12751269

0 commit comments

Comments
 (0)