Skip to content

Commit 59786b0

Browse files
committed
use more inlining, and force some of it
1 parent 5e27ee7 commit 59786b0

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/libcore/mem.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ impl<T> ManuallyDrop<T> {
950950
/// ManuallyDrop::new(Box::new(()));
951951
/// ```
952952
#[stable(feature = "manually_drop", since = "1.20.0")]
953-
#[inline]
953+
#[inline(always)]
954954
pub const fn new(value: T) -> ManuallyDrop<T> {
955955
ManuallyDrop { value }
956956
}
@@ -967,7 +967,7 @@ impl<T> ManuallyDrop<T> {
967967
/// let _: Box<()> = ManuallyDrop::into_inner(x); // This drops the `Box`.
968968
/// ```
969969
#[stable(feature = "manually_drop", since = "1.20.0")]
970-
#[inline]
970+
#[inline(always)]
971971
pub const fn into_inner(slot: ManuallyDrop<T>) -> T {
972972
slot.value
973973
}
@@ -1015,15 +1015,15 @@ impl<T: ?Sized> ManuallyDrop<T> {
10151015
#[stable(feature = "manually_drop", since = "1.20.0")]
10161016
impl<T: ?Sized> Deref for ManuallyDrop<T> {
10171017
type Target = T;
1018-
#[inline]
1018+
#[inline(always)]
10191019
fn deref(&self) -> &T {
10201020
&self.value
10211021
}
10221022
}
10231023

10241024
#[stable(feature = "manually_drop", since = "1.20.0")]
10251025
impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
1026-
#[inline]
1026+
#[inline(always)]
10271027
fn deref_mut(&mut self) -> &mut T {
10281028
&mut self.value
10291029
}
@@ -1044,6 +1044,7 @@ impl<T> MaybeUninit<T> {
10441044
/// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
10451045
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
10461046
#[unstable(feature = "maybe_uninit", issue = "53491")]
1047+
#[inline(always)]
10471048
pub const fn new(val: T) -> MaybeUninit<T> {
10481049
MaybeUninit { value: ManuallyDrop::new(val) }
10491050
}
@@ -1053,6 +1054,7 @@ impl<T> MaybeUninit<T> {
10531054
/// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
10541055
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
10551056
#[unstable(feature = "maybe_uninit", issue = "53491")]
1057+
#[inline(always)]
10561058
pub const fn uninitialized() -> MaybeUninit<T> {
10571059
MaybeUninit { uninit: () }
10581060
}
@@ -1066,6 +1068,7 @@ impl<T> MaybeUninit<T> {
10661068
/// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
10671069
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
10681070
#[unstable(feature = "maybe_uninit", issue = "53491")]
1071+
#[inline]
10691072
pub fn zeroed() -> MaybeUninit<T> {
10701073
let mut u = MaybeUninit::<T>::uninitialized();
10711074
unsafe {
@@ -1076,6 +1079,7 @@ impl<T> MaybeUninit<T> {
10761079

10771080
/// Set the value of the `MaybeUninit`. This overwrites any previous value without dropping it.
10781081
#[unstable(feature = "maybe_uninit", issue = "53491")]
1082+
#[inline(always)]
10791083
pub fn set(&mut self, val: T) {
10801084
unsafe {
10811085
self.value = ManuallyDrop::new(val);
@@ -1091,6 +1095,7 @@ impl<T> MaybeUninit<T> {
10911095
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
10921096
/// state, otherwise this will immediately cause undefined behavior.
10931097
#[unstable(feature = "maybe_uninit", issue = "53491")]
1098+
#[inline(always)]
10941099
pub unsafe fn into_inner(self) -> T {
10951100
ManuallyDrop::into_inner(self.value)
10961101
}
@@ -1102,6 +1107,7 @@ impl<T> MaybeUninit<T> {
11021107
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
11031108
/// state, otherwise this will immediately cause undefined behavior.
11041109
#[unstable(feature = "maybe_uninit", issue = "53491")]
1110+
#[inline(always)]
11051111
pub unsafe fn get_ref(&self) -> &T {
11061112
&*self.value
11071113
}
@@ -1113,20 +1119,23 @@ impl<T> MaybeUninit<T> {
11131119
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
11141120
/// state, otherwise this will immediately cause undefined behavior.
11151121
#[unstable(feature = "maybe_uninit", issue = "53491")]
1122+
#[inline(always)]
11161123
pub unsafe fn get_mut(&mut self) -> &mut T {
11171124
&mut *self.value
11181125
}
11191126

11201127
/// Get a pointer to the contained value. Reading from this pointer will be undefined
11211128
/// behavior unless the `MaybeUninit` is initialized.
11221129
#[unstable(feature = "maybe_uninit", issue = "53491")]
1130+
#[inline(always)]
11231131
pub fn as_ptr(&self) -> *const T {
11241132
unsafe { &*self.value as *const T }
11251133
}
11261134

11271135
/// Get a mutable pointer to the contained value. Reading from this pointer will be undefined
11281136
/// behavior unless the `MaybeUninit` is initialized.
11291137
#[unstable(feature = "maybe_uninit", issue = "53491")]
1138+
#[inline(always)]
11301139
pub fn as_mut_ptr(&mut self) -> *mut T {
11311140
unsafe { &mut *self.value as *mut T }
11321141
}

0 commit comments

Comments
 (0)