diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-20 12:40:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-20 12:40:15 +0200 |
| commit | f01ffbc7f14c5e80c130d679e99c3507591e4bab (patch) | |
| tree | b99009d35d372e0a4b6007e4be1a5dec035772f9 /src | |
| parent | 7bf377f289a4f79829309ed69dccfe33f20b089c (diff) | |
| parent | d0862ec9b0c4107b773dcb0197f1877468ce14ad (diff) | |
| download | rust-f01ffbc7f14c5e80c130d679e99c3507591e4bab.tar.gz rust-f01ffbc7f14c5e80c130d679e99c3507591e4bab.zip | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/ptr/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index 93391918595..3cc0a1cd75e 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -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 } |
