Skip to content

Commit

Permalink
fix some uses I missed
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 26, 2019
1 parent 0e0383a commit 853ae8d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/libstd/sys/sgx/ext/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ENCLU_EGETKEY: u32 = 1;
#[unstable(feature = "sgx_platform", issue = "56975")]
pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32> {
unsafe {
let mut out = MaybeUninit::uninitialized();
let mut out = MaybeUninit::uninit();
let error;

asm!(
Expand All @@ -41,7 +41,7 @@ pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32>
);

match error {
0 => Ok(out.into_initialized()),
0 => Ok(out.assume_init()),
err => Err(err),
}
}
Expand All @@ -58,7 +58,7 @@ pub fn ereport(
reportdata: &Align128<[u8; 64]>,
) -> Align512<[u8; 432]> {
unsafe {
let mut report = MaybeUninit::uninitialized();
let mut report = MaybeUninit::uninit();

asm!(
"enclu"
Expand All @@ -69,6 +69,6 @@ pub fn ereport(
"{rdx}"(report.as_mut_ptr())
);

report.into_initialized()
report.assume_init()
}
}
2 changes: 1 addition & 1 deletion src/libstd/sys/sgx/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ mod tests {
let mut init = MaybeUninit::<RWLock>::zeroed();
rwlock_new(&mut init);
assert_eq!(
mem::transmute::<_, [u8; 128]>(init.into_initialized()).as_slice(),
mem::transmute::<_, [u8; 128]>(init.assume_init()).as_slice(),
RWLOCK_INIT
)
};
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ unsafe impl Sync for ReentrantMutex {}

impl ReentrantMutex {
pub fn uninitialized() -> ReentrantMutex {
ReentrantMutex { inner: UnsafeCell::new(MaybeUninit::uninitialized()) }
ReentrantMutex { inner: UnsafeCell::new(MaybeUninit::uninit()) }
}

pub unsafe fn init(&mut self) {
Expand Down
5 changes: 4 additions & 1 deletion src/test/codegen/box-maybe-uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ pub fn box_uninitialized() -> Box<MaybeUninit<usize>> {
// CHECK-NOT: alloca
// CHECK-NOT: memcpy
// CHECK-NOT: memset
Box::new(MaybeUninit::uninitialized())
Box::new(MaybeUninit::uninit())
}

// FIXME: add a test for a bigger box. Currently broken, see
// https://github.com/rust-lang/rust/issues/58201.
6 changes: 3 additions & 3 deletions src/test/run-pass/panic-uninitialized-zeroed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {

assert_eq!(
panic::catch_unwind(|| {
mem::MaybeUninit::<!>::uninitialized().into_initialized()
mem::MaybeUninit::<!>::uninit().assume_init()
}).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
s == "Attempted to instantiate uninhabited type !"
})),
Expand All @@ -63,7 +63,7 @@ fn main() {

assert_eq!(
panic::catch_unwind(|| {
mem::MaybeUninit::<Foo>::uninitialized().into_initialized()
mem::MaybeUninit::<Foo>::uninit().assume_init()
}).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
s == "Attempted to instantiate uninhabited type Foo"
})),
Expand All @@ -90,7 +90,7 @@ fn main() {

assert_eq!(
panic::catch_unwind(|| {
mem::MaybeUninit::<Bar>::uninitialized().into_initialized()
mem::MaybeUninit::<Bar>::uninit().assume_init()
}).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
s == "Attempted to instantiate uninhabited type Bar"
})),
Expand Down

0 comments on commit 853ae8d

Please sign in to comment.