Rollup merge of #130966 - RalfJung:ptr-metadata-const-stable, r=scottmcm · qinheping/verify-rust-std@e97c379 (original) (raw)

`@@ -92,7 +92,7 @@ impl<T: ?Sized> *const T {

`

92

92

`/// }

`

93

93

```` /// ```

````

94

94

`#[unstable(feature = "set_ptr_value", issue = "75091")]

`

95

``

`-

#[rustc_const_unstable(feature = "set_ptr_value", issue = "75091")]

`

``

95

`+

#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]

`

96

96

`#[must_use = "returns a new pointer rather than modifying its argument"]

`

97

97

`#[inline]

`

98

98

`pub const fn with_metadata_of(self, meta: *const U) -> *const U

`

`@@ -412,7 +412,6 @@ impl<T: ?Sized> *const T {

`

412

412

`#[inline(always)]

`

413

413

`#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]

`

414

414

`#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]

`

415

``

`-

#[rustc_allow_const_fn_unstable(set_ptr_value)]

`

416

415

`#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces

`

417

416

`pub const unsafe fn byte_offset(self, count: isize) -> Self {

`

418

417

`` // SAFETY: the caller must uphold the safety contract for offset.

``

`@@ -495,7 +494,6 @@ impl<T: ?Sized> *const T {

`

495

494

`#[inline(always)]

`

496

495

`#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]

`

497

496

`#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]

`

498

``

`-

#[rustc_allow_const_fn_unstable(set_ptr_value)]

`

499

497

`pub const fn wrapping_byte_offset(self, count: isize) -> Self {

`

500

498

`self.cast::().wrapping_offset(count).with_metadata_of(self)

`

501

499

`}

`

`@@ -645,7 +643,6 @@ impl<T: ?Sized> *const T {

`

645

643

`#[inline(always)]

`

646

644

`#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]

`

647

645

`#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]

`

648

``

`-

#[rustc_allow_const_fn_unstable(set_ptr_value)]

`

649

646

`#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces

`

650

647

`pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {

`

651

648

`` // SAFETY: the caller must uphold the safety contract for offset_from.

``

`@@ -873,7 +870,6 @@ impl<T: ?Sized> *const T {

`

873

870

`#[inline(always)]

`

874

871

`#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]

`

875

872

`#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]

`

876

``

`-

#[rustc_allow_const_fn_unstable(set_ptr_value)]

`

877

873

`#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces

`

878

874

`pub const unsafe fn byte_add(self, count: usize) -> Self {

`

879

875

`` // SAFETY: the caller must uphold the safety contract for add.

``

`@@ -956,7 +952,6 @@ impl<T: ?Sized> *const T {

`

956

952

`#[inline(always)]

`

957

953

`#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]

`

958

954

`#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]

`

959

``

`-

#[rustc_allow_const_fn_unstable(set_ptr_value)]

`

960

955

`#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces

`

961

956

`pub const unsafe fn byte_sub(self, count: usize) -> Self {

`

962

957

`` // SAFETY: the caller must uphold the safety contract for sub.

``

`@@ -1039,7 +1034,6 @@ impl<T: ?Sized> *const T {

`

1039

1034

`#[inline(always)]

`

1040

1035

`#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]

`

1041

1036

`#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]

`

1042

``

`-

#[rustc_allow_const_fn_unstable(set_ptr_value)]

`

1043

1037

`pub const fn wrapping_byte_add(self, count: usize) -> Self {

`

1044

1038

`self.cast::().wrapping_add(count).with_metadata_of(self)

`

1045

1039

`}

`

`@@ -1120,7 +1114,6 @@ impl<T: ?Sized> *const T {

`

1120

1114

`#[inline(always)]

`

1121

1115

`#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]

`

1122

1116

`#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]

`

1123

``

`-

#[rustc_allow_const_fn_unstable(set_ptr_value)]

`

1124

1117

`pub const fn wrapping_byte_sub(self, count: usize) -> Self {

`

1125

1118

`self.cast::().wrapping_sub(count).with_metadata_of(self)

`

1126

1119

`}

`

`@@ -1554,7 +1547,6 @@ impl *const [T] {

`

1554

1547

`#[inline]

`

1555

1548

`#[stable(feature = "slice_ptr_len", since = "1.79.0")]

`

1556

1549

`#[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")]

`

1557

``

`-

#[rustc_allow_const_fn_unstable(ptr_metadata)]

`

1558

1550

`pub const fn len(self) -> usize {

`

1559

1551

`metadata(self)

`

1560

1552

`}

`