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
This commit is contained in:
Mazdak Farrokhzad 2019-10-20 12:40:15 +02:00 committed by GitHub
commit f01ffbc7f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -188,7 +188,7 @@ unsafe fn real_drop_in_place<T: ?Sized>(to_drop: &mut T) {
/// let p: *const i32 = ptr::null();
/// assert!(p.is_null());
/// ```
#[inline]
#[inline(always)]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_promotable]
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 }
/// let p: *mut i32 = ptr::null_mut();
/// assert!(p.is_null());
/// ```
#[inline]
#[inline(always)]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_promotable]
pub const fn null_mut<T>() -> *mut T { 0 as *mut T }