Skip to content

Commit 121b95e

Browse files
author
Lucas Paixão
committed
Clippy fix
1 parent 17f399e commit 121b95e

File tree

6 files changed

+19
-32
lines changed

6 files changed

+19
-32
lines changed

src/buf/fixed/handle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Drop for FixedBuf {
3838
fn drop(&mut self) {
3939
let registry = Rc::get_mut(&mut self.registry);
4040

41-
if let None = registry { return; }
41+
if registry.is_none() { return; }
4242

4343
let registry = registry.unwrap();
4444
// Safety: the length of the initialized data in the buffer has been

src/buf/fixed/pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ impl<T: IoBufMut> FixedBufPool<T> {
228228
pub fn try_next(&mut self, cap: usize) -> Option<FixedBuf> {
229229
let inner = Rc::get_mut(&mut self.inner);
230230

231-
if let None = inner { return None }
231+
if inner.is_none() { return None }
232232

233233
inner.unwrap().try_next(cap).map(|data| {
234-
let pool = Rc::clone(&mut self.inner);
234+
let pool = Rc::clone(&self.inner);
235235
// Safety: the validity of buffer data is ensured by
236236
// plumbing::Pool::try_next
237237
unsafe { FixedBuf::new(pool, data) }

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
//! call `close()`.
5858
5959
#![warn(missing_docs)]
60-
#![allow(clippy::thread_local_initializer_can_be_made_const)]
60+
#![allow(clippy::missing_const_for_thread_local)]
6161

6262
macro_rules! syscall {
6363
($fn: ident ( $($arg: expr),* $(,)* ) ) => {{

src/runtime/driver/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl Driver {
205205
}
206206
Lifecycle::CompletionList(list) => {
207207
// Deallocate list entries, recording if more CQE's are expected
208-
let more = cqueue::more(list.into_iter().last().unwrap().flags);
208+
let more = cqueue::more(list.into_iter().next_back().unwrap().flags);
209209

210210
if more {
211211
// If more are expected, we have to keep the op around
@@ -240,14 +240,13 @@ impl Driver {
240240
Ok(op)
241241
}
242242

243-
pub(crate) fn submit_op<T: Unpin, S: Unpin, F>(
243+
pub(crate) fn submit_op<T: Unpin + Completable, S: Unpin, F>(
244244
&self,
245245
mut data: T,
246246
f: F,
247247
handle: WeakHandle,
248248
) -> io::Result<Pin<Box<Op<T, S>>>>
249249
where
250-
T: Completable,
251250
F: FnOnce(&mut T) -> squeue::Entry,
252251
{
253252
// Configure the SQE

src/runtime/driver/op/mod.rs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub struct ArcMonitorGuard<'a, T> {
9797
arc_monitor: &'a ArcMonitor<T>,
9898
}
9999

100-
impl<'a, T> Drop for ArcMonitorGuard<'a, T> {
100+
impl<T> Drop for ArcMonitorGuard<'_, T> {
101101
fn drop(&mut self) {
102102
self.arc_monitor.leave();
103103
}
@@ -162,7 +162,7 @@ impl<T> ArcMonitor<T> {
162162

163163
if old_uses > 0 {
164164
return Some(ArcMonitorGuard {
165-
arc_monitor: &self,
165+
arc_monitor: self,
166166
});
167167
}
168168

@@ -176,7 +176,7 @@ impl<T> ArcMonitor<T> {
176176
}
177177

178178
Some(ArcMonitorGuard {
179-
arc_monitor: &self,
179+
arc_monitor: self,
180180
})
181181
}
182182

@@ -222,13 +222,10 @@ impl<T> ArcMonitor<T> {
222222
}
223223
}
224224

225-
let is_recycled =
226-
self
227-
.status
228-
.compare_exchange(ArcMonitorStatus::Live, ArcMonitorStatus::Dropped, Ordering::Release, Ordering::Relaxed)
229-
.is_ok();
230-
231-
is_recycled
225+
self
226+
.status
227+
.compare_exchange(ArcMonitorStatus::Live, ArcMonitorStatus::Dropped, Ordering::Release, Ordering::Relaxed)
228+
.is_ok()
232229
}
233230
}
234231

@@ -247,20 +244,12 @@ impl<T> DerefMut for ArcMonitor<T> {
247244
}
248245
}
249246

247+
#[derive(Default)]
250248
pub(crate) struct Location {
251249
pub(crate) address: usize,
252250
pub(crate) vtable: usize,
253251
}
254252

255-
impl Default for Location {
256-
fn default() -> Location {
257-
Location {
258-
address: 0,
259-
vtable: 0
260-
}
261-
}
262-
}
263-
264253
/// In-flight operation
265254
pub struct Op<T: 'static, CqeType = SingleCQE>
266255
where
@@ -379,7 +368,7 @@ impl<T: Unpin, CqeType: Unpin> Op<T, CqeType> {
379368
fn initialize(mut self: Pin<Box<Self>>) -> Pin<Box<Self>> {
380369
let location = ArcMonitor::<Location>::new(Default::default(), 2);
381370

382-
let this: *mut Self = unsafe { mem::transmute(&*self) };
371+
let this = &*self as *const Op<T, CqeType> as *mut Op<T, CqeType>;
383372
let notifiable: *mut dyn Notifiable = this as *mut _;
384373

385374
//SAFETY: Converting current address and vtable to a tuple

src/runtime/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub struct Runtime {
6868
/// handle.await.unwrap();
6969
/// });
7070
/// ```
71-
pub fn spawn<F: Future + 'static>(task: F) -> tokio::task::JoinHandle<F::Output>
71+
pub fn spawn<F>(task: F) -> tokio::task::JoinHandle<F::Output>
7272
where F: Future + Send + 'static,
7373
F::Output: Send + 'static
7474
{
@@ -98,7 +98,7 @@ impl Runtime {
9898
/// Creates a new tokio_uring runtime on the current thread.
9999
///
100100
/// This takes the tokio-uring [`Builder`](crate::Builder) as a parameter.
101-
pub fn new<'a>() -> io::Result<Runtime> {
101+
pub fn new() -> io::Result<Runtime> {
102102
let mut runtime = Runtime {
103103
local: ManuallyDrop::new(LocalSet::new()),
104104
tokio_rt: MaybeUninit::zeroed(),
@@ -138,10 +138,9 @@ impl Runtime {
138138
let is_unique = |item: &Arc<RuntimeContext>, list: LinkedList<Arc<RuntimeContext>>| {
139139
let item_fd = item.handle().as_raw_fd();
140140

141-
list
141+
!list
142142
.iter()
143-
.find(|i| i.handle().as_raw_fd() == item_fd)
144-
.is_none()
143+
.any(|i| i.handle().as_raw_fd() == item_fd)
145144
};
146145

147146
let contexts = self.contexts.clone();

0 commit comments

Comments
 (0)