From cd677f7d13696e840d312f5e3658ded2de2fb4bb Mon Sep 17 00:00:00 2001 From: Xudong Huang Date: Thu, 10 Jun 2021 13:57:50 +0800 Subject: [PATCH] :pencil: fix clippy warnings --- src/stack/unix.rs | 10 +++------- src/yield_.rs | 5 ++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/stack/unix.rs b/src/stack/unix.rs index 6c9675c..0cb9576 100644 --- a/src/stack/unix.rs +++ b/src/stack/unix.rs @@ -93,13 +93,9 @@ pub fn max_stack_size() -> usize { let mut ret = PAGE_SIZE.load(Ordering::Relaxed); if ret == 0 { - let mut limit; - let limitret; - - unsafe { - limit = mem::MaybeUninit::uninit().assume_init(); - limitret = libc::getrlimit(libc::RLIMIT_STACK, &mut limit); - } + let limit = mem::MaybeUninit::uninit(); + let mut limit = unsafe { limit.assume_init() }; + let limitret = unsafe { libc::getrlimit(libc::RLIMIT_STACK, &mut limit) }; if limitret == 0 { ret = if limit.rlim_max == libc::RLIM_INFINITY diff --git a/src/yield_.rs b/src/yield_.rs index a3031bf..f82be13 100644 --- a/src/yield_.rs +++ b/src/yield_.rs @@ -26,7 +26,10 @@ pub fn done() -> T { assert!(is_generator(), "done is only possible in a generator"); // set the done bit for this special return ContextStack::current().top()._ref = 0xf; - unsafe { std::mem::MaybeUninit::uninit().assume_init() } + // this return value would not be dropped when _ref is 0xf + // so it's safe here to reutrn a dummy T + let ret = std::mem::MaybeUninit::uninit(); + unsafe { ret.assume_init() } } /// switch back to parent context