Skip to content

Enforce clippy in CI #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ status = [
"test (nightly, x86_64-unknown-linux-gnu)",
"test (nightly, thumbv6m-none-eabi)",
"test (nightly, thumbv7m-none-eabi)",
"clippy",
"fmt",
]
6 changes: 2 additions & 4 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ jobs:
profile: minimal
# embedded-hal-async needs nightly.
# Use a pinned version to avoid spontaneous breakages (new clippy lints are added often)
toolchain: nightly-2022-09-05
toolchain: nightly-2022-09-25
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: cargo clippy -- --deny=warnings
20 changes: 10 additions & 10 deletions embedded-hal-async/src/digital.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub trait Wait: embedded_hal::digital::ErrorType {
/// # Note for implementers
/// The pin may have switched back to low before the task was run after
/// being woken. The future should still resolve in that case.
fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a>;
fn wait_for_high(&mut self) -> Self::WaitForHighFuture<'_>;

/// The future returned by `wait_for_low`.
type WaitForLowFuture<'a>: Future<Output = Result<(), Self::Error>>
Expand All @@ -42,7 +42,7 @@ pub trait Wait: embedded_hal::digital::ErrorType {
/// # Note for implementers
/// The pin may have switched back to high before the task was run after
/// being woken. The future should still resolve in that case.
fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a>;
fn wait_for_low(&mut self) -> Self::WaitForLowFuture<'_>;

/// The future returned from `wait_for_rising_edge`.
type WaitForRisingEdgeFuture<'a>: Future<Output = Result<(), Self::Error>>
Expand All @@ -53,7 +53,7 @@ pub trait Wait: embedded_hal::digital::ErrorType {
///
/// If the pin is already high, this does *not* return immediately, it'll wait for the
/// pin to go low and then high again.
fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a>;
fn wait_for_rising_edge(&mut self) -> Self::WaitForRisingEdgeFuture<'_>;

/// The future returned from `wait_for_falling_edge`.
type WaitForFallingEdgeFuture<'a>: Future<Output = Result<(), Self::Error>>
Expand All @@ -64,45 +64,45 @@ pub trait Wait: embedded_hal::digital::ErrorType {
///
/// If the pin is already low, this does *not* return immediately, it'll wait for the
/// pin to go high and then low again.
fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a>;
fn wait_for_falling_edge(&mut self) -> Self::WaitForFallingEdgeFuture<'_>;

/// The future returned from `wait_for_any_edge`.
type WaitForAnyEdgeFuture<'a>: Future<Output = Result<(), Self::Error>>
where
Self: 'a;

/// Wait for the pin to undergo any transition, i.e low to high OR high to low.
fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a>;
fn wait_for_any_edge(&mut self) -> Self::WaitForAnyEdgeFuture<'_>;
}

impl<T: Wait> Wait for &mut T {
type WaitForHighFuture<'a> = T::WaitForHighFuture<'a> where Self: 'a;

fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> {
fn wait_for_high(&mut self) -> Self::WaitForHighFuture<'_> {
T::wait_for_high(self)
}

type WaitForLowFuture<'a> = T::WaitForLowFuture<'a> where Self: 'a;

fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> {
fn wait_for_low(&mut self) -> Self::WaitForLowFuture<'_> {
T::wait_for_low(self)
}

type WaitForRisingEdgeFuture<'a> = T::WaitForRisingEdgeFuture<'a> where Self: 'a;

fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> {
fn wait_for_rising_edge(&mut self) -> Self::WaitForRisingEdgeFuture<'_> {
T::wait_for_rising_edge(self)
}

type WaitForFallingEdgeFuture<'a> = T::WaitForFallingEdgeFuture<'a> where Self: 'a;

fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> {
fn wait_for_falling_edge(&mut self) -> Self::WaitForFallingEdgeFuture<'_> {
T::wait_for_falling_edge(self)
}

type WaitForAnyEdgeFuture<'a> = T::WaitForAnyEdgeFuture<'a> where Self: 'a;

fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> {
fn wait_for_any_edge(&mut self) -> Self::WaitForAnyEdgeFuture<'_> {
T::wait_for_any_edge(self)
}
}
4 changes: 2 additions & 2 deletions embedded-hal-async/src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,13 @@ pub trait SpiBusFlush: ErrorType {
/// Wait until all operations have completed and the bus is idle.
///
/// See (the docs on embedded-hal)[embedded_hal::spi::blocking] for information on flushing.
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a>;
fn flush(&mut self) -> Self::FlushFuture<'_>;
}

impl<T: SpiBusFlush> SpiBusFlush for &mut T {
type FlushFuture<'a> = T::FlushFuture<'a> where Self: 'a;

fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> {
fn flush(&mut self) -> Self::FlushFuture<'_> {
T::flush(self)
}
}
Expand Down
1 change: 1 addition & 0 deletions embedded-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added
- Implement `PartialOrd`, `Ord`, `Hash` for `can::StandardId`, `can::ExtendedId` and `can::Id` according to CAN bus arbitration rules
- Implement `Eq` for `i2c::Operaiton`

### Fixed
- Fixed documentation for `wait_for_rising_edge`.
Expand Down
2 changes: 1 addition & 1 deletion embedded-hal/src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl AddressMode for TenBitAddress {}
/// Transactional I2C operation.
///
/// Several operations can be combined as part of a transaction.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be noted in the changelog.

pub enum Operation<'a> {
/// Read data into the provided buffer
Read(&'a mut [u8]),
Expand Down