Skip to content

Commit 760102e

Browse files
authored
Clippy CI (#108)
* update clippy CI script * update clippy CI script * update CI scripts
1 parent 0b3ea14 commit 760102e

File tree

13 files changed

+64
-63
lines changed

13 files changed

+64
-63
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
- stm32g070
1818
- stm32g071
1919
- stm32g081
20-
2120
steps:
2221
- uses: actions/checkout@v2
2322
- uses: actions-rs/toolchain@v1
@@ -26,6 +25,5 @@ jobs:
2625
toolchain: ${{ matrix.rust }}
2726
target: thumbv6m-none-eabi
2827
override: true
29-
3028
- name: Regular build
31-
run: cargo check --features ${{ matrix.feature }}
29+
run: cargo check --features ${{ matrix.feature }}

.github/workflows/clippy.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,26 @@ name: Clippy check
77
jobs:
88
clippy_check:
99
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
rust:
13+
- stable
14+
feature:
15+
- stm32g030
16+
- stm32g031
17+
- stm32g041
18+
- stm32g070
19+
- stm32g071
20+
- stm32g081
1021
steps:
1122
- uses: actions/checkout@v1
1223
- run: rustup component add clippy
1324
- uses: actions-rs/toolchain@v1
1425
with:
15-
toolchain: stable
26+
toolchain: ${{ matrix.rust }}
1627
target: thumbv6m-none-eabi
1728
override: true
1829
- uses: actions-rs/clippy-check@v1
1930
with:
2031
token: ${{ secrets.GITHUB_TOKEN }}
21-
args: --features=stm32g031 --target thumbv6m-none-eabi
32+
args: --target thumbv6m-none-eabi --features ${{ matrix.feature }}

.github/workflows/rustfmt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- uses: actions-rs/cargo@v1
2121
with:
2222
command: fmt
23-
args: --all -- --check
23+
args: --all -- --check

.vscode/settings.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
{
2-
"rust.all_targets": false,
3-
"rust.target": "thumbv6m-none-eabi",
4-
"rust.all_features": false,
5-
"rust.features": [
6-
"rt",
7-
"stm32g081"
8-
],
92
"rust-analyzer.checkOnSave.allTargets": false,
103
"rust-analyzer.checkOnSave.extraArgs": [
114
"--target",
125
"thumbv6m-none-eabi"
136
],
147
"rust-analyzer.cargo.features": [
158
"rt",
16-
"stm32g081"
9+
"stm32g071"
1710
]
18-
}
11+
}

src/analog/adc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::stm32::ADC;
77
use hal::adc::{Channel, OneShot};
88

99
/// ADC Result Alignment
10-
#[derive(PartialEq)]
10+
#[derive(Eq, PartialEq)]
1111
pub enum Align {
1212
/// Right aligned results (least significant bits)
1313
///
@@ -23,7 +23,7 @@ pub enum Align {
2323
}
2424

2525
/// ADC Sampling Precision
26-
#[derive(Copy, Clone, PartialEq)]
26+
#[derive(Copy, Clone, PartialEq, Eq)]
2727
pub enum Precision {
2828
/// 12 bit precision
2929
B_12 = 0b00,
@@ -36,7 +36,7 @@ pub enum Precision {
3636
}
3737

3838
/// ADC Sampling time
39-
#[derive(Copy, Clone, PartialEq)]
39+
#[derive(Copy, Clone, PartialEq, Eq)]
4040
pub enum SampleTime {
4141
T_2 = 0b000,
4242
T_4 = 0b001,
@@ -49,7 +49,7 @@ pub enum SampleTime {
4949
}
5050

5151
// ADC Oversampling ratio
52-
#[derive(Copy, Clone, PartialEq)]
52+
#[derive(Copy, Clone, PartialEq, Eq)]
5353
pub enum OversamplingRatio {
5454
X_2 = 0b000,
5555
X_4 = 0b001,
@@ -88,7 +88,7 @@ pub enum AsyncClockDiv {
8888
}
8989

9090
/// ADC injected trigger source selection
91-
#[derive(Copy, Clone, PartialEq)]
91+
#[derive(Copy, Clone, PartialEq, Eq)]
9292
pub enum InjTrigSource {
9393
TRG_0 = 0b000, // TIM1_TRGO2
9494
TRG_1 = 0b001, // TIM1_CC4

src/dma.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//! Direct Memory Access Engine
2-
use crate::dmamux::{self, DmaMuxIndex};
3-
use crate::rcc::{Enable, Rcc, Reset};
4-
use crate::stm32::{self, DMA, DMAMUX};
5-
6-
use crate::dmamux::DmaMuxExt;
2+
use crate::dmamux::DmaMuxIndex;
3+
use crate::rcc::Rcc;
4+
use crate::stm32::DMAMUX;
75

86
/// Extension trait to split a DMA peripheral into independent channels
97
pub trait DmaExt {
@@ -58,7 +56,7 @@ impl From<Direction> for bool {
5856
}
5957

6058
#[doc = "Peripheral size"]
61-
#[derive(Clone, Copy, Debug, PartialEq)]
59+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
6260
#[repr(u8)]
6361
pub enum WordSize {
6462
#[doc = "0: 8-bit size"]
@@ -239,6 +237,8 @@ pub trait Channel: private::Channel {
239237
}
240238
}
241239

240+
// TODO: Blocked by https://github.com/stm32-rs/stm32-rs/pull/695
241+
#[cfg(any(feature = "stm32g030", feature = "stm32g031", feature = "stm32g041"))]
242242
macro_rules! dma {
243243
(
244244
channels: {
@@ -250,6 +250,11 @@ macro_rules! dma {
250250
), )+
251251
},
252252
) => {
253+
use crate::dmamux;
254+
use crate::rcc::{Enable, Reset};
255+
use crate::stm32::{self, DMA};
256+
257+
use crate::dmamux::DmaMuxExt;
253258

254259
/// DMA channels
255260
pub struct Channels {
@@ -322,21 +327,8 @@ macro_rules! dma {
322327
}
323328
}
324329

325-
#[cfg(any(feature = "stm32g070", feature = "stm32g071"))]
326-
dma!(
327-
channels: {
328-
C1: (ch1, htif1, tcif1, teif1, gif1, chtif1, ctcif1, cteif1, cgif1, C0),
329-
C2: (ch2, htif2, tcif2, teif2, gif2, chtif2, ctcif2, cteif2, cgif2, C1),
330-
C3: (ch3, htif3, tcif3, teif3, gif3, chtif3, ctcif3, cteif3, cgif3, C2),
331-
C4: (ch4, htif4, tcif4, teif4, gif4, chtif4, ctcif4, cteif4, cgif4, C3),
332-
C5: (ch5, htif5, tcif5, teif5, gif5, chtif5, ctcif5, cteif5, cgif5, C4),
333-
C6: (ch6, htif6, tcif6, teif6, gif6, chtif6, ctcif6, cteif6, cgif6, C5),
334-
C7: (ch7, htif7, tcif7, teif7, gif7, chtif7, ctcif7, cteif7, cgif7, C6),
335-
},
336-
);
337-
338330
// TODO: Blocked by https://github.com/stm32-rs/stm32-rs/pull/695
339-
// #[cfg(feature = "stm32g081")]
331+
// #[cfg(any(feature = "stm32g070", feature = "stm32g071", feature = "stm32g081"))]
340332
// dma!(
341333
// channels: {
342334
// C1: (ch1, htif1, tcif1, teif1, gif1, chtif1, ctcif1, cteif1, cgif1, C0),
@@ -360,6 +352,7 @@ dma!(
360352
},
361353
);
362354

355+
#[cfg(any(feature = "stm32g030", feature = "stm32g031", feature = "stm32g041"))]
363356
impl DmaExt for DMA {
364357
type Channels = Channels;
365358

src/exti.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::gpio::SignalEdge;
33
use crate::stm32::EXTI;
44

55
/// EXTI trigger event
6-
#[derive(PartialEq, PartialOrd, Clone, Copy)]
6+
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy)]
77
pub enum Event {
88
GPIO0 = 0,
99
GPIO1 = 1,

src/i2c/blocking.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ macro_rules! i2c {
231231

232232
// Wait for any previous address sequence to end automatically.
233233
// This could be up to 50% of a bus cycle (ie. up to 0.5/freq)
234-
while self.i2c.cr2.read().start().bit_is_set() { () };
234+
while self.i2c.cr2.read().start().bit_is_set() {};
235235

236236
// flush i2c tx register
237237
self.i2c.isr.write(|w| w.txe().set_bit());
@@ -308,7 +308,7 @@ macro_rules! i2c {
308308

309309
// Wait for any previous address sequence to end automatically.
310310
// This could be up to 50% of a bus cycle (ie. up to 0.5/freq)
311-
while self.i2c.cr2.read().start().bit_is_set() { () };
311+
while self.i2c.cr2.read().start().bit_is_set() {};
312312

313313
self.i2c.cr2.modify(|_, w| unsafe {
314314
w
@@ -349,7 +349,7 @@ macro_rules! i2c {
349349

350350
// Wait for any previous address sequence to end automatically.
351351
// This could be up to 50% of a bus cycle (ie. up to 0.5/freq)
352-
while self.i2c.cr2.read().start().bit_is_set() { () };
352+
while self.i2c.cr2.read().start().bit_is_set() {};
353353
// Flush rxdr register
354354
let _ = self.i2c.rxdr.read().rxdata().bits();
355355

@@ -392,8 +392,7 @@ macro_rules! i2c {
392392

393393
fn slave_wait_addressed(&mut self) -> Result<(u16, I2cDirection), Error>{
394394
// blocking wait until addressed
395-
while self.i2c.isr.read().addr().bit_is_clear()
396-
{ () };
395+
while self.i2c.isr.read().addr().bit_is_clear() {};
397396

398397

399398
let isr = self.i2c.isr.read();

src/rng.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ macro_rules! rng_core {
170170
let mut i = 0_usize;
171171
while i < buffer.len() {
172172
let random_word = self.gen()?;
173+
174+
#[allow(clippy::transmute_num_to_bytes)]
173175
let bytes: [$type; BATCH_SIZE] = unsafe { mem::transmute(random_word) };
174176
let n = cmp::min(BATCH_SIZE, buffer.len() - i);
175177
buffer[i..i + n].copy_from_slice(&bytes[..n]);

src/serial/config.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
use crate::prelude::*;
22
use crate::time::Bps;
33

4-
#[derive(PartialEq, PartialOrd, Clone, Copy)]
4+
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy)]
55
pub enum WordLength {
66
DataBits7,
77
DataBits8,
88
DataBits9,
99
}
1010

11-
#[derive(PartialEq, PartialOrd, Clone, Copy)]
11+
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy)]
1212
pub enum Parity {
1313
ParityNone,
1414
ParityEven,
1515
ParityOdd,
1616
}
1717

18-
#[derive(PartialEq, PartialOrd, Clone, Copy, Debug)]
18+
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy, Debug)]
1919
pub enum StopBits {
2020
#[doc = "1 stop bit"]
2121
STOP1 = 0b00,
@@ -33,7 +33,7 @@ impl StopBits {
3333
}
3434
}
3535

36-
#[derive(PartialEq, PartialOrd, Clone, Copy, Debug)]
36+
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy, Debug)]
3737
pub enum FifoThreshold {
3838
#[doc = "1/8 of its depth"]
3939
FIFO_1_BYTE = 0b000,
@@ -54,7 +54,7 @@ impl FifoThreshold {
5454
self as u8
5555
}
5656
}
57-
#[derive(PartialEq, PartialOrd, Clone, Copy)]
57+
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy)]
5858
pub struct BasicConfig {
5959
pub(crate) baudrate: Bps,
6060
pub(crate) wordlength: WordLength,
@@ -63,7 +63,7 @@ pub struct BasicConfig {
6363
pub(crate) swap: bool,
6464
}
6565

66-
#[derive(PartialEq, PartialOrd, Clone, Copy)]
66+
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy)]
6767
pub struct FullConfig {
6868
pub(crate) baudrate: Bps,
6969
pub(crate) wordlength: WordLength,

0 commit comments

Comments
 (0)