@@ -512,7 +512,6 @@ impl<T: ?Sized> NonNull<T> {
512
512
/// # Examples
513
513
///
514
514
/// ```
515
- /// #![feature(non_null_convenience)]
516
515
/// use std::ptr::NonNull;
517
516
///
518
517
/// let mut s = [1, 2, 3];
@@ -523,12 +522,12 @@ impl<T: ?Sized> NonNull<T> {
523
522
/// println!("{}", ptr.offset(2).read());
524
523
/// }
525
524
/// ```
526
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
527
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
528
- #[ must_use = "returns a new pointer rather than modifying its argument" ]
529
525
#[ inline( always) ]
530
526
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
531
- pub const unsafe fn offset ( self , count : isize ) -> NonNull < T >
527
+ #[ must_use = "returns a new pointer rather than modifying its argument" ]
528
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
529
+ #[ rustc_const_stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
530
+ pub const unsafe fn offset ( self , count : isize ) -> Self
532
531
where
533
532
T : Sized ,
534
533
{
@@ -549,11 +548,11 @@ impl<T: ?Sized> NonNull<T> {
549
548
///
550
549
/// For non-`Sized` pointees this operation changes only the data pointer,
551
550
/// leaving the metadata untouched.
552
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
553
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
554
551
#[ must_use]
555
552
#[ inline( always) ]
556
553
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
554
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
555
+ #[ rustc_const_stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
557
556
pub const unsafe fn byte_offset ( self , count : isize ) -> Self {
558
557
// SAFETY: the caller must uphold the safety contract for `offset` and `byte_offset` has
559
558
// the same safety contract.
@@ -599,7 +598,6 @@ impl<T: ?Sized> NonNull<T> {
599
598
/// # Examples
600
599
///
601
600
/// ```
602
- /// #![feature(non_null_convenience)]
603
601
/// use std::ptr::NonNull;
604
602
///
605
603
/// let s: &str = "123";
@@ -610,11 +608,11 @@ impl<T: ?Sized> NonNull<T> {
610
608
/// println!("{}", ptr.add(2).read() as char);
611
609
/// }
612
610
/// ```
613
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
614
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
615
- #[ must_use = "returns a new pointer rather than modifying its argument" ]
616
611
#[ inline( always) ]
617
612
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
613
+ #[ must_use = "returns a new pointer rather than modifying its argument" ]
614
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
615
+ #[ rustc_const_stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
618
616
pub const unsafe fn add ( self , count : usize ) -> Self
619
617
where
620
618
T : Sized ,
@@ -636,12 +634,12 @@ impl<T: ?Sized> NonNull<T> {
636
634
///
637
635
/// For non-`Sized` pointees this operation changes only the data pointer,
638
636
/// leaving the metadata untouched.
639
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
640
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
641
637
#[ must_use]
642
638
#[ inline( always) ]
643
- #[ rustc_allow_const_fn_unstable( set_ptr_value) ]
644
639
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
640
+ #[ rustc_allow_const_fn_unstable( set_ptr_value) ]
641
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
642
+ #[ rustc_const_stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
645
643
pub const unsafe fn byte_add ( self , count : usize ) -> Self {
646
644
// SAFETY: the caller must uphold the safety contract for `add` and `byte_add` has the same
647
645
// safety contract.
@@ -688,7 +686,6 @@ impl<T: ?Sized> NonNull<T> {
688
686
/// # Examples
689
687
///
690
688
/// ```
691
- /// #![feature(non_null_convenience)]
692
689
/// use std::ptr::NonNull;
693
690
///
694
691
/// let s: &str = "123";
@@ -699,11 +696,11 @@ impl<T: ?Sized> NonNull<T> {
699
696
/// println!("{}", end.sub(2).read() as char);
700
697
/// }
701
698
/// ```
702
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
703
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
704
- #[ must_use = "returns a new pointer rather than modifying its argument" ]
705
699
#[ inline( always) ]
706
700
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
701
+ #[ must_use = "returns a new pointer rather than modifying its argument" ]
702
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
703
+ #[ rustc_const_stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
707
704
pub const unsafe fn sub ( self , count : usize ) -> Self
708
705
where
709
706
T : Sized ,
@@ -730,12 +727,12 @@ impl<T: ?Sized> NonNull<T> {
730
727
///
731
728
/// For non-`Sized` pointees this operation changes only the data pointer,
732
729
/// leaving the metadata untouched.
733
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
734
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
735
730
#[ must_use]
736
731
#[ inline( always) ]
737
- #[ rustc_allow_const_fn_unstable( set_ptr_value) ]
738
732
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
733
+ #[ rustc_allow_const_fn_unstable( set_ptr_value) ]
734
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
735
+ #[ rustc_const_stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
739
736
pub const unsafe fn byte_sub ( self , count : usize ) -> Self {
740
737
// SAFETY: the caller must uphold the safety contract for `sub` and `byte_sub` has the same
741
738
// safety contract.
@@ -816,7 +813,6 @@ impl<T: ?Sized> NonNull<T> {
816
813
/// Basic usage:
817
814
///
818
815
/// ```
819
- /// #![feature(non_null_convenience)]
820
816
/// use std::ptr::NonNull;
821
817
///
822
818
/// let a = [0; 5];
@@ -833,7 +829,7 @@ impl<T: ?Sized> NonNull<T> {
833
829
/// *Incorrect* usage:
834
830
///
835
831
/// ```rust,no_run
836
- /// #![feature(non_null_convenience, strict_provenance)]
832
+ /// #![feature(strict_provenance)]
837
833
/// use std::ptr::NonNull;
838
834
///
839
835
/// let ptr1 = NonNull::new(Box::into_raw(Box::new(0u8))).unwrap();
@@ -845,14 +841,13 @@ impl<T: ?Sized> NonNull<T> {
845
841
/// // Since ptr2_other and ptr2 are derived from pointers to different objects,
846
842
/// // computing their offset is undefined behavior, even though
847
843
/// // they point to the same address!
848
- /// unsafe {
849
- /// let zero = ptr2_other.offset_from(ptr2); // Undefined Behavior
850
- /// }
844
+ ///
845
+ /// let zero = unsafe { ptr2_other.offset_from(ptr2) }; // Undefined Behavior
851
846
/// ```
852
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
853
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
854
847
#[ inline]
855
848
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
849
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
850
+ #[ rustc_const_stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
856
851
pub const unsafe fn offset_from ( self , origin : NonNull < T > ) -> isize
857
852
where
858
853
T : Sized ,
@@ -870,10 +865,10 @@ impl<T: ?Sized> NonNull<T> {
870
865
///
871
866
/// For non-`Sized` pointees this operation considers only the data pointers,
872
867
/// ignoring the metadata.
873
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
874
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
875
868
#[ inline( always) ]
876
869
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
870
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
871
+ #[ rustc_const_stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
877
872
pub const unsafe fn byte_offset_from < U : ?Sized > ( self , origin : NonNull < U > ) -> isize {
878
873
// SAFETY: the caller must uphold the safety contract for `byte_offset_from`.
879
874
unsafe { self . pointer . byte_offset_from ( origin. pointer ) }
@@ -897,7 +892,7 @@ impl<T: ?Sized> NonNull<T> {
897
892
/// to [`sub`](#method.sub)). The following are all equivalent, assuming
898
893
/// that their safety preconditions are met:
899
894
/// ```rust
900
- /// # #![feature(non_null_convenience )]
895
+ /// # #![feature(ptr_sub_ptr )]
901
896
/// # unsafe fn blah(ptr: std::ptr::NonNull<u32>, origin: std::ptr::NonNull<u32>, count: usize) -> bool {
902
897
/// ptr.sub_ptr(origin) == count
903
898
/// # &&
@@ -926,7 +921,7 @@ impl<T: ?Sized> NonNull<T> {
926
921
/// # Examples
927
922
///
928
923
/// ```
929
- /// #![feature(non_null_convenience )]
924
+ /// #![feature(ptr_sub_ptr )]
930
925
/// use std::ptr::NonNull;
931
926
///
932
927
/// let a = [0; 5];
@@ -942,12 +937,10 @@ impl<T: ?Sized> NonNull<T> {
942
937
/// // This would be incorrect, as the pointers are not correctly ordered:
943
938
/// // ptr1.sub_ptr(ptr2)
944
939
/// ```
945
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
946
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
947
- // #[unstable(feature = "ptr_sub_ptr", issue = "95892")]
948
- // #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
949
940
#[ inline]
950
941
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
942
+ #[ unstable( feature = "ptr_sub_ptr" , issue = "95892" ) ]
943
+ #[ rustc_const_unstable( feature = "const_ptr_sub_ptr" , issue = "95892" ) ]
951
944
pub const unsafe fn sub_ptr ( self , subtracted : NonNull < T > ) -> usize
952
945
where
953
946
T : Sized ,
@@ -962,10 +955,10 @@ impl<T: ?Sized> NonNull<T> {
962
955
/// See [`ptr::read`] for safety concerns and examples.
963
956
///
964
957
/// [`ptr::read`]: crate::ptr::read()
965
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
966
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
967
958
#[ inline]
968
959
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
960
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
961
+ #[ rustc_const_stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
969
962
pub const unsafe fn read ( self ) -> T
970
963
where
971
964
T : Sized ,
@@ -984,9 +977,9 @@ impl<T: ?Sized> NonNull<T> {
984
977
/// See [`ptr::read_volatile`] for safety concerns and examples.
985
978
///
986
979
/// [`ptr::read_volatile`]: crate::ptr::read_volatile()
987
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
988
980
#[ inline]
989
981
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
982
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
990
983
pub unsafe fn read_volatile ( self ) -> T
991
984
where
992
985
T : Sized ,
@@ -1003,10 +996,10 @@ impl<T: ?Sized> NonNull<T> {
1003
996
/// See [`ptr::read_unaligned`] for safety concerns and examples.
1004
997
///
1005
998
/// [`ptr::read_unaligned`]: crate::ptr::read_unaligned()
1006
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1007
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1008
999
#[ inline]
1009
1000
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1001
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1002
+ #[ rustc_const_stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1010
1003
pub const unsafe fn read_unaligned ( self ) -> T
1011
1004
where
1012
1005
T : Sized ,
@@ -1023,10 +1016,10 @@ impl<T: ?Sized> NonNull<T> {
1023
1016
/// See [`ptr::copy`] for safety concerns and examples.
1024
1017
///
1025
1018
/// [`ptr::copy`]: crate::ptr::copy()
1026
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1027
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1028
1019
#[ inline( always) ]
1029
1020
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1021
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1022
+ #[ rustc_const_unstable( feature = "const_intrinsic_copy" , issue = "80697" ) ]
1030
1023
pub const unsafe fn copy_to ( self , dest : NonNull < T > , count : usize )
1031
1024
where
1032
1025
T : Sized ,
@@ -1043,10 +1036,10 @@ impl<T: ?Sized> NonNull<T> {
1043
1036
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
1044
1037
///
1045
1038
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
1046
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1047
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1048
1039
#[ inline( always) ]
1049
1040
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1041
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1042
+ #[ rustc_const_unstable( feature = "const_intrinsic_copy" , issue = "80697" ) ]
1050
1043
pub const unsafe fn copy_to_nonoverlapping ( self , dest : NonNull < T > , count : usize )
1051
1044
where
1052
1045
T : Sized ,
@@ -1063,10 +1056,10 @@ impl<T: ?Sized> NonNull<T> {
1063
1056
/// See [`ptr::copy`] for safety concerns and examples.
1064
1057
///
1065
1058
/// [`ptr::copy`]: crate::ptr::copy()
1066
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1067
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1068
1059
#[ inline( always) ]
1069
1060
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1061
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1062
+ #[ rustc_const_unstable( feature = "const_intrinsic_copy" , issue = "80697" ) ]
1070
1063
pub const unsafe fn copy_from ( self , src : NonNull < T > , count : usize )
1071
1064
where
1072
1065
T : Sized ,
@@ -1083,10 +1076,10 @@ impl<T: ?Sized> NonNull<T> {
1083
1076
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
1084
1077
///
1085
1078
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
1086
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1087
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1088
1079
#[ inline( always) ]
1089
1080
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1081
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1082
+ #[ rustc_const_unstable( feature = "const_intrinsic_copy" , issue = "80697" ) ]
1090
1083
pub const unsafe fn copy_from_nonoverlapping ( self , src : NonNull < T > , count : usize )
1091
1084
where
1092
1085
T : Sized ,
@@ -1100,8 +1093,8 @@ impl<T: ?Sized> NonNull<T> {
1100
1093
/// See [`ptr::drop_in_place`] for safety concerns and examples.
1101
1094
///
1102
1095
/// [`ptr::drop_in_place`]: crate::ptr::drop_in_place()
1103
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1104
1096
#[ inline( always) ]
1097
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1105
1098
pub unsafe fn drop_in_place ( self ) {
1106
1099
// SAFETY: the caller must uphold the safety contract for `drop_in_place`.
1107
1100
unsafe { ptr:: drop_in_place ( self . as_ptr ( ) ) }
@@ -1113,11 +1106,10 @@ impl<T: ?Sized> NonNull<T> {
1113
1106
/// See [`ptr::write`] for safety concerns and examples.
1114
1107
///
1115
1108
/// [`ptr::write`]: crate::ptr::write()
1116
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1117
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1118
- //#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1119
1109
#[ inline( always) ]
1120
1110
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1111
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1112
+ #[ rustc_const_unstable( feature = "const_ptr_write" , issue = "86302" ) ]
1121
1113
pub const unsafe fn write ( self , val : T )
1122
1114
where
1123
1115
T : Sized ,
@@ -1132,12 +1124,11 @@ impl<T: ?Sized> NonNull<T> {
1132
1124
/// See [`ptr::write_bytes`] for safety concerns and examples.
1133
1125
///
1134
1126
/// [`ptr::write_bytes`]: crate::ptr::write_bytes()
1135
- #[ doc( alias = "memset" ) ]
1136
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1137
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1138
- //#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1139
1127
#[ inline( always) ]
1128
+ #[ doc( alias = "memset" ) ]
1140
1129
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1130
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1131
+ #[ rustc_const_unstable( feature = "const_ptr_write" , issue = "86302" ) ]
1141
1132
pub const unsafe fn write_bytes ( self , val : u8 , count : usize )
1142
1133
where
1143
1134
T : Sized ,
@@ -1156,9 +1147,9 @@ impl<T: ?Sized> NonNull<T> {
1156
1147
/// See [`ptr::write_volatile`] for safety concerns and examples.
1157
1148
///
1158
1149
/// [`ptr::write_volatile`]: crate::ptr::write_volatile()
1159
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1160
1150
#[ inline( always) ]
1161
1151
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1152
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1162
1153
pub unsafe fn write_volatile ( self , val : T )
1163
1154
where
1164
1155
T : Sized ,
@@ -1175,11 +1166,10 @@ impl<T: ?Sized> NonNull<T> {
1175
1166
/// See [`ptr::write_unaligned`] for safety concerns and examples.
1176
1167
///
1177
1168
/// [`ptr::write_unaligned`]: crate::ptr::write_unaligned()
1178
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1179
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1180
- //#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1181
1169
#[ inline( always) ]
1182
1170
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1171
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1172
+ #[ rustc_const_unstable( feature = "const_ptr_write" , issue = "86302" ) ]
1183
1173
pub const unsafe fn write_unaligned ( self , val : T )
1184
1174
where
1185
1175
T : Sized ,
@@ -1194,8 +1184,8 @@ impl<T: ?Sized> NonNull<T> {
1194
1184
/// See [`ptr::replace`] for safety concerns and examples.
1195
1185
///
1196
1186
/// [`ptr::replace`]: crate::ptr::replace()
1197
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1198
1187
#[ inline( always) ]
1188
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1199
1189
pub unsafe fn replace ( self , src : T ) -> T
1200
1190
where
1201
1191
T : Sized ,
@@ -1211,10 +1201,9 @@ impl<T: ?Sized> NonNull<T> {
1211
1201
/// See [`ptr::swap`] for safety concerns and examples.
1212
1202
///
1213
1203
/// [`ptr::swap`]: crate::ptr::swap()
1214
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1215
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1216
- //#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
1217
1204
#[ inline( always) ]
1205
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1206
+ #[ rustc_const_unstable( feature = "const_swap" , issue = "83163" ) ]
1218
1207
pub const unsafe fn swap ( self , with : NonNull < T > )
1219
1208
where
1220
1209
T : Sized ,
@@ -1246,7 +1235,6 @@ impl<T: ?Sized> NonNull<T> {
1246
1235
/// Accessing adjacent `u8` as `u16`
1247
1236
///
1248
1237
/// ```
1249
- /// #![feature(non_null_convenience)]
1250
1238
/// use std::mem::align_of;
1251
1239
/// use std::ptr::NonNull;
1252
1240
///
@@ -1264,11 +1252,10 @@ impl<T: ?Sized> NonNull<T> {
1264
1252
/// }
1265
1253
/// # }
1266
1254
/// ```
1267
- #[ unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1268
- #[ rustc_const_unstable( feature = "non_null_convenience" , issue = "117691" ) ]
1269
- //#[rustc_const_unstable(feature = "const_align_offset", issue = "90962")]
1270
- #[ must_use]
1271
1255
#[ inline]
1256
+ #[ must_use]
1257
+ #[ stable( feature = "non_null_convenience" , since = "CURRENT_RUSTC_VERSION" ) ]
1258
+ #[ rustc_const_unstable( feature = "const_align_offset" , issue = "90962" ) ]
1272
1259
pub const fn align_offset ( self , align : usize ) -> usize
1273
1260
where
1274
1261
T : Sized ,
@@ -1312,10 +1299,9 @@ impl<T: ?Sized> NonNull<T> {
1312
1299
/// underlying allocation.
1313
1300
///
1314
1301
/// ```
1315
- /// #![feature(const_pointer_is_aligned)]
1316
- /// #![feature(non_null_convenience)]
1317
- /// #![feature(const_option)]
1318
1302
/// #![feature(const_nonnull_new)]
1303
+ /// #![feature(const_option)]
1304
+ /// #![feature(const_pointer_is_aligned)]
1319
1305
/// use std::ptr::NonNull;
1320
1306
///
1321
1307
/// // On some platforms, the alignment of primitives is less than their size.
@@ -1390,10 +1376,10 @@ impl<T: ?Sized> NonNull<T> {
1390
1376
/// ```
1391
1377
///
1392
1378
/// [tracking issue]: https://github.com/rust-lang/rust/issues/104203
1379
+ #[ inline]
1380
+ #[ must_use]
1393
1381
#[ stable( feature = "pointer_is_aligned" , since = "CURRENT_RUSTC_VERSION" ) ]
1394
1382
#[ rustc_const_unstable( feature = "const_pointer_is_aligned" , issue = "104203" ) ]
1395
- #[ must_use]
1396
- #[ inline]
1397
1383
pub const fn is_aligned ( self ) -> bool
1398
1384
where
1399
1385
T : Sized ,
@@ -1505,10 +1491,10 @@ impl<T: ?Sized> NonNull<T> {
1505
1491
/// ```
1506
1492
///
1507
1493
/// [tracking issue]: https://github.com/rust-lang/rust/issues/104203
1494
+ #[ inline]
1495
+ #[ must_use]
1508
1496
#[ unstable( feature = "pointer_is_aligned_to" , issue = "96284" ) ]
1509
1497
#[ rustc_const_unstable( feature = "const_pointer_is_aligned" , issue = "104203" ) ]
1510
- #[ must_use]
1511
- #[ inline]
1512
1498
pub const fn is_aligned_to ( self , align : usize ) -> bool {
1513
1499
self . pointer . is_aligned_to ( align)
1514
1500
}
0 commit comments