Skip to content

Commit 76240d7

Browse files
committed
make some functions promotable to reduce fallout
1 parent 0294e3f commit 76240d7

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

library/core/src/ptr/const_ptr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ impl<T: ?Sized> *const T {
4343
/// Casts to a pointer of another type.
4444
#[stable(feature = "ptr_cast", since = "1.38.0")]
4545
#[rustc_const_stable(feature = "const_ptr_cast", since = "1.38.0")]
46+
#[rustc_promotable] // Operation cannot fail, so it may be promoted.
4647
#[inline]
4748
pub const fn cast<U>(self) -> *const U {
4849
self as _

library/core/src/ptr/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
196196
/// ```
197197
#[inline(always)]
198198
#[stable(feature = "rust1", since = "1.0.0")]
199-
#[rustc_promotable]
199+
#[rustc_promotable] // Operation cannot fail, so it may be promoted.
200200
#[rustc_const_stable(feature = "const_ptr_null", since = "1.32.0")]
201201
pub const fn null<T>() -> *const T {
202202
0 as *const T
@@ -214,7 +214,7 @@ pub const fn null<T>() -> *const T {
214214
/// ```
215215
#[inline(always)]
216216
#[stable(feature = "rust1", since = "1.0.0")]
217-
#[rustc_promotable]
217+
#[rustc_promotable] // Operation cannot fail, so it may be promoted.
218218
#[rustc_const_stable(feature = "const_ptr_null", since = "1.32.0")]
219219
pub const fn null_mut<T>() -> *mut T {
220220
0 as *mut T

library/core/src/ptr/mut_ptr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ impl<T: ?Sized> *mut T {
4242
/// Casts to a pointer of another type.
4343
#[stable(feature = "ptr_cast", since = "1.38.0")]
4444
#[rustc_const_stable(feature = "const_ptr_cast", since = "1.38.0")]
45+
#[rustc_promotable] // Operation cannot fail, so it may be promoted.
4546
#[inline]
4647
pub const fn cast<U>(self) -> *mut U {
4748
self as _

library/core/src/slice/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ impl<T> [T] {
404404
/// [`as_mut_ptr`]: #method.as_mut_ptr
405405
#[stable(feature = "rust1", since = "1.0.0")]
406406
#[rustc_const_stable(feature = "const_slice_as_ptr", since = "1.32.0")]
407+
#[rustc_promotable] // Operation cannot fail, so it may be promoted.
407408
#[inline]
408409
pub const fn as_ptr(&self) -> *const T {
409410
self as *const [T] as *const T
@@ -432,6 +433,7 @@ impl<T> [T] {
432433
/// ```
433434
#[stable(feature = "rust1", since = "1.0.0")]
434435
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
436+
#[rustc_promotable] // Operation cannot fail, so it may be promoted.
435437
#[inline]
436438
pub const fn as_mut_ptr(&mut self) -> *mut T {
437439
self as *mut [T] as *mut T

library/std/src/net/ip.rs

+2
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ impl Ipv4Addr {
302302
/// let addr = Ipv4Addr::new(127, 0, 0, 1);
303303
/// ```
304304
#[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")]
305+
#[rustc_promotable] // Operation cannot fail, so it may be promoted.
305306
#[stable(feature = "rust1", since = "1.0.0")]
306307
pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {
307308
// `s_addr` is stored as BE on all machine and the array is in BE order.
@@ -1045,6 +1046,7 @@ impl Ipv6Addr {
10451046
/// ```
10461047
#[rustc_allow_const_fn_unstable(const_fn_transmute)]
10471048
#[rustc_const_stable(feature = "const_ipv6", since = "1.32.0")]
1049+
#[rustc_promotable] // Operation cannot fail, so it may be promoted.
10481050
#[stable(feature = "rust1", since = "1.0.0")]
10491051
pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr {
10501052
let addr16 = [

0 commit comments

Comments
 (0)