Skip to content

Commit 97db8f0

Browse files
authored
Merge pull request #512 from usbalbin/clippy
Fix some clippy warnings
2 parents 99fb744 + d753c9a commit 97db8f0

File tree

21 files changed

+61
-125
lines changed

21 files changed

+61
-125
lines changed

examples/mdma.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ fn main() -> ! {
195195
Transfer::init_master(
196196
streams.1,
197197
MemoryToMemory::new(),
198-
unsafe { mem::transmute(&mut target_buffer[..]) }, // Dest: TCM (stack)
198+
unsafe {
199+
mem::transmute::<&mut [u8], &mut [u8]>(&mut target_buffer[..])
200+
}, // Dest: TCM (stack)
199201
Some(source_buffer), // Source: TCM (stack)
200202
config,
201203
)

examples/qspi_mdma.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ fn main() -> ! {
108108
_,
109109
> = Transfer::init_master(
110110
streams.0,
111-
qspi, // Dest: QSPI
112-
unsafe { mem::transmute(&mut source_buffer) }, // Source: TCM (stack)
111+
qspi, // Dest: QSPI
112+
unsafe {
113+
mem::transmute::<&mut [u8; 80], &mut [u8; 80]>(&mut source_buffer)
114+
}, // Source: TCM (stack)
113115
None,
114116
config,
115117
);

src/adc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ macro_rules! adc_hal {
597597
#[cfg(not(feature = "revision_v"))]
598598
let f_target = f_adc.raw();
599599

600-
let (divider, presc) = match (ker_ck.raw() + f_target - 1) / f_target {
600+
let (divider, presc) = match ker_ck.raw().div_ceil(f_target) {
601601
1 => (1, PRESC_A::Div1),
602602
2 => (2, PRESC_A::Div2),
603603
3..=4 => (4, PRESC_A::Div4),

src/delay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a> Countdown<'a> {
110110
}
111111
}
112112

113-
impl<'a> CountDown for Countdown<'a> {
113+
impl CountDown for Countdown<'_> {
114114
type Time = fugit::MicrosDurationU32;
115115

116116
fn start<T>(&mut self, count: T)

src/dma/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -992,9 +992,9 @@ where
992992
/// MDMA block. The length is referred to the source size
993993
///
994994
/// * `s_len`: The number of input words of s_size available. `None` if the
995-
/// source is a peripheral
995+
/// source is a peripheral
996996
/// * `d_len`: The number of input words of d_size available. `None` if the
997-
/// destination is a peripheral
997+
/// destination is a peripheral
998998
///
999999
/// `s_len` and `d_len` cannot both be peripherals (None)
10001000
fn m_number_of_bytes(
@@ -1052,24 +1052,24 @@ where
10521052
/// # Panics
10531053
///
10541054
/// * When a memory-memory transfer is specified but the `second_buf`
1055-
/// argument is `None`.
1055+
/// argument is `None`.
10561056
///
10571057
/// * When the length is greater than 65536 bytes.
10581058
///
10591059
/// * When `config` specifies a `source_increment` that is smaller than the
1060-
/// source size.
1060+
/// source size.
10611061
///
10621062
/// * When `config` specifies a `destination_increment` that is smaller than
1063-
/// the destination size.
1063+
/// the destination size.
10641064
///
10651065
/// * When `config` specifies a `transfer_length` that is not a multiple of
1066-
/// both the source and destination sizes.
1066+
/// both the source and destination sizes.
10671067
///
10681068
/// * When `config` specifies a `packing_alignment` that extends the source,
1069-
/// but the source size is larger than the destination size.
1069+
/// but the source size is larger than the destination size.
10701070
///
10711071
/// * When `config` specifies a `packing_alignment` that truncates the
1072-
/// source, but the source size is smaller than the destination size.
1072+
/// source, but the source size is smaller than the destination size.
10731073
pub fn init_master(
10741074
mut stream: STREAM,
10751075
peripheral: PERIPHERAL,

src/dma/traits.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ pub trait MasterStream: Stream + Sealed {
193193
/// # Safety
194194
///
195195
/// Must have the same alignment as configured for the transfer
196-
197196
unsafe fn set_source_address(&mut self, value: usize);
198197

199198
/// Set the destination for the Master DMA stream

src/ethernet/eth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ impl StationManagement for EthernetMAC {
802802
/// Define TxToken type and implement consume method
803803
pub struct TxToken<'a, const TD: usize>(&'a mut TDesRing<TD>);
804804

805-
impl<'a, const TD: usize> phy::TxToken for TxToken<'a, TD> {
805+
impl<const TD: usize> phy::TxToken for TxToken<'_, TD> {
806806
fn consume<R, F>(self, len: usize, f: F) -> R
807807
where
808808
F: FnOnce(&mut [u8]) -> R,
@@ -818,7 +818,7 @@ impl<'a, const TD: usize> phy::TxToken for TxToken<'a, TD> {
818818
/// Define RxToken type and implement consume method
819819
pub struct RxToken<'a, const RD: usize>(&'a mut RDesRing<RD>);
820820

821-
impl<'a, const RD: usize> phy::RxToken for RxToken<'a, RD> {
821+
impl<const RD: usize> phy::RxToken for RxToken<'_, RD> {
822822
fn consume<R, F>(self, f: F) -> R
823823
where
824824
F: FnOnce(&[u8]) -> R,

src/flash/operations.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ impl UnlockedFlashBank<'_> {
270270
}
271271
}
272272

273-
impl<'a> ErrorType for UnlockedFlashBank<'a> {
273+
impl ErrorType for UnlockedFlashBank<'_> {
274274
type Error = Error;
275275
}
276-
impl<'a> ReadNorFlash for UnlockedFlashBank<'a> {
276+
impl ReadNorFlash for UnlockedFlashBank<'_> {
277277
const READ_SIZE: usize = 1;
278278

279279
fn read(
@@ -291,7 +291,7 @@ impl<'a> ReadNorFlash for UnlockedFlashBank<'a> {
291291
}
292292
}
293293

294-
impl<'a> NorFlash for UnlockedFlashBank<'a> {
294+
impl NorFlash for UnlockedFlashBank<'_> {
295295
const WRITE_SIZE: usize = super::WRITE_SIZE;
296296
const ERASE_SIZE: usize = super::SECTOR_SIZE;
297297

src/fmc.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ impl FmcExt for stm32::FMC {
125125

126126
// Calculate kernel clock
127127
let fmc_ker_ck = match clk_sel {
128-
rec::FmcClkSel::RccHclk3 => {
129-
Some(clocks.hclk()).expect("FMC: HCLK must be enabled")
130-
}
128+
rec::FmcClkSel::RccHclk3 => clocks.hclk(),
131129
rec::FmcClkSel::Pll1Q => {
132130
clocks.pll1_q_ck().expect("FMC: PLL1_Q must be enabled")
133131
}

src/gpio.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
//! - **Dynamic**: Pin mode is selected at runtime. See changing configurations for more details
2828
//! - Input
2929
//! - **PullUp**: Input connected to high with a weak pull up resistor. Will be high when nothing
30-
//! is connected
30+
//! is connected
3131
//! - **PullDown**: Input connected to high with a weak pull up resistor. Will be low when nothing
32-
//! is connected
32+
//! is connected
3333
//! - **Floating**: Input not pulled to high or low. Will be undefined when nothing is connected
3434
//! - Output
3535
//! - **PushPull**: Output which either drives the pin high or low
3636
//! - **OpenDrain**: Output which leaves the gate floating, or pulls it do ground in drain
37-
//! mode. Can be used as an input in the `open` configuration
37+
//! mode. Can be used as an input in the `open` configuration
3838
//!
3939
//! ## Changing modes
4040
//! The simplest way to change the pin mode is to use the `into_<mode>` functions. These return a

0 commit comments

Comments
 (0)