Skip to content

Commit 3a5fdfc

Browse files
committed
Partially stabilize const_pin
1 parent f7b3231 commit 3a5fdfc

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

alloc/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
#![feature(const_eval_select)]
113113
#![feature(const_heap)]
114114
#![feature(const_maybe_uninit_write)]
115-
#![feature(const_pin)]
116115
#![feature(const_size_of_val)]
117116
#![feature(const_vec_string_slice)]
118117
#![feature(core_intrinsics)]

core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
#![feature(const_nonnull_new)]
130130
#![feature(const_num_midpoint)]
131131
#![feature(const_option_ext)]
132-
#![feature(const_pin)]
132+
#![feature(const_pin_2)]
133133
#![feature(const_pointer_is_aligned)]
134134
#![feature(const_ptr_is_null)]
135135
#![feature(const_ptr_sub_ptr)]

core/src/pin.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ impl<Ptr: Deref<Target: Unpin>> Pin<Ptr> {
11861186
/// let mut pinned: Pin<&mut u8> = Pin::new(&mut val);
11871187
/// ```
11881188
#[inline(always)]
1189-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1189+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
11901190
#[stable(feature = "pin", since = "1.33.0")]
11911191
pub const fn new(pointer: Ptr) -> Pin<Ptr> {
11921192
// SAFETY: the value pointed to is `Unpin`, and so has no requirements
@@ -1214,7 +1214,7 @@ impl<Ptr: Deref<Target: Unpin>> Pin<Ptr> {
12141214
/// assert_eq!(*r, 5);
12151215
/// ```
12161216
#[inline(always)]
1217-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1217+
#[rustc_const_unstable(feature = "const_pin_2", issue = "76654")]
12181218
#[stable(feature = "pin_into_inner", since = "1.39.0")]
12191219
pub const fn into_inner(pin: Pin<Ptr>) -> Ptr {
12201220
pin.__pointer
@@ -1351,7 +1351,7 @@ impl<Ptr: Deref> Pin<Ptr> {
13511351
/// [`pin` module docs]: self
13521352
#[lang = "new_unchecked"]
13531353
#[inline(always)]
1354-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1354+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
13551355
#[stable(feature = "pin", since = "1.33.0")]
13561356
pub const unsafe fn new_unchecked(pointer: Ptr) -> Pin<Ptr> {
13571357
Pin { __pointer: pointer }
@@ -1503,7 +1503,7 @@ impl<Ptr: Deref> Pin<Ptr> {
15031503
/// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
15041504
/// instead.
15051505
#[inline(always)]
1506-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1506+
#[rustc_const_unstable(feature = "const_pin_2", issue = "76654")]
15071507
#[stable(feature = "pin_into_inner", since = "1.39.0")]
15081508
pub const unsafe fn into_inner_unchecked(pin: Pin<Ptr>) -> Ptr {
15091509
pin.__pointer
@@ -1559,7 +1559,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
15591559
/// ["pinning projections"]: self#projections-and-structural-pinning
15601560
#[inline(always)]
15611561
#[must_use]
1562-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1562+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
15631563
#[stable(feature = "pin", since = "1.33.0")]
15641564
pub const fn get_ref(self) -> &'a T {
15651565
self.__pointer
@@ -1570,7 +1570,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
15701570
/// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
15711571
#[inline(always)]
15721572
#[must_use = "`self` will be dropped if the result is not used"]
1573-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1573+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
15741574
#[stable(feature = "pin", since = "1.33.0")]
15751575
pub const fn into_ref(self) -> Pin<&'a T> {
15761576
Pin { __pointer: self.__pointer }
@@ -1588,7 +1588,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
15881588
#[inline(always)]
15891589
#[must_use = "`self` will be dropped if the result is not used"]
15901590
#[stable(feature = "pin", since = "1.33.0")]
1591-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1591+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
15921592
pub const fn get_mut(self) -> &'a mut T
15931593
where
15941594
T: Unpin,
@@ -1609,7 +1609,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
16091609
#[inline(always)]
16101610
#[must_use = "`self` will be dropped if the result is not used"]
16111611
#[stable(feature = "pin", since = "1.33.0")]
1612-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1612+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
16131613
pub const unsafe fn get_unchecked_mut(self) -> &'a mut T {
16141614
self.__pointer
16151615
}
@@ -1652,7 +1652,7 @@ impl<T: ?Sized> Pin<&'static T> {
16521652
/// This is safe because `T` is borrowed immutably for the `'static` lifetime, which
16531653
/// never ends.
16541654
#[stable(feature = "pin_static_ref", since = "1.61.0")]
1655-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1655+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
16561656
pub const fn static_ref(r: &'static T) -> Pin<&'static T> {
16571657
// SAFETY: The 'static borrow guarantees the data will not be
16581658
// moved/invalidated until it gets dropped (which is never).
@@ -1666,7 +1666,7 @@ impl<T: ?Sized> Pin<&'static mut T> {
16661666
/// This is safe because `T` is borrowed for the `'static` lifetime, which
16671667
/// never ends.
16681668
#[stable(feature = "pin_static_ref", since = "1.61.0")]
1669-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1669+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
16701670
pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> {
16711671
// SAFETY: The 'static borrow guarantees the data will not be
16721672
// moved/invalidated until it gets dropped (which is never).

core/tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#![feature(const_likely)]
2222
#![feature(const_nonnull_new)]
2323
#![feature(const_option_ext)]
24-
#![feature(const_pin)]
24+
#![feature(const_pin_2)]
2525
#![feature(const_pointer_is_aligned)]
2626
#![feature(const_three_way_compare)]
2727
#![feature(const_trait_impl)]

core/tests/pin.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ fn pin_const() {
1919
const REF: &'static usize = PINNED.get_ref();
2020
assert_eq!(REF, POINTER);
2121

22+
const INT: u8 = 42;
23+
const STATIC_REF: Pin<&'static u8> = Pin::static_ref(&INT);
24+
assert_eq!(*STATIC_REF, INT);
25+
2226
// Note: `pin_mut_const` tests that the methods of `Pin<&mut T>` are usable in a const context.
2327
// A const fn is used because `&mut` is not (yet) usable in constants.
2428
const fn pin_mut_const() {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy