Skip to content

Commit 4d96185

Browse files
authored
Rollup merge of #64996 - lzutao:inline-ptr-null, r=oli-obk
Inline `ptr::null(_mut)` even in debug builds I think we should treat `ptr::null(_mut)` as a constant. As It may help reduce code size in debug build. See godbolt link: https://godbolt.org/z/b9YMtD
2 parents c491875 + d0862ec commit 4d96185

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libcore/ptr/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ unsafe fn real_drop_in_place<T: ?Sized>(to_drop: &mut T) {
188188
/// let p: *const i32 = ptr::null();
189189
/// assert!(p.is_null());
190190
/// ```
191-
#[inline]
191+
#[inline(always)]
192192
#[stable(feature = "rust1", since = "1.0.0")]
193193
#[rustc_promotable]
194194
pub const fn null<T>() -> *const T { 0 as *const T }
@@ -203,7 +203,7 @@ pub const fn null<T>() -> *const T { 0 as *const T }
203203
/// let p: *mut i32 = ptr::null_mut();
204204
/// assert!(p.is_null());
205205
/// ```
206-
#[inline]
206+
#[inline(always)]
207207
#[stable(feature = "rust1", since = "1.0.0")]
208208
#[rustc_promotable]
209209
pub const fn null_mut<T>() -> *mut T { 0 as *mut T }

0 commit comments

Comments
 (0)