@@ -471,9 +471,10 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
471
471
///
472
472
/// Unlike `Pin::new_unchecked`, this method is safe because the pointer
473
473
/// `P` dereferences to an [`Unpin`] type, which cancels the pinning guarantees.
474
- #[ stable( feature = "pin" , since = "1.33.0" ) ]
475
474
#[ inline( always) ]
476
- pub fn new ( pointer : P ) -> Pin < P > {
475
+ #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
476
+ #[ stable( feature = "pin" , since = "1.33.0" ) ]
477
+ pub const fn new ( pointer : P ) -> Pin < P > {
477
478
// SAFETY: the value pointed to is `Unpin`, and so has no requirements
478
479
// around pinning.
479
480
unsafe { Pin :: new_unchecked ( pointer) }
@@ -483,9 +484,10 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
483
484
///
484
485
/// This requires that the data inside this `Pin` is [`Unpin`] so that we
485
486
/// can ignore the pinning invariants when unwrapping it.
486
- #[ stable( feature = "pin_into_inner" , since = "1.39.0" ) ]
487
487
#[ inline( always) ]
488
- pub fn into_inner ( pin : Pin < P > ) -> P {
488
+ #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
489
+ #[ stable( feature = "pin_into_inner" , since = "1.39.0" ) ]
490
+ pub const fn into_inner ( pin : Pin < P > ) -> P {
489
491
pin. pointer
490
492
}
491
493
}
@@ -556,9 +558,10 @@ impl<P: Deref> Pin<P> {
556
558
///
557
559
/// [`mem::swap`]: crate::mem::swap
558
560
#[ lang = "new_unchecked" ]
559
- #[ stable( feature = "pin" , since = "1.33.0" ) ]
560
561
#[ inline( always) ]
561
- pub unsafe fn new_unchecked ( pointer : P ) -> Pin < P > {
562
+ #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
563
+ #[ stable( feature = "pin" , since = "1.33.0" ) ]
564
+ pub const unsafe fn new_unchecked ( pointer : P ) -> Pin < P > {
562
565
Pin { pointer }
563
566
}
564
567
@@ -589,9 +592,10 @@ impl<P: Deref> Pin<P> {
589
592
///
590
593
/// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
591
594
/// instead.
592
- #[ stable( feature = "pin_into_inner" , since = "1.39.0" ) ]
593
595
#[ inline( always) ]
594
- pub unsafe fn into_inner_unchecked ( pin : Pin < P > ) -> P {
596
+ #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
597
+ #[ stable( feature = "pin_into_inner" , since = "1.39.0" ) ]
598
+ pub const unsafe fn into_inner_unchecked ( pin : Pin < P > ) -> P {
595
599
pin. pointer
596
600
}
597
601
}
@@ -693,18 +697,20 @@ impl<'a, T: ?Sized> Pin<&'a T> {
693
697
/// with the same lifetime as the original `Pin`.
694
698
///
695
699
/// ["pinning projections"]: self#projections-and-structural-pinning
696
- #[ stable( feature = "pin" , since = "1.33.0" ) ]
697
700
#[ inline( always) ]
698
- pub fn get_ref ( self ) -> & ' a T {
701
+ #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
702
+ #[ stable( feature = "pin" , since = "1.33.0" ) ]
703
+ pub const fn get_ref ( self ) -> & ' a T {
699
704
self . pointer
700
705
}
701
706
}
702
707
703
708
impl < ' a , T : ?Sized > Pin < & ' a mut T > {
704
709
/// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
705
- #[ stable( feature = "pin" , since = "1.33.0" ) ]
706
710
#[ inline( always) ]
707
- pub fn into_ref ( self ) -> Pin < & ' a T > {
711
+ #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
712
+ #[ stable( feature = "pin" , since = "1.33.0" ) ]
713
+ pub const fn into_ref ( self ) -> Pin < & ' a T > {
708
714
Pin { pointer : self . pointer }
709
715
}
710
716
@@ -717,9 +723,10 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
717
723
/// that lives for as long as the borrow of the `Pin`, not the lifetime of
718
724
/// the `Pin` itself. This method allows turning the `Pin` into a reference
719
725
/// with the same lifetime as the original `Pin`.
720
- #[ stable( feature = "pin" , since = "1.33.0" ) ]
721
726
#[ inline( always) ]
722
- pub fn get_mut ( self ) -> & ' a mut T
727
+ #[ stable( feature = "pin" , since = "1.33.0" ) ]
728
+ #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
729
+ pub const fn get_mut ( self ) -> & ' a mut T
723
730
where
724
731
T : Unpin ,
725
732
{
@@ -736,9 +743,10 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
736
743
///
737
744
/// If the underlying data is `Unpin`, `Pin::get_mut` should be used
738
745
/// instead.
739
- #[ stable( feature = "pin" , since = "1.33.0" ) ]
740
746
#[ inline( always) ]
741
- pub unsafe fn get_unchecked_mut ( self ) -> & ' a mut T {
747
+ #[ stable( feature = "pin" , since = "1.33.0" ) ]
748
+ #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
749
+ pub const unsafe fn get_unchecked_mut ( self ) -> & ' a mut T {
742
750
self . pointer
743
751
}
744
752
0 commit comments