diff --git a/esp-hal-embassy/CHANGELOG.md b/esp-hal-embassy/CHANGELOG.md index 741ba7a3d3..02f44c914a 100644 --- a/esp-hal-embassy/CHANGELOG.md +++ b/esp-hal-embassy/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- MSRV bump to 1.79 (#2156) + ### Fixed ### Removed diff --git a/esp-hal-embassy/Cargo.toml b/esp-hal-embassy/Cargo.toml index c080278ca4..77ffb37199 100644 --- a/esp-hal-embassy/Cargo.toml +++ b/esp-hal-embassy/Cargo.toml @@ -2,7 +2,7 @@ name = "esp-hal-embassy" version = "0.3.0" edition = "2021" -rust-version = "1.76.0" +rust-version = "1.79.0" description = "Embassy support for esp-hal" repository = "https://github.com/esp-rs/esp-hal" license = "MIT OR Apache-2.0" diff --git a/esp-hal-embassy/src/time_driver.rs b/esp-hal-embassy/src/time_driver.rs index 45f2125ef0..63e4c17fb8 100644 --- a/esp-hal-embassy/src/time_driver.rs +++ b/esp-hal-embassy/src/time_driver.rs @@ -36,11 +36,8 @@ pub(super) struct EmbassyTimer { alarms: Mutex<[AlarmState; MAX_SUPPORTED_ALARM_COUNT]>, } -#[allow(clippy::declare_interior_mutable_const)] -const ALARM_STATE_NONE: AlarmState = AlarmState::new(); - embassy_time_driver::time_driver_impl!(static DRIVER: EmbassyTimer = EmbassyTimer { - alarms: Mutex::new([ALARM_STATE_NONE; MAX_SUPPORTED_ALARM_COUNT]), + alarms: Mutex::new([const { AlarmState::new() }; MAX_SUPPORTED_ALARM_COUNT]), }); impl EmbassyTimer { diff --git a/esp-hal/src/gpio/mod.rs b/esp-hal/src/gpio/mod.rs index 9168914dd7..df03c5d67d 100644 --- a/esp-hal/src/gpio/mod.rs +++ b/esp-hal/src/gpio/mod.rs @@ -91,12 +91,13 @@ pub mod rtc_io; /// Convenience constant for `Option::None` pin -static USER_INTERRUPT_HANDLER: CFnPtr = CFnPtr::NULL; +static USER_INTERRUPT_HANDLER: CFnPtr = CFnPtr::new(); struct CFnPtr(AtomicPtr<()>); impl CFnPtr { - #[allow(clippy::declare_interior_mutable_const)] - pub const NULL: Self = Self(AtomicPtr::new(core::ptr::null_mut())); + pub const fn new() -> Self { + Self(AtomicPtr::new(core::ptr::null_mut())) + } pub fn store(&self, f: extern "C" fn()) { self.0.store(f as *mut (), Ordering::Relaxed); @@ -2488,9 +2489,8 @@ mod asynch { use super::*; - #[allow(clippy::declare_interior_mutable_const)] - const NEW_AW: AtomicWaker = AtomicWaker::new(); - pub(super) static PIN_WAKERS: [AtomicWaker; NUM_PINS] = [NEW_AW; NUM_PINS]; + pub(super) static PIN_WAKERS: [AtomicWaker; NUM_PINS] = + [const { AtomicWaker::new() }; NUM_PINS]; impl<'d, P> Flex<'d, P> where diff --git a/esp-hal/src/i2c.rs b/esp-hal/src/i2c.rs index 647ad54328..2b157e92b3 100644 --- a/esp-hal/src/i2c.rs +++ b/esp-hal/src/i2c.rs @@ -533,23 +533,14 @@ mod asynch { task::{Context, Poll}, }; - use cfg_if::cfg_if; use embassy_sync::waitqueue::AtomicWaker; use embedded_hal::i2c::Operation; use procmacros::handler; use super::*; - cfg_if! { - if #[cfg(all(i2c0, i2c1))] { - const NUM_I2C: usize = 2; - } else if #[cfg(i2c0)] { - const NUM_I2C: usize = 1; - } - } - #[allow(clippy::declare_interior_mutable_const)] - const INIT: AtomicWaker = AtomicWaker::new(); - static WAKERS: [AtomicWaker; NUM_I2C] = [INIT; NUM_I2C]; + const NUM_I2C: usize = 1 + cfg!(i2c1) as usize; + static WAKERS: [AtomicWaker; NUM_I2C] = [const { AtomicWaker::new() }; NUM_I2C]; #[cfg_attr(esp32, allow(dead_code))] pub(crate) enum Event { diff --git a/esp-hal/src/rmt.rs b/esp-hal/src/rmt.rs index fcd765c077..102b573ec2 100644 --- a/esp-hal/src/rmt.rs +++ b/esp-hal/src/rmt.rs @@ -1124,9 +1124,7 @@ pub mod asynch { #[cfg(not(any(esp32, esp32s3)))] const NUM_CHANNELS: usize = 4; - #[allow(clippy::declare_interior_mutable_const)] - const INIT: AtomicWaker = AtomicWaker::new(); - static WAKER: [AtomicWaker; NUM_CHANNELS] = [INIT; NUM_CHANNELS]; + static WAKER: [AtomicWaker; NUM_CHANNELS] = [const { AtomicWaker::new() }; NUM_CHANNELS]; #[must_use = "futures do nothing unless you `.await` or poll them"] pub(crate) struct RmtTxFuture diff --git a/esp-hal/src/timer/systimer.rs b/esp-hal/src/timer/systimer.rs index e8e4bdd974..a1fb75af7d 100644 --- a/esp-hal/src/timer/systimer.rs +++ b/esp-hal/src/timer/systimer.rs @@ -1026,9 +1026,7 @@ mod asynch { const NUM_ALARMS: usize = 3; - #[allow(clippy::declare_interior_mutable_const)] - const INIT: AtomicWaker = AtomicWaker::new(); - static WAKERS: [AtomicWaker; NUM_ALARMS] = [INIT; NUM_ALARMS]; + static WAKERS: [AtomicWaker; NUM_ALARMS] = [const { AtomicWaker::new() }; NUM_ALARMS]; #[must_use = "futures do nothing unless you `.await` or poll them"] pub(crate) struct AlarmFuture<'a, COMP: Comparator, UNIT: Unit> { diff --git a/esp-hal/src/touch.rs b/esp-hal/src/touch.rs index 3005d2e298..be397dc10b 100644 --- a/esp-hal/src/touch.rs +++ b/esp-hal/src/touch.rs @@ -536,9 +536,8 @@ mod asynch { const NUM_TOUCH_PINS: usize = 10; - #[allow(clippy::declare_interior_mutable_const)] - const NEW_AW: AtomicWaker = AtomicWaker::new(); - static TOUCH_WAKERS: [AtomicWaker; NUM_TOUCH_PINS] = [NEW_AW; NUM_TOUCH_PINS]; + static TOUCH_WAKERS: [AtomicWaker; NUM_TOUCH_PINS] = + [const { AtomicWaker::new() }; NUM_TOUCH_PINS]; // Helper variable to store which pins need handling. static TOUCHED_PINS: AtomicU16 = AtomicU16::new(0); diff --git a/esp-hal/src/twai/mod.rs b/esp-hal/src/twai/mod.rs index 30c451cd1a..04366586ee 100644 --- a/esp-hal/src/twai/mod.rs +++ b/esp-hal/src/twai/mod.rs @@ -1641,10 +1641,9 @@ mod asynch { } } - const NUM_TWAI: usize = 2; - #[allow(clippy::declare_interior_mutable_const)] - const NEW_STATE: TwaiAsyncState = TwaiAsyncState::new(); - pub(crate) static TWAI_STATE: [TwaiAsyncState; NUM_TWAI] = [NEW_STATE; NUM_TWAI]; + const NUM_TWAI: usize = 1 + cfg!(twai1) as usize; + pub(crate) static TWAI_STATE: [TwaiAsyncState; NUM_TWAI] = + [const { TwaiAsyncState::new() }; NUM_TWAI]; impl Twai<'_, T, crate::Async> where diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index 8461e561da..35134be4e3 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -1849,7 +1849,6 @@ where mod asynch { use core::task::Poll; - use cfg_if::cfg_if; use embassy_sync::waitqueue::AtomicWaker; use enumset::{EnumSet, EnumSetType}; use procmacros::handler; @@ -1857,20 +1856,10 @@ mod asynch { use super::*; use crate::Async; - cfg_if! { - if #[cfg(all(uart0, uart1, uart2))] { - const NUM_UART: usize = 3; - } else if #[cfg(all(uart0, uart1))] { - const NUM_UART: usize = 2; - } else if #[cfg(uart0)] { - const NUM_UART: usize = 1; - } - } + const NUM_UART: usize = 1 + cfg!(uart1) as usize + cfg!(uart2) as usize; - #[allow(clippy::declare_interior_mutable_const)] - const INIT: AtomicWaker = AtomicWaker::new(); - static TX_WAKERS: [AtomicWaker; NUM_UART] = [INIT; NUM_UART]; - static RX_WAKERS: [AtomicWaker; NUM_UART] = [INIT; NUM_UART]; + static TX_WAKERS: [AtomicWaker; NUM_UART] = [const { AtomicWaker::new() }; NUM_UART]; + static RX_WAKERS: [AtomicWaker; NUM_UART] = [const { AtomicWaker::new() }; NUM_UART]; #[derive(EnumSetType, Debug)] pub(crate) enum TxEvent {