From 7c8f57e5641857cab0f8df8277fd7165faf87ecb Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Thu, 8 Aug 2024 11:02:07 +0300 Subject: [PATCH 1/3] nrf: buffered_uarte: Add overrides for `too_many_arguments` lint One possible future fix for this could be refactoring at least ppi arguments into separate struct. --- embassy-nrf/src/buffered_uarte.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index b368a3d33..159b4db8f 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs @@ -219,6 +219,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { /// # Panics /// /// Panics if `rx_buffer.len()` is odd. + #[allow(clippy::too_many_arguments)] pub fn new( uarte: impl Peripheral

+ 'd, timer: impl Peripheral

+ 'd, @@ -254,6 +255,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { /// # Panics /// /// Panics if `rx_buffer.len()` is odd. + #[allow(clippy::too_many_arguments)] pub fn new_with_rtscts( uarte: impl Peripheral

+ 'd, timer: impl Peripheral

+ 'd, @@ -286,6 +288,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { ) } + #[allow(clippy::too_many_arguments)] fn new_inner( peri: PeripheralRef<'d, U>, timer: PeripheralRef<'d, T>, @@ -534,6 +537,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { /// # Panics /// /// Panics if `rx_buffer.len()` is odd. + #[allow(clippy::too_many_arguments)] pub fn new( uarte: impl Peripheral

+ 'd, timer: impl Peripheral

+ 'd, @@ -564,6 +568,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { /// # Panics /// /// Panics if `rx_buffer.len()` is odd. + #[allow(clippy::too_many_arguments)] pub fn new_with_rts( uarte: impl Peripheral

+ 'd, timer: impl Peripheral

+ 'd, @@ -590,6 +595,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { ) } + #[allow(clippy::too_many_arguments)] fn new_inner( peri: PeripheralRef<'d, U>, timer: PeripheralRef<'d, T>, @@ -614,6 +620,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { this } + #[allow(clippy::too_many_arguments)] fn new_innerer( peri: PeripheralRef<'d, U>, timer: PeripheralRef<'d, T>, From 2767b14a4e8ef501a6f02afa11758c0783c07cd4 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Thu, 8 Aug 2024 11:45:11 +0300 Subject: [PATCH 2/3] nrf: gpio: Fix return values for functions returning unit type - `()` --- embassy-nrf/src/gpio.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index 7b272dca0..dbc26ea3f 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs @@ -534,11 +534,13 @@ mod eh02 { type Error = Infallible; fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) + self.set_high(); + Ok(()) } fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) + self.set_low(); + Ok(()) } } @@ -580,11 +582,13 @@ mod eh02 { type Error = Infallible; fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) + self.set_high(); + Ok(()) } fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) + self.set_low(); + Ok(()) } } @@ -628,11 +632,13 @@ impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> { impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> { fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) + self.set_high(); + Ok(()) } fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) + self.set_low(); + Ok(()) } } @@ -665,11 +671,13 @@ impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> { impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> { fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) + self.set_high(); + Ok(()) } fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) + self.set_low(); + Ok(()) } } From 2e8d9dba1443d1bb9a621027df06b0f9ba0097bc Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Thu, 8 Aug 2024 11:54:50 +0300 Subject: [PATCH 3/3] nrf: wdt: Fix formatting for `Safety` section --- embassy-nrf/src/wdt.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/embassy-nrf/src/wdt.rs b/embassy-nrf/src/wdt.rs index 5a261ce8f..e4cfa3344 100644 --- a/embassy-nrf/src/wdt.rs +++ b/embassy-nrf/src/wdt.rs @@ -184,8 +184,9 @@ impl WatchdogHandle { /// Steal a watchdog handle by index. /// - /// Safety: watchdog must be initialized, index must be between 0 and N-1 where - /// N is the handle count when initializing. + /// # Safety + /// Watchdog must be initialized and `index` must be between `0` and `N-1` + /// where `N` is the handle count when initializing. pub unsafe fn steal(index: u8) -> Self { Self { index } }