Skip to content

Commit c29300f

Browse files
committed
Clippy
1 parent fb6c183 commit c29300f

3 files changed

Lines changed: 26 additions & 34 deletions

File tree

src/observer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ mod tests {
666666
fn test_send() {
667667
/* observer can send when the underlying value can */
668668
#[allow(unused)]
669-
fn ex<'executor, T: Send, E: ExecutorNotified + Send>(_observer: TypedObserver<T, E>) {
669+
fn ex<T: Send, E: ExecutorNotified + Send>(_observer: TypedObserver<T, E>) {
670670
fn assert_send<T: Send>() {}
671671
assert_send::<TypedObserver<T, E>>();
672672
}
@@ -676,7 +676,7 @@ mod tests {
676676
fn test_unpin() {
677677
/* observer can unpin */
678678
#[allow(unused)]
679-
fn ex<'executor, T, E: ExecutorNotified + Unpin>(_observer: TypedObserver<T, E>) {
679+
fn ex<T, E: ExecutorNotified + Unpin>(_observer: TypedObserver<T, E>) {
680680
fn assert_unpin<T: Unpin>() {}
681681
assert_unpin::<TypedObserver<T, E>>();
682682
}

src/sys/stdlib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ mod tests {
280280
crate::observer::Observation::Ready(value) => {
281281
assert_eq!(value, 99);
282282
// Verify it was polled at least 3 times and the counter was decremented
283-
// Since we start at 3 and decrement each poll, final value should be <= 0
284-
assert!(polls_counter.load(Ordering::Relaxed) <= 0);
283+
// Since we start at 3 and decrement each poll, final value should be 0
284+
assert_eq!(polls_counter.load(Ordering::Relaxed), 0);
285285
}
286286
_ => panic!("Task should have completed successfully"),
287287
}

src/task.rs

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,11 @@ mod tests {
607607
}
608608

609609
#[allow(unused)]
610-
fn spawn_check<F: Future + Send, E: SomeExecutor>(task: Task<F, Infallible>, exec: &mut E)
611-
where
610+
fn spawn_check<F: Future + Send, E: SomeExecutor + Send>(
611+
task: Task<F, Infallible>,
612+
exec: &mut E,
613+
) where
612614
F::Output: Send,
613-
E: Send,
614615
{
615616
let spawned: SpawnedTask<F, Infallible, E> = task.spawn(exec).0;
616617
fn assert_send<T: Send>(_: T) {}
@@ -631,12 +632,10 @@ mod tests {
631632
}
632633

633634
#[allow(unused)]
634-
fn spawn_check_unpin<F: Future + Unpin, E: SomeExecutor>(
635+
fn spawn_check_unpin<F: Future + Unpin, E: SomeExecutor + Unpin>(
635636
task: Task<F, Infallible>,
636637
exec: &mut E,
637-
) where
638-
E: Unpin,
639-
{
638+
) {
640639
let spawned: SpawnedTask<F, Infallible, E> = task.spawn(exec).0;
641640
fn assert_unpin<T: Unpin>(_: T) {}
642641
assert_unpin(spawned);
@@ -665,13 +664,12 @@ mod tests {
665664
{
666665
type ExecutorNotifier = Infallible;
667666

668-
fn spawn_local<F: Future, Notifier: ObserverNotified<F::Output>>(
667+
fn spawn_local<F: Future + 'new_task, Notifier: ObserverNotified<F::Output>>(
669668
&mut self,
670669
task: Task<F, Notifier>,
671670
) -> impl Observer<Value = F::Output>
672671
where
673672
Self: Sized,
674-
F: 'new_task,
675673
F::Output: 'static,
676674
/* I am a little uncertain whether this is really required */
677675
<F as Future>::Output: Unpin,
@@ -682,21 +680,21 @@ mod tests {
682680
observer
683681
}
684682

685-
fn spawn_local_async<F: Future, Notifier: ObserverNotified<F::Output>>(
683+
async fn spawn_local_async<
684+
F: Future + 'new_task,
685+
Notifier: ObserverNotified<F::Output>,
686+
>(
686687
&mut self,
687688
task: Task<F, Notifier>,
688-
) -> impl Future<Output = impl Observer<Value = F::Output>>
689+
) -> impl Observer<Value = F::Output>
689690
where
690691
Self: Sized,
691-
F: 'new_task,
692692
F::Output: 'static,
693693
{
694-
async {
695-
let (spawn, observer) = task.spawn_local(self);
696-
let pinned_spawn = Box::pin(spawn);
697-
self.0.push(pinned_spawn);
698-
observer
699-
}
694+
let (spawn, observer) = task.spawn_local(self);
695+
let pinned_spawn = Box::pin(spawn);
696+
self.0.push(pinned_spawn);
697+
observer
700698
}
701699

702700
fn spawn_local_objsafe(
@@ -729,18 +727,12 @@ mod tests {
729727
>,
730728
> + 's,
731729
> {
732-
Box::new(async {
733-
let (spawn, observer) = task.spawn_local_objsafe(self);
734-
let pinned_spawn = Box::pin(spawn);
735-
self.0.push(pinned_spawn);
736-
Box::new(observer)
737-
as Box<
738-
dyn Observer<
739-
Value = Box<dyn Any>,
740-
Output = FinishedObservation<Box<dyn Any>>,
741-
>,
742-
>
743-
})
730+
let (spawn, observer) = task.spawn_local_objsafe(self);
731+
let pinned_spawn = Box::pin(spawn);
732+
self.0.push(pinned_spawn);
733+
#[allow(clippy::type_complexity)]
734+
let boxed = Box::new(observer) as Box<dyn Observer<Value = _, Output = _>>;
735+
Box::new(std::future::ready(boxed))
744736
}
745737

746738
fn executor_notifier(&mut self) -> Option<Self::ExecutorNotifier> {

0 commit comments

Comments
 (0)