Skip to content

Commit 50650fa

Browse files
committed
refactor(port_std): address the clippy::extra_unused_type_parameters lint in expect_worker_thread
1 parent d576106 commit 50650fa

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/r3_port_std/src/lib.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl State {
295295

296296
pub unsafe fn dispatch_first_task<Traits: PortInstance>(&'static self) -> ! {
297297
log::trace!("dispatch_first_task");
298-
assert_eq!(expect_worker_thread::<Traits>(), ThreadRole::Boot);
298+
assert_eq!(expect_worker_thread(), ThreadRole::Boot);
299299
assert!(self.is_cpu_lock_active::<Traits>());
300300

301301
// Create a UMS worker thread for the dispatcher
@@ -332,7 +332,7 @@ impl State {
332332
}
333333

334334
fn dispatch<Traits: PortInstance>(&'static self) {
335-
assert_eq!(expect_worker_thread::<Traits>(), ThreadRole::Interrupt);
335+
assert_eq!(expect_worker_thread(), ThreadRole::Interrupt);
336336

337337
unsafe { self.enter_cpu_lock::<Traits>() };
338338
unsafe { Traits::choose_running_task() };
@@ -387,7 +387,7 @@ impl State {
387387

388388
pub unsafe fn yield_cpu<Traits: PortInstance>(&'static self) {
389389
log::trace!("yield_cpu");
390-
expect_worker_thread::<Traits>();
390+
expect_worker_thread();
391391
assert!(!self.is_cpu_lock_active::<Traits>());
392392

393393
self.pend_interrupt_line::<Traits>(INTERRUPT_LINE_DISPATCH)
@@ -399,7 +399,7 @@ impl State {
399399
task: &'static TaskCb<Traits>,
400400
) -> ! {
401401
log::trace!("exit_and_dispatch");
402-
assert_eq!(expect_worker_thread::<Traits>(), ThreadRole::Task);
402+
assert_eq!(expect_worker_thread(), ThreadRole::Task);
403403
assert!(self.is_cpu_lock_active::<Traits>());
404404

405405
unsafe {
@@ -409,7 +409,7 @@ impl State {
409409

410410
pub unsafe fn enter_cpu_lock<Traits: PortInstance>(&self) {
411411
log::trace!("enter_cpu_lock");
412-
expect_worker_thread::<Traits>();
412+
expect_worker_thread();
413413

414414
let mut lock = self.thread_group.get().unwrap().lock();
415415
assert!(!lock.scheduler().cpu_lock);
@@ -418,7 +418,7 @@ impl State {
418418

419419
pub unsafe fn leave_cpu_lock<Traits: PortInstance>(&'static self) {
420420
log::trace!("leave_cpu_lock");
421-
expect_worker_thread::<Traits>();
421+
expect_worker_thread();
422422

423423
let mut lock = self.thread_group.get().unwrap().lock();
424424
assert!(lock.scheduler().cpu_lock);
@@ -435,7 +435,7 @@ impl State {
435435
task: &'static TaskCb<Traits>,
436436
) {
437437
log::trace!("initialize_task_state {task:p}");
438-
expect_worker_thread::<Traits>();
438+
expect_worker_thread();
439439
assert!(self.is_cpu_lock_active::<Traits>());
440440

441441
let pts = &task.port_task_state;
@@ -452,15 +452,15 @@ impl State {
452452
}
453453

454454
pub fn is_cpu_lock_active<Traits: PortInstance>(&self) -> bool {
455-
expect_worker_thread::<Traits>();
455+
expect_worker_thread();
456456

457457
(self.thread_group.get().unwrap().lock())
458458
.scheduler()
459459
.cpu_lock
460460
}
461461

462462
pub fn is_task_context<Traits: PortInstance>(&self) -> bool {
463-
expect_worker_thread::<Traits>();
463+
expect_worker_thread();
464464

465465
THREAD_ROLE.with(|role| match role.get() {
466466
ThreadRole::Interrupt | ThreadRole::Boot => false,
@@ -470,7 +470,7 @@ impl State {
470470
}
471471

472472
pub fn is_interrupt_context<Traits: PortInstance>(&self) -> bool {
473-
expect_worker_thread::<Traits>();
473+
expect_worker_thread();
474474

475475
THREAD_ROLE.with(|role| match role.get() {
476476
ThreadRole::Task | ThreadRole::Boot => false,
@@ -480,7 +480,7 @@ impl State {
480480
}
481481

482482
pub fn is_scheduler_active<Traits: PortInstance>(&self) -> bool {
483-
expect_worker_thread::<Traits>();
483+
expect_worker_thread();
484484

485485
THREAD_ROLE.with(|role| match role.get() {
486486
ThreadRole::Interrupt | ThreadRole::Task => true,
@@ -496,7 +496,7 @@ impl State {
496496
) -> Result<(), SetInterruptLinePriorityError> {
497497
log::trace!("set_interrupt_line_priority({num}, {priority})");
498498
assert!(matches!(
499-
expect_worker_thread::<Traits>(),
499+
expect_worker_thread(),
500500
ThreadRole::Boot | ThreadRole::Task
501501
));
502502

@@ -518,7 +518,7 @@ impl State {
518518
num: InterruptNum,
519519
) -> Result<(), EnableInterruptLineError> {
520520
log::trace!("enable_interrupt_line({num})");
521-
expect_worker_thread::<Traits>();
521+
expect_worker_thread();
522522

523523
let mut lock = self.thread_group.get().unwrap().lock();
524524
lock.scheduler()
@@ -538,7 +538,7 @@ impl State {
538538
num: InterruptNum,
539539
) -> Result<(), EnableInterruptLineError> {
540540
log::trace!("disable_interrupt_line({num})");
541-
expect_worker_thread::<Traits>();
541+
expect_worker_thread();
542542

543543
(self.thread_group.get().unwrap().lock())
544544
.scheduler()
@@ -551,7 +551,7 @@ impl State {
551551
num: InterruptNum,
552552
) -> Result<(), PendInterruptLineError> {
553553
log::trace!("pend_interrupt_line({num})");
554-
expect_worker_thread::<Traits>();
554+
expect_worker_thread();
555555

556556
let mut lock = self.thread_group.get().unwrap().lock();
557557
lock.scheduler()
@@ -571,7 +571,7 @@ impl State {
571571
num: InterruptNum,
572572
) -> Result<(), ClearInterruptLineError> {
573573
log::trace!("clear_interrupt_line({num})");
574-
expect_worker_thread::<Traits>();
574+
expect_worker_thread();
575575

576576
(self.thread_group.get().unwrap().lock())
577577
.scheduler()
@@ -583,7 +583,7 @@ impl State {
583583
&self,
584584
num: InterruptNum,
585585
) -> Result<bool, QueryInterruptLineError> {
586-
expect_worker_thread::<Traits>();
586+
expect_worker_thread();
587587

588588
(self.thread_group.get().unwrap().lock())
589589
.scheduler()
@@ -596,7 +596,7 @@ impl State {
596596
pub const MAX_TIMEOUT: UTicks = UTicks::MAX / 2;
597597

598598
pub fn tick_count<Traits: PortInstance>(&self) -> UTicks {
599-
expect_worker_thread::<Traits>();
599+
expect_worker_thread();
600600

601601
let origin = if let Some(x) = self.origin.load(Ordering::Acquire) {
602602
x
@@ -645,7 +645,7 @@ impl State {
645645
}
646646

647647
pub fn pend_tick_after<Traits: PortInstance>(&self, tick_count_delta: UTicks) {
648-
expect_worker_thread::<Traits>();
648+
expect_worker_thread();
649649
log::trace!("pend_tick_after({tick_count_delta:?})");
650650

651651
// Calculate when `timer_tick` should be called
@@ -663,15 +663,15 @@ impl State {
663663
}
664664

665665
pub fn pend_tick<Traits: PortInstance>(&'static self) {
666-
expect_worker_thread::<Traits>();
666+
expect_worker_thread();
667667
log::trace!("pend_tick");
668668

669669
self.pend_interrupt_line::<Traits>(INTERRUPT_LINE_TIMER)
670670
.unwrap();
671671
}
672672

673673
extern "C" fn timer_handler<Traits: PortInstance>() {
674-
assert_eq!(expect_worker_thread::<Traits>(), ThreadRole::Interrupt);
674+
assert_eq!(expect_worker_thread(), ThreadRole::Interrupt);
675675
log::trace!("timer_handler");
676676

677677
// Safety: CPU Lock inactive, an interrupt context
@@ -680,7 +680,7 @@ impl State {
680680
}
681681

682682
/// Assert that the current thread is a worker thread of `Traits`.
683-
fn expect_worker_thread<Traits: PortInstance>() -> ThreadRole {
683+
fn expect_worker_thread() -> ThreadRole {
684684
// TODO: Check that the current worker thread belongs to
685685
// `Traits::port_state().thread_group`
686686
let role = THREAD_ROLE.with(|r| r.get());

0 commit comments

Comments
 (0)