From e75d43d3f08691a021b2a3a50381fac2a76e8af4 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Tue, 9 Jul 2024 06:23:19 -0700 Subject: [PATCH] Fix new clippy lints introduced in 1.78 & 1.79 (#1776) * Fix new clippy lints introduced in 1.78 & 1.79 * Patch semihosting --- esp-hal/src/analog/adc/mod.rs | 2 +- esp-hal/src/interrupt/riscv.rs | 9 ++++----- esp-hal/src/interrupt/xtensa.rs | 4 ++-- esp-hal/src/soc/esp32/cpu_control.rs | 6 ++++++ esp-hal/src/soc/esp32s3/cpu_control.rs | 6 ++++++ esp-ieee802154/src/lib.rs | 6 ++++-- hil-test/Cargo.toml | 3 +++ 7 files changed, 26 insertions(+), 10 deletions(-) diff --git a/esp-hal/src/analog/adc/mod.rs b/esp-hal/src/analog/adc/mod.rs index 2227e1bcc..133f04287 100644 --- a/esp-hal/src/analog/adc/mod.rs +++ b/esp-hal/src/analog/adc/mod.rs @@ -205,7 +205,7 @@ impl AdcCalScheme for () { } /// A helper trait to get access to ADC calibration efuses. -#[cfg(not(esp32h2))] +#[cfg(not(any(esp32, esp32s2, esp32h2)))] trait AdcCalEfuse { /// Get ADC calibration init code /// diff --git a/esp-hal/src/interrupt/riscv.rs b/esp-hal/src/interrupt/riscv.rs index afc5a4c92..309d20d6d 100644 --- a/esp-hal/src/interrupt/riscv.rs +++ b/esp-hal/src/interrupt/riscv.rs @@ -413,14 +413,13 @@ mod vectored { // this has no effect on level interrupts, but the interrupt may be an edge one // so we clear it anyway clear(core, cpu_intr); - - let configured_interrupts = get_configured_interrupts(core, status, unsafe { - core::mem::transmute(INTERRUPT_TO_PRIORITY[cpu_intr as usize - 1] as u8) - }); + let prio: Priority = + unsafe { core::mem::transmute(INTERRUPT_TO_PRIORITY[cpu_intr as usize - 1] as u8) }; + let configured_interrupts = get_configured_interrupts(core, status, prio); for interrupt_nr in configured_interrupts.iterator() { // Don't use `Interrupt::try_from`. It's slower and placed in flash - let interrupt = unsafe { core::mem::transmute(interrupt_nr as u16) }; + let interrupt: Interrupt = unsafe { core::mem::transmute(interrupt_nr as u16) }; handle_interrupt(interrupt, context); } } diff --git a/esp-hal/src/interrupt/xtensa.rs b/esp-hal/src/interrupt/xtensa.rs index 328d225ca..7a4421aec 100644 --- a/esp-hal/src/interrupt/xtensa.rs +++ b/esp-hal/src/interrupt/xtensa.rs @@ -476,7 +476,7 @@ mod vectored { for interrupt_nr in configured_interrupts.iterator() { // Don't use `Interrupt::try_from`. It's slower and placed in flash - let interrupt = unsafe { core::mem::transmute(interrupt_nr as u16) }; + let interrupt: Interrupt = unsafe { core::mem::transmute(interrupt_nr as u16) }; handle_interrupt(level, interrupt, save_frame); } } else { @@ -487,7 +487,7 @@ mod vectored { for interrupt_nr in configured_interrupts.iterator() { // Don't use `Interrupt::try_from`. It's slower and placed in flash - let interrupt = unsafe { core::mem::transmute(interrupt_nr as u16) }; + let interrupt: Interrupt = unsafe { core::mem::transmute(interrupt_nr as u16) }; handle_interrupt(level, interrupt, save_frame); } } diff --git a/esp-hal/src/soc/esp32/cpu_control.rs b/esp-hal/src/soc/esp32/cpu_control.rs index a0947f2a8..83436840e 100644 --- a/esp-hal/src/soc/esp32/cpu_control.rs +++ b/esp-hal/src/soc/esp32/cpu_control.rs @@ -84,6 +84,12 @@ pub struct Stack { pub mem: MaybeUninit<[u8; SIZE]>, } +impl Default for Stack { + fn default() -> Self { + Self::new() + } +} + #[allow(clippy::len_without_is_empty)] impl Stack { /// Construct a stack of length SIZE, uninitialized diff --git a/esp-hal/src/soc/esp32s3/cpu_control.rs b/esp-hal/src/soc/esp32s3/cpu_control.rs index 407448a04..fae7e47e1 100644 --- a/esp-hal/src/soc/esp32s3/cpu_control.rs +++ b/esp-hal/src/soc/esp32s3/cpu_control.rs @@ -84,6 +84,12 @@ pub struct Stack { pub mem: MaybeUninit<[u8; SIZE]>, } +impl Default for Stack { + fn default() -> Self { + Self::new() + } +} + #[allow(clippy::len_without_is_empty)] impl Stack { /// Construct a stack of length SIZE, uninitialized diff --git a/esp-ieee802154/src/lib.rs b/esp-ieee802154/src/lib.rs index 81b583876..b4f1d7bb2 100644 --- a/esp-ieee802154/src/lib.rs +++ b/esp-ieee802154/src/lib.rs @@ -225,7 +225,8 @@ impl<'a> Ieee802154<'a> { pub fn set_tx_done_callback(&mut self, callback: &'a mut (dyn FnMut() + Send)) { critical_section::with(|cs| { let mut tx_done_callback = TX_DONE_CALLBACK.borrow_ref_mut(cs); - tx_done_callback.replace(unsafe { core::mem::transmute(callback) }); + let cb: &'static mut (dyn FnMut() + Send) = unsafe { core::mem::transmute(callback) }; + tx_done_callback.replace(cb); }); } @@ -241,7 +242,8 @@ impl<'a> Ieee802154<'a> { pub fn set_rx_available_callback(&mut self, callback: &'a mut (dyn FnMut() + Send)) { critical_section::with(|cs| { let mut rx_available_callback = RX_AVAILABLE_CALLBACK.borrow_ref_mut(cs); - rx_available_callback.replace(unsafe { core::mem::transmute(callback) }); + let cb: &'static mut (dyn FnMut() + Send) = unsafe { core::mem::transmute(callback) }; + rx_available_callback.replace(cb); }); } diff --git a/hil-test/Cargo.toml b/hil-test/Cargo.toml index 33a82775d..9da5b2d3b 100644 --- a/hil-test/Cargo.toml +++ b/hil-test/Cargo.toml @@ -118,6 +118,9 @@ nb = "1.1.0" p192 = { version = "0.13.0", default-features = false, features = ["arithmetic"] } p256 = { version = "0.13.2", default-features = false, features = ["arithmetic"] } +[patch.crates-io] +semihosting = { git = "https://github.com/taiki-e/semihosting", tag = "v0.1.10" } + [features] default = ["async", "embassy", "embassy-time-timg0"]