Skip to content

Commit 5c59e72

Browse files
committed
fix: migrate to 2024 edition and fmt
1 parent 1e809d9 commit 5c59e72

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

rtic/src/export/cortex_basepri.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use super::cortex_logical2hw;
22
use cortex_m::register::{basepri, basepri_max};
33
pub use cortex_m::{
4+
Peripherals,
45
asm::wfi,
56
interrupt,
6-
peripheral::{scb::SystemHandler, DWT, SCB, SYST},
7-
Peripherals,
7+
peripheral::{DWT, SCB, SYST, scb::SystemHandler},
88
};
99

1010
#[cfg(not(any(feature = "thumbv7-backend", feature = "thumbv8main-backend")))]
@@ -69,13 +69,15 @@ pub unsafe fn lock<T, R>(
6969
nvic_prio_bits: u8,
7070
f: impl FnOnce(&mut T) -> R,
7171
) -> R {
72-
if ceiling == (1 << nvic_prio_bits) {
73-
critical_section::with(|_| f(&mut *ptr))
74-
} else {
75-
let current = basepri::read();
76-
basepri_max::write(cortex_logical2hw(ceiling, nvic_prio_bits));
77-
let r = f(&mut *ptr);
78-
basepri::write(current);
79-
r
72+
unsafe {
73+
if ceiling == (1 << nvic_prio_bits) {
74+
critical_section::with(|_| f(&mut *ptr))
75+
} else {
76+
let current = basepri::read();
77+
basepri_max::write(cortex_logical2hw(ceiling, nvic_prio_bits));
78+
let r = f(&mut *ptr);
79+
basepri::write(current);
80+
r
81+
}
8082
}
8183
}

rtic/src/export/cortex_source_mask.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pub use cortex_m::{
2+
Peripherals,
23
asm::wfi,
34
interrupt,
4-
peripheral::{scb::SystemHandler, DWT, NVIC, SCB, SYST},
5-
Peripherals,
5+
peripheral::{DWT, NVIC, SCB, SYST, scb::SystemHandler},
66
};
77

88
#[cfg(not(any(feature = "thumbv6-backend", feature = "thumbv8base-backend")))]
@@ -57,7 +57,9 @@ impl<const M: usize> Mask<M> {
5757
let block = bit / 32;
5858

5959
if block as usize >= M {
60-
panic!("Generating masks for thumbv6/thumbv8m.base failed! Are you compiling for thumbv6 on an thumbv7 MCU or using an unsupported thumbv8m.base MCU?");
60+
panic!(
61+
"Generating masks for thumbv6/thumbv8m.base failed! Are you compiling for thumbv6 on an thumbv7 MCU or using an unsupported thumbv8m.base MCU?"
62+
);
6163
}
6264

6365
let offset = bit - (block * 32);

rtic/src/export/executor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ unsafe fn waker_clone(p: *const ()) -> RawWaker {
1717
unsafe fn waker_wake(p: *const ()) {
1818
// The only thing we need from a waker is the function to call to pend the async
1919
// dispatcher.
20-
let f: fn() = mem::transmute(p);
20+
let f: fn() = unsafe { mem::transmute(p) };
2121
f();
2222
}
2323

@@ -81,7 +81,7 @@ macro_rules! from_ptr_n_args {
8181
($name:ident, $($t:ident),*) => {
8282
#[inline(always)]
8383
pub unsafe fn $name<$($t,)* Fun: Fn($($t,)*) -> F>(_f: Fun, ptr: &AsyncTaskExecutorPtr) -> &Self {
84-
&*(ptr.get() as *const _)
84+
unsafe { &*(ptr.get() as *const _) }
8585
}
8686
};
8787
}

rtic/src/export/riscv_esp32c6.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pub use esp32c6::{Interrupt, Peripherals};
21
use esp32c6::{INTERRUPT_CORE0, PLIC_MX};
2+
pub use esp32c6::{Interrupt, Peripherals};
33
pub use riscv::interrupt;
44
pub use riscv::register::mcause;
55

rtic/src/export/slic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub use riscv_slic::{lock, pend, run, InterruptNumber};
1+
pub use riscv_slic::{InterruptNumber, lock, pend, run};
22

33
#[cfg(all(
44
feature = "riscv-slic",

rtic/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
#![allow(clippy::inline_always)]
3434
#![allow(unexpected_cfgs)]
3535

36-
pub use rtic_core::{prelude as mutex_prelude, Exclusive, Mutex};
36+
pub use rtic_core::{Exclusive, Mutex, prelude as mutex_prelude};
3737
pub use rtic_macros::app;
3838

3939
/// module `mutex::prelude` provides `Mutex` and multi-lock variants. Recommended over `mutex_prelude`
4040
pub mod mutex {
41-
pub use rtic_core::prelude;
4241
pub use rtic_core::Mutex;
42+
pub use rtic_core::prelude;
4343
}
4444

4545
#[doc(hidden)]

0 commit comments

Comments
 (0)