Skip to content

Commit bfc49b1

Browse files
committed
Auto merge of #40538 - aturon:stab-1.17, r=alexcrichton
Library stabilizations for 1.17 Details of the stabilizations are available in the commits. Includes only library stabilizations; there are a couple of compiler stabilizations that should also be done for 1.17. Will need a beta backport, which I will create after approval. r? @alexcrichton
2 parents 4853584 + 1241a88 commit bfc49b1

File tree

20 files changed

+77
-113
lines changed

20 files changed

+77
-113
lines changed

src/liballoc/arc.rs

+13-18
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,15 @@ impl<T> Arc<T> {
287287
/// # Examples
288288
///
289289
/// ```
290-
/// #![feature(rc_raw)]
291-
///
292290
/// use std::sync::Arc;
293291
///
294292
/// let x = Arc::new(10);
295293
/// let x_ptr = Arc::into_raw(x);
296294
/// assert_eq!(unsafe { *x_ptr }, 10);
297295
/// ```
298-
#[unstable(feature = "rc_raw", issue = "37197")]
299-
pub fn into_raw(this: Self) -> *mut T {
300-
let ptr = unsafe { &mut (**this.ptr).data as *mut _ };
296+
#[stable(feature = "rc_raw", since = "1.17.0")]
297+
pub fn into_raw(this: Self) -> *const T {
298+
let ptr = unsafe { &(**this.ptr).data as *const _ };
301299
mem::forget(this);
302300
ptr
303301
}
@@ -315,8 +313,6 @@ impl<T> Arc<T> {
315313
/// # Examples
316314
///
317315
/// ```
318-
/// #![feature(rc_raw)]
319-
///
320316
/// use std::sync::Arc;
321317
///
322318
/// let x = Arc::new(10);
@@ -332,11 +328,14 @@ impl<T> Arc<T> {
332328
///
333329
/// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
334330
/// ```
335-
#[unstable(feature = "rc_raw", issue = "37197")]
336-
pub unsafe fn from_raw(ptr: *mut T) -> Self {
331+
#[stable(feature = "rc_raw", since = "1.17.0")]
332+
pub unsafe fn from_raw(ptr: *const T) -> Self {
337333
// To find the corresponding pointer to the `ArcInner` we need to subtract the offset of the
338334
// `data` field from the pointer.
339-
Arc { ptr: Shared::new((ptr as *mut u8).offset(-offset_of!(ArcInner<T>, data)) as *mut _) }
335+
let ptr = (ptr as *const u8).offset(-offset_of!(ArcInner<T>, data));
336+
Arc {
337+
ptr: Shared::new(ptr as *const _),
338+
}
340339
}
341340
}
342341

@@ -448,7 +447,7 @@ impl<T: ?Sized> Arc<T> {
448447
// Non-inlined part of `drop`.
449448
#[inline(never)]
450449
unsafe fn drop_slow(&mut self) {
451-
let ptr = *self.ptr;
450+
let ptr = self.ptr.as_mut_ptr();
452451

453452
// Destroy the data at this time, even though we may not free the box
454453
// allocation itself (there may still be weak pointers lying around).
@@ -461,17 +460,13 @@ impl<T: ?Sized> Arc<T> {
461460
}
462461

463462
#[inline]
464-
#[unstable(feature = "ptr_eq",
465-
reason = "newly added",
466-
issue = "36497")]
463+
#[stable(feature = "ptr_eq", since = "1.17.0")]
467464
/// Returns true if the two `Arc`s point to the same value (not
468465
/// just values that compare as equal).
469466
///
470467
/// # Examples
471468
///
472469
/// ```
473-
/// #![feature(ptr_eq)]
474-
///
475470
/// use std::sync::Arc;
476471
///
477472
/// let five = Arc::new(5);
@@ -628,7 +623,7 @@ impl<T: Clone> Arc<T> {
628623
// As with `get_mut()`, the unsafety is ok because our reference was
629624
// either unique to begin with, or became one upon cloning the contents.
630625
unsafe {
631-
let inner = &mut **this.ptr;
626+
let inner = &mut *this.ptr.as_mut_ptr();
632627
&mut inner.data
633628
}
634629
}
@@ -671,7 +666,7 @@ impl<T: ?Sized> Arc<T> {
671666
// the Arc itself to be `mut`, so we're returning the only possible
672667
// reference to the inner data.
673668
unsafe {
674-
let inner = &mut **this.ptr;
669+
let inner = &mut *this.ptr.as_mut_ptr();
675670
Some(&mut inner.data)
676671
}
677672
} else {

src/liballoc/rc.rs

+10-18
Original file line numberDiff line numberDiff line change
@@ -364,17 +364,15 @@ impl<T> Rc<T> {
364364
/// # Examples
365365
///
366366
/// ```
367-
/// #![feature(rc_raw)]
368-
///
369367
/// use std::rc::Rc;
370368
///
371369
/// let x = Rc::new(10);
372370
/// let x_ptr = Rc::into_raw(x);
373371
/// assert_eq!(unsafe { *x_ptr }, 10);
374372
/// ```
375-
#[unstable(feature = "rc_raw", issue = "37197")]
376-
pub fn into_raw(this: Self) -> *mut T {
377-
let ptr = unsafe { &mut (**this.ptr).value as *mut _ };
373+
#[stable(feature = "rc_raw", since = "1.17.0")]
374+
pub fn into_raw(this: Self) -> *const T {
375+
let ptr = unsafe { &mut (*this.ptr.as_mut_ptr()).value as *const _ };
378376
mem::forget(this);
379377
ptr
380378
}
@@ -392,8 +390,6 @@ impl<T> Rc<T> {
392390
/// # Examples
393391
///
394392
/// ```
395-
/// #![feature(rc_raw)]
396-
///
397393
/// use std::rc::Rc;
398394
///
399395
/// let x = Rc::new(10);
@@ -409,11 +405,11 @@ impl<T> Rc<T> {
409405
///
410406
/// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
411407
/// ```
412-
#[unstable(feature = "rc_raw", issue = "37197")]
413-
pub unsafe fn from_raw(ptr: *mut T) -> Self {
408+
#[stable(feature = "rc_raw", since = "1.17.0")]
409+
pub unsafe fn from_raw(ptr: *const T) -> Self {
414410
// To find the corresponding pointer to the `RcBox` we need to subtract the offset of the
415411
// `value` field from the pointer.
416-
Rc { ptr: Shared::new((ptr as *mut u8).offset(-offset_of!(RcBox<T>, value)) as *mut _) }
412+
Rc { ptr: Shared::new((ptr as *const u8).offset(-offset_of!(RcBox<T>, value)) as *const _) }
417413
}
418414
}
419415

@@ -543,25 +539,21 @@ impl<T: ?Sized> Rc<T> {
543539
#[stable(feature = "rc_unique", since = "1.4.0")]
544540
pub fn get_mut(this: &mut Self) -> Option<&mut T> {
545541
if Rc::is_unique(this) {
546-
let inner = unsafe { &mut **this.ptr };
542+
let inner = unsafe { &mut *this.ptr.as_mut_ptr() };
547543
Some(&mut inner.value)
548544
} else {
549545
None
550546
}
551547
}
552548

553549
#[inline]
554-
#[unstable(feature = "ptr_eq",
555-
reason = "newly added",
556-
issue = "36497")]
550+
#[stable(feature = "ptr_eq", since = "1.17.0")]
557551
/// Returns true if the two `Rc`s point to the same value (not
558552
/// just values that compare as equal).
559553
///
560554
/// # Examples
561555
///
562556
/// ```
563-
/// #![feature(ptr_eq)]
564-
///
565557
/// use std::rc::Rc;
566558
///
567559
/// let five = Rc::new(5);
@@ -631,7 +623,7 @@ impl<T: Clone> Rc<T> {
631623
// reference count is guaranteed to be 1 at this point, and we required
632624
// the `Rc<T>` itself to be `mut`, so we're returning the only possible
633625
// reference to the inner value.
634-
let inner = unsafe { &mut **this.ptr };
626+
let inner = unsafe { &mut *this.ptr.as_mut_ptr() };
635627
&mut inner.value
636628
}
637629
}
@@ -677,7 +669,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc<T> {
677669
/// ```
678670
fn drop(&mut self) {
679671
unsafe {
680-
let ptr = *self.ptr;
672+
let ptr = self.ptr.as_mut_ptr();
681673

682674
self.dec_strong();
683675
if self.strong() == 0 {

src/libcollections/btree/map.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ pub struct ValuesMut<'a, K: 'a, V: 'a> {
338338
}
339339

340340
/// An iterator over a sub-range of BTreeMap's entries.
341+
#[stable(feature = "btree_range", since = "1.17.0")]
341342
pub struct Range<'a, K: 'a, V: 'a> {
342343
front: Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>,
343344
back: Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>,
@@ -351,6 +352,7 @@ impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Range<'a, K, V>
351352
}
352353

353354
/// A mutable iterator over a sub-range of BTreeMap's entries.
355+
#[stable(feature = "btree_range", since = "1.17.0")]
354356
pub struct RangeMut<'a, K: 'a, V: 'a> {
355357
front: Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>,
356358
back: Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>,
@@ -724,8 +726,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
724726
/// Basic usage:
725727
///
726728
/// ```
727-
/// #![feature(btree_range, collections_bound)]
728-
///
729729
/// use std::collections::BTreeMap;
730730
/// use std::collections::Bound::Included;
731731
///
@@ -738,9 +738,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
738738
/// }
739739
/// assert_eq!(Some((&5, &"b")), map.range(4..).next());
740740
/// ```
741-
#[unstable(feature = "btree_range",
742-
reason = "matches collection reform specification, waiting for dust to settle",
743-
issue = "27787")]
741+
#[stable(feature = "btree_range", since = "1.17.0")]
744742
pub fn range<T: ?Sized, R>(&self, range: R) -> Range<K, V>
745743
where T: Ord, K: Borrow<T>, R: RangeArgument<T>
746744
{
@@ -768,8 +766,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
768766
/// Basic usage:
769767
///
770768
/// ```
771-
/// #![feature(btree_range)]
772-
///
773769
/// use std::collections::BTreeMap;
774770
///
775771
/// let mut map: BTreeMap<&str, i32> = ["Alice", "Bob", "Carol", "Cheryl"].iter()
@@ -782,9 +778,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
782778
/// println!("{} => {}", name, balance);
783779
/// }
784780
/// ```
785-
#[unstable(feature = "btree_range",
786-
reason = "matches collection reform specification, waiting for dust to settle",
787-
issue = "27787")]
781+
#[stable(feature = "btree_range", since = "1.17.0")]
788782
pub fn range_mut<T: ?Sized, R>(&mut self, range: R) -> RangeMut<K, V>
789783
where T: Ord, K: Borrow<T>, R: RangeArgument<T>
790784
{

src/libcollections/btree/set.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub struct IntoIter<T> {
113113
/// [`BTreeSet`]: struct.BTreeSet.html
114114
/// [`range`]: struct.BTreeSet.html#method.range
115115
#[derive(Debug)]
116+
#[stable(feature = "btree_range", since = "1.17.0")]
116117
pub struct Range<'a, T: 'a> {
117118
iter: ::btree_map::Range<'a, T, ()>,
118119
}
@@ -264,8 +265,6 @@ impl<T: Ord> BTreeSet<T> {
264265
/// # Examples
265266
///
266267
/// ```
267-
/// #![feature(btree_range, collections_bound)]
268-
///
269268
/// use std::collections::BTreeSet;
270269
/// use std::collections::Bound::Included;
271270
///
@@ -278,9 +277,7 @@ impl<T: Ord> BTreeSet<T> {
278277
/// }
279278
/// assert_eq!(Some(&5), set.range(4..).next());
280279
/// ```
281-
#[unstable(feature = "btree_range",
282-
reason = "matches collection reform specification, waiting for dust to settle",
283-
issue = "27787")]
280+
#[stable(feature = "btree_range", since = "1.17.0")]
284281
pub fn range<K: ?Sized, R>(&self, range: R) -> Range<T>
285282
where K: Ord, T: Borrow<K>, R: RangeArgument<K>
286283
{

src/libcollections/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,17 @@ mod std {
129129
}
130130

131131
/// An endpoint of a range of keys.
132-
#[unstable(feature = "collections_bound", issue = "27787")]
132+
#[stable(feature = "collections_bound", since = "1.17.0")]
133133
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
134134
pub enum Bound<T> {
135135
/// An inclusive bound.
136+
#[stable(feature = "collections_bound", since = "1.17.0")]
136137
Included(T),
137138
/// An exclusive bound.
139+
#[stable(feature = "collections_bound", since = "1.17.0")]
138140
Excluded(T),
139141
/// An infinite endpoint. Indicates that there is no bound in this direction.
142+
#[stable(feature = "collections_bound", since = "1.17.0")]
140143
Unbounded,
141144
}
142145

0 commit comments

Comments
 (0)