diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 58f813bee..422eab62f 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -11,10 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@master + - uses: dtolnay/rust-toolchain@stable with: - # embedded-hal-async needs nightly. - # Use a pinned version to avoid spontaneous breakages (new clippy lints are added often) - toolchain: nightly-2023-10-14 components: clippy - run: cargo clippy --all-features -- --deny=warnings diff --git a/.github/workflows/rustdoc.yml b/.github/workflows/rustdoc.yml index 105d4e58c..7829e62b6 100644 --- a/.github/workflows/rustdoc.yml +++ b/.github/workflows/rustdoc.yml @@ -13,6 +13,6 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: nightly-2023-10-14 + toolchain: nightly-2024-07-26 # tokio/net required to workaround https://github.com/tokio-rs/tokio/issues/6165 - run: RUSTDOCFLAGS="--deny=warnings --cfg=docsrs" cargo doc --all-features --features tokio/net diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 6a3522c47..129eb2285 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -12,8 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@master + - uses: dtolnay/rust-toolchain@stable with: - toolchain: nightly components: rustfmt - run: cargo fmt --check diff --git a/embedded-hal-async/build.rs b/embedded-hal-async/build.rs deleted file mode 100644 index 78bd27ec7..000000000 --- a/embedded-hal-async/build.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::env; -use std::ffi::OsString; -use std::process::Command; - -fn main() { - println!("cargo:rerun-if-changed=build.rs"); - - let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); - - let output = Command::new(rustc) - .arg("--version") - .output() - .expect("failed to run `rustc --version`"); - - if String::from_utf8_lossy(&output.stdout).contains("nightly") { - println!("cargo:rustc-cfg=nightly"); - } -} diff --git a/embedded-hal-async/src/lib.rs b/embedded-hal-async/src/lib.rs index 44901deca..cbd74f5d4 100644 --- a/embedded-hal-async/src/lib.rs +++ b/embedded-hal-async/src/lib.rs @@ -1,12 +1,6 @@ #![doc = include_str!("../README.md")] #![warn(missing_docs)] #![no_std] -// disable warning for already-stabilized features. -// Needed to pass CI, because we deny warnings. -// We don't immediately remove them to not immediately break older nightlies. -// When all features are stable, we'll remove them. -#![cfg_attr(nightly, allow(stable_features, unknown_lints))] -#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))] #![allow(async_fn_in_trait)] pub mod delay; diff --git a/embedded-hal-bus/build.rs b/embedded-hal-bus/build.rs deleted file mode 100644 index 78bd27ec7..000000000 --- a/embedded-hal-bus/build.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::env; -use std::ffi::OsString; -use std::process::Command; - -fn main() { - println!("cargo:rerun-if-changed=build.rs"); - - let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); - - let output = Command::new(rustc) - .arg("--version") - .output() - .expect("failed to run `rustc --version`"); - - if String::from_utf8_lossy(&output.stdout).contains("nightly") { - println!("cargo:rustc-cfg=nightly"); - } -} diff --git a/embedded-hal-bus/src/lib.rs b/embedded-hal-bus/src/lib.rs index 396043a31..dfeca16e1 100644 --- a/embedded-hal-bus/src/lib.rs +++ b/embedded-hal-bus/src/lib.rs @@ -2,15 +2,6 @@ #![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(docsrs, feature(doc_cfg))] -// disable warning for already-stabilized features. -// Needed to pass CI, because we deny warnings. -// We don't immediately remove them to not immediately break older nightlies. -// When all features are stable, we'll remove them. -#![cfg_attr(all(feature = "async", nightly), allow(stable_features))] -#![cfg_attr( - all(feature = "async", nightly), - feature(async_fn_in_trait, impl_trait_projections) -)] // needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`. #[cfg(feature = "defmt-03")] diff --git a/embedded-hal-nb/src/spi.rs b/embedded-hal-nb/src/spi.rs index 06689db4c..75553c78b 100644 --- a/embedded-hal-nb/src/spi.rs +++ b/embedded-hal-nb/src/spi.rs @@ -13,13 +13,13 @@ pub use embedded_hal::spi::{ /// - Due to how full duplex SPI works each `read` call must be preceded by a `write` call. /// /// - `read` calls only return the data received with the last `write` call. -/// Previously received data is discarded +/// Previously received data is discarded /// /// - Data is only guaranteed to be clocked out when the `read` call succeeds. -/// The slave select line shouldn't be released before that. +/// The slave select line shouldn't be released before that. /// /// - Some SPIs can work with 8-bit *and* 16-bit words. You can overload this trait with different -/// `Word` types to allow operation in both modes. +/// `Word` types to allow operation in both modes. pub trait FullDuplex: ErrorType { /// Reads the word stored in the shift register /// diff --git a/embedded-hal/README.md b/embedded-hal/README.md index 79667661e..e47182b71 100644 --- a/embedded-hal/README.md +++ b/embedded-hal/README.md @@ -37,37 +37,37 @@ or a console to operate either on hardware serial ports or on virtual ones like The HAL - Must *erase* device specific details. Neither register, register blocks, nor magic values should -appear in the API. + appear in the API. - Must be generic *within* a device and *across* devices. The API to use a serial interface must -be the same regardless of whether the implementation uses the USART1 or UART4 peripheral of a -device or the UART0 peripheral of another device. + be the same regardless of whether the implementation uses the USART1 or UART4 peripheral of a + device or the UART0 peripheral of another device. - Where possible must *not* be tied to a specific asynchronous model. The API should be usable -in blocking mode, with the `futures` model, with an async/await model or with a callback model. -(cf. the [`nb`](https://docs.rs/nb) crate) + in blocking mode, with the `futures` model, with an async/await model or with a callback model. + (cf. the [`nb`](https://docs.rs/nb) crate) - Must be minimal, and thus easy to implement and zero cost, yet highly composable. People that -want higher level abstraction should *prefer to use this HAL* rather than *re-implement* -register manipulation code. + want higher level abstraction should *prefer to use this HAL* rather than *re-implement* + register manipulation code. - Serve as a foundation for building an ecosystem of platform-agnostic drivers. Here driver -means a library crate that lets a target platform interface an external device like a digital -sensor or a wireless transceiver. The advantage of this system is that by writing the driver as -a generic library on top of `embedded-hal` driver authors can support any number of target -platforms (e.g. Cortex-M microcontrollers, AVR microcontrollers, embedded Linux, etc.). The -advantage for application developers is that by adopting `embedded-hal` they can unlock all -these drivers for their platform. + means a library crate that lets a target platform interface an external device like a digital + sensor or a wireless transceiver. The advantage of this system is that by writing the driver as + a generic library on top of `embedded-hal` driver authors can support any number of target + platforms (e.g. Cortex-M microcontrollers, AVR microcontrollers, embedded Linux, etc.). The + advantage for application developers is that by adopting `embedded-hal` they can unlock all + these drivers for their platform. - Trait methods must be fallible so that they can be used in any possible situation. -Nevertheless, HAL implementations can additionally provide infallible versions of the same methods -if they can never fail in their platform. This way, generic code can use the fallible abstractions -provided here but platform-specific code can avoid fallibility-related boilerplate if possible. + Nevertheless, HAL implementations can additionally provide infallible versions of the same methods + if they can never fail in their platform. This way, generic code can use the fallible abstractions + provided here but platform-specific code can avoid fallibility-related boilerplate if possible. ## Out of scope - Initialization and configuration stuff like "ensure this serial interface and that SPI -interface are not using the same pins". The HAL will focus on *doing I/O*. + interface are not using the same pins". The HAL will focus on *doing I/O*. ## Platform agnostic drivers diff --git a/embedded-io-adapters/build.rs b/embedded-io-adapters/build.rs deleted file mode 100644 index 78bd27ec7..000000000 --- a/embedded-io-adapters/build.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::env; -use std::ffi::OsString; -use std::process::Command; - -fn main() { - println!("cargo:rerun-if-changed=build.rs"); - - let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); - - let output = Command::new(rustc) - .arg("--version") - .output() - .expect("failed to run `rustc --version`"); - - if String::from_utf8_lossy(&output.stdout).contains("nightly") { - println!("cargo:rustc-cfg=nightly"); - } -} diff --git a/embedded-io-adapters/src/futures_03.rs b/embedded-io-adapters/src/futures_03.rs index a40370a24..d1127a8c6 100644 --- a/embedded-io-adapters/src/futures_03.rs +++ b/embedded-io-adapters/src/futures_03.rs @@ -1,5 +1,10 @@ //! Adapters to/from `futures::io` traits. +// MSRV is 1.60 if you don't enable async, 1.80 if you do. +// Cargo.toml has 1.60, which makes Clippy complain that `poll_fn` was introduced +// in 1.64. So, just silence it for this file. +#![allow(clippy::incompatible_msrv)] + use core::future::poll_fn; use core::pin::Pin; diff --git a/embedded-io-adapters/src/lib.rs b/embedded-io-adapters/src/lib.rs index f9d0f1a5c..9d6628836 100644 --- a/embedded-io-adapters/src/lib.rs +++ b/embedded-io-adapters/src/lib.rs @@ -2,18 +2,6 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![warn(missing_docs)] #![doc = include_str!("../README.md")] -// disable warning for already-stabilized features. -// Needed to pass CI, because we deny warnings. -// We don't immediately remove them to not immediately break older nightlies. -// When all features are stable, we'll remove them. -#![cfg_attr( - all(any(feature = "tokio-1", feature = "futures-03"), nightly), - allow(stable_features) -)] -#![cfg_attr( - all(any(feature = "tokio-1", feature = "futures-03"), nightly), - feature(async_fn_in_trait, impl_trait_projections) -)] #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] diff --git a/embedded-io-adapters/src/tokio_1.rs b/embedded-io-adapters/src/tokio_1.rs index 418284b93..0dd4d265b 100644 --- a/embedded-io-adapters/src/tokio_1.rs +++ b/embedded-io-adapters/src/tokio_1.rs @@ -1,5 +1,10 @@ //! Adapters to/from `tokio::io` traits. +// MSRV is 1.60 if you don't enable async, 1.80 if you do. +// Cargo.toml has 1.60, which makes Clippy complain that `poll_fn` was introduced +// in 1.64. So, just silence it for this file. +#![allow(clippy::incompatible_msrv)] + use core::future::poll_fn; use core::pin::Pin; use core::task::Poll; diff --git a/embedded-io-async/build.rs b/embedded-io-async/build.rs deleted file mode 100644 index 78bd27ec7..000000000 --- a/embedded-io-async/build.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::env; -use std::ffi::OsString; -use std::process::Command; - -fn main() { - println!("cargo:rerun-if-changed=build.rs"); - - let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); - - let output = Command::new(rustc) - .arg("--version") - .output() - .expect("failed to run `rustc --version`"); - - if String::from_utf8_lossy(&output.stdout).contains("nightly") { - println!("cargo:rustc-cfg=nightly"); - } -} diff --git a/embedded-io-async/src/lib.rs b/embedded-io-async/src/lib.rs index 1171d42a0..7c0ac2d55 100644 --- a/embedded-io-async/src/lib.rs +++ b/embedded-io-async/src/lib.rs @@ -2,12 +2,6 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![warn(missing_docs)] #![doc = include_str!("../README.md")] -// disable warning for already-stabilized features. -// Needed to pass CI, because we deny warnings. -// We don't immediately remove them to not immediately break older nightlies. -// When all features are stable, we'll remove them. -#![cfg_attr(nightly, allow(stable_features, unknown_lints))] -#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))] #![allow(async_fn_in_trait)] #[cfg(feature = "alloc")] diff --git a/embedded-io/README.md b/embedded-io/README.md index d647ffe9d..04ea97771 100644 --- a/embedded-io/README.md +++ b/embedded-io/README.md @@ -15,9 +15,9 @@ targets. ## Differences with `std::io` - `Error` is an associated type. This allows each implementor to return its own error type, -while avoiding `dyn` or `Box`. This is consistent with how errors are handled in [`embedded-hal`](https://github.com/rust-embedded/embedded-hal/). + while avoiding `dyn` or `Box`. This is consistent with how errors are handled in [`embedded-hal`](https://github.com/rust-embedded/embedded-hal/). - In `std::io`, the `Read`/`Write` traits might be blocking or non-blocking (i.e. returning `WouldBlock` errors) depending on the file descriptor's mode, which is only known at run-time. This allows passing a non-blocking stream to code that expects a blocking -stream, causing unexpected errors. To solve this, `embedded-io` specifies `Read`/`Write` are always blocking, and adds new `ReadReady`/`WriteReady` traits to allow using streams in a non-blocking way. + stream, causing unexpected errors. To solve this, `embedded-io` specifies `Read`/`Write` are always blocking, and adds new `ReadReady`/`WriteReady` traits to allow using streams in a non-blocking way. ## Optional Cargo features