Skip to content

Commit

Permalink
Merge pull request #3239 from plaes/nrf-clippy
Browse files Browse the repository at this point in the history
nrf: Fix bunch of low-hanging clippy lint warnings
  • Loading branch information
Dirbaio authored Aug 8, 2024
2 parents f31e718 + 2e8d9db commit 3afc5e4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
7 changes: 7 additions & 0 deletions embassy-nrf/src/buffered_uarte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P = U> + 'd,
timer: impl Peripheral<P = T> + 'd,
Expand Down Expand Up @@ -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<P = U> + 'd,
timer: impl Peripheral<P = T> + 'd,
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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<P = U> + 'd,
timer: impl Peripheral<P = T> + 'd,
Expand Down Expand Up @@ -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<P = U> + 'd,
timer: impl Peripheral<P = T> + 'd,
Expand All @@ -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>,
Expand All @@ -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>,
Expand Down
24 changes: 16 additions & 8 deletions embassy-nrf/src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}

Expand Down Expand Up @@ -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(())
}
}

Expand Down Expand Up @@ -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(())
}
}

Expand Down Expand Up @@ -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(())
}
}

Expand Down
5 changes: 3 additions & 2 deletions embassy-nrf/src/wdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down

0 comments on commit 3afc5e4

Please sign in to comment.