diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 46fb03b26..586d42513 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,23 +38,9 @@ jobs: --target thumbv7m-none-eabi --features async,defmt-03 - msrv-1-60: + msrv-1-81: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.60 - - run: > - cargo test - -p embedded-hal:1.0.0 - -p embedded-hal-bus - -p embedded-hal-nb - -p embedded-io - -p embedded-io-adapters - -p embedded-can - - msrv-1-75: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.75 + - uses: dtolnay/rust-toolchain@1.81 - run: cargo test --workspace --all-features diff --git a/README.md b/README.md index da60c3fed..63c347628 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ on crates.io. ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.60 and up. It *might* +This crate is guaranteed to compile on stable Rust 1.81 and up. It *might* compile with older versions but that may change in any new patch release. See [here](docs/msrv.md) for details on how the MSRV may be upgraded. diff --git a/embedded-can/CHANGELOG.md b/embedded-can/CHANGELOG.md index 302c85a09..ada6c80d3 100644 --- a/embedded-can/CHANGELOG.md +++ b/embedded-can/CHANGELOG.md @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -... +- Added blanket `core::error::Error` and `core::fmt::Display` implementations for the custom `Error` traits +- Increased MSRV to 1.81 due to `core::error::Error` ## [v0.4.1] - 2022-09-28 diff --git a/embedded-can/Cargo.toml b/embedded-can/Cargo.toml index 07ef7cc53..105f286b0 100644 --- a/embedded-can/Cargo.toml +++ b/embedded-can/Cargo.toml @@ -2,7 +2,7 @@ name = "embedded-can" version = "0.4.1" edition = "2021" -rust-version = "1.56" +rust-version = "1.81" description = "HAL traits for Controller Area Network (CAN) devices." categories = ["embedded", "hardware-support", "no-std"] diff --git a/embedded-can/README.md b/embedded-can/README.md index 1beaf39cd..96afb5ec6 100644 --- a/embedded-can/README.md +++ b/embedded-can/README.md @@ -19,7 +19,7 @@ This project is developed and maintained by the [HAL team](https://github.com/ru ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.60 and up. It *might* +This crate is guaranteed to compile on stable Rust 1.81 and up. It *might* compile with older versions but that may change in any new patch release. See [here](../docs/msrv.md) for details on how the MSRV may be upgraded. diff --git a/embedded-can/src/lib.rs b/embedded-can/src/lib.rs index da561f58c..22730604c 100644 --- a/embedded-can/src/lib.rs +++ b/embedded-can/src/lib.rs @@ -61,6 +61,14 @@ pub trait Error: core::fmt::Debug { fn kind(&self) -> ErrorKind; } +impl core::fmt::Display for dyn Error { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self) + } +} + +impl core::error::Error for dyn Error {} + impl Error for core::convert::Infallible { fn kind(&self) -> ErrorKind { match *self {} diff --git a/embedded-hal-bus/CHANGELOG.md b/embedded-hal-bus/CHANGELOG.md index 45d0f6cc8..d9009d9c3 100644 --- a/embedded-hal-bus/CHANGELOG.md +++ b/embedded-hal-bus/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Added the `alloc` feature. - Added a new `RcDevice` for I2C and SPI, a reference-counting equivalent to `RefCellDevice`. +- Migrated `std` feature-gated `std::error::Error` implementations to `core::error::Error` +- Increased MSRV to 1.81 due to `core::error::Error` ## [v0.2.0] - 2024-04-23 diff --git a/embedded-hal-bus/Cargo.toml b/embedded-hal-bus/Cargo.toml index d0ebecf7d..d45016f84 100644 --- a/embedded-hal-bus/Cargo.toml +++ b/embedded-hal-bus/Cargo.toml @@ -15,7 +15,7 @@ repository = "https://github.com/rust-embedded/embedded-hal" version = "0.2.0" [features] -# Enable shared bus implementations using `std::sync::Mutex`, and implement `std::error::Error` for `DeviceError` +# Enable shared bus implementations using `std::sync::Mutex` std = ["alloc"] # Use `portable-atomic` to enable `atomic-device` on devices without native atomic CAS # diff --git a/embedded-hal-bus/README.md b/embedded-hal-bus/README.md index 2e6d9db0d..9f7f598e6 100644 --- a/embedded-hal-bus/README.md +++ b/embedded-hal-bus/README.md @@ -39,12 +39,11 @@ provides mechanisms to obtain multiple `I2c` instances out of a single `I2c` ins that does not natively support atomic CAS. If you enable this, you must also add `portable-atomic` to your crate with a feature flag such as `unsafe-assume-single-core` or `critical-section` to choose how atomic CAS is implemented. See for more info. -- **`std`**: enable shared bus implementations using `std::sync::Mutex`, and implement - `std::error::Error` for `DeviceError`. +- **`std`**: enable shared bus implementations using `std::sync::Mutex`. ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.60 and up. It *might* +This crate is guaranteed to compile on stable Rust 1.81 and up. It *might* compile with older versions but that may change in any new patch release. See [here](../docs/msrv.md) for details on how the MSRV may be upgraded. diff --git a/embedded-hal-bus/src/spi/mod.rs b/embedded-hal-bus/src/spi/mod.rs index 5a8356e28..c7a793f90 100644 --- a/embedded-hal-bus/src/spi/mod.rs +++ b/embedded-hal-bus/src/spi/mod.rs @@ -47,8 +47,7 @@ impl Display for DeviceError { } } -#[cfg(feature = "std")] -impl std::error::Error for DeviceError {} +impl core::error::Error for DeviceError {} impl Error for DeviceError where diff --git a/embedded-hal-nb/CHANGELOG.md b/embedded-hal-nb/CHANGELOG.md index f31190acb..5d52ebc24 100644 --- a/embedded-hal-nb/CHANGELOG.md +++ b/embedded-hal-nb/CHANGELOG.md @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -No unreleased changes +- Added blanket `core::error::Error` and `core::fmt::Display` implementations for the custom `Error` traits +- Increased MSRV to 1.81 due to `core::error::Error` ## [v1.0.0] - 2023-12-28 diff --git a/embedded-hal-nb/Cargo.toml b/embedded-hal-nb/Cargo.toml index d4575ead0..43a6cd7be 100644 --- a/embedded-hal-nb/Cargo.toml +++ b/embedded-hal-nb/Cargo.toml @@ -2,7 +2,7 @@ name = "embedded-hal-nb" version = "1.0.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.81" categories = ["embedded", "hardware-support", "no-std"] description = "Non-blocking Hardware Abstraction Layer (HAL) for embedded systems using the `nb` crate." diff --git a/embedded-hal-nb/README.md b/embedded-hal-nb/README.md index aa72e7b1e..414e0168f 100644 --- a/embedded-hal-nb/README.md +++ b/embedded-hal-nb/README.md @@ -17,7 +17,7 @@ This project is developed and maintained by the [HAL team](https://github.com/ru ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.60 and up. It *might* +This crate is guaranteed to compile on stable Rust 1.81 and up. It *might* compile with older versions but that may change in any new patch release. See [here](../docs/msrv.md) for details on how the MSRV may be upgraded. diff --git a/embedded-hal-nb/src/serial.rs b/embedded-hal-nb/src/serial.rs index 18d1265c2..59183cab3 100644 --- a/embedded-hal-nb/src/serial.rs +++ b/embedded-hal-nb/src/serial.rs @@ -10,6 +10,14 @@ pub trait Error: core::fmt::Debug { fn kind(&self) -> ErrorKind; } +impl core::fmt::Display for dyn Error { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self) + } +} + +impl core::error::Error for dyn Error {} + impl Error for core::convert::Infallible { #[inline] fn kind(&self) -> ErrorKind { diff --git a/embedded-hal/CHANGELOG.md b/embedded-hal/CHANGELOG.md index 4a1af0e3f..9b20e59c7 100644 --- a/embedded-hal/CHANGELOG.md +++ b/embedded-hal/CHANGELOG.md @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -No unreleased changes yet. +- Added blanket `core::error::Error` and `core::fmt::Display` implementations for the custom `Error` traits +- Increased MSRV to 1.81 due to `core::error::Error` ## [v1.0.0] - 2023-12-28 diff --git a/embedded-hal/Cargo.toml b/embedded-hal/Cargo.toml index f67b2527b..011f3cc9d 100644 --- a/embedded-hal/Cargo.toml +++ b/embedded-hal/Cargo.toml @@ -8,7 +8,7 @@ categories = ["asynchronous", "embedded", "hardware-support", "no-std"] description = " A Hardware Abstraction Layer (HAL) for embedded systems " documentation = "https://docs.rs/embedded-hal" edition = "2021" -rust-version = "1.60" +rust-version = "1.81" keywords = ["hal", "IO"] license = "MIT OR Apache-2.0" name = "embedded-hal" diff --git a/embedded-hal/README.md b/embedded-hal/README.md index e47182b71..dc0442100 100644 --- a/embedded-hal/README.md +++ b/embedded-hal/README.md @@ -84,7 +84,7 @@ to your crate before publishing it! ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.60 and up. It *might* +This crate is guaranteed to compile on stable Rust 1.81 and up. It *might* compile with older versions but that may change in any new patch release. See [here](../docs/msrv.md) for details on how the MSRV may be upgraded. diff --git a/embedded-hal/src/digital.rs b/embedded-hal/src/digital.rs index 201cd7637..7fcfc0e43 100644 --- a/embedded-hal/src/digital.rs +++ b/embedded-hal/src/digital.rs @@ -15,6 +15,14 @@ pub trait Error: core::fmt::Debug { fn kind(&self) -> ErrorKind; } +impl core::fmt::Display for dyn Error { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self) + } +} + +impl core::error::Error for dyn Error {} + impl Error for core::convert::Infallible { fn kind(&self) -> ErrorKind { match *self {} diff --git a/embedded-hal/src/i2c.rs b/embedded-hal/src/i2c.rs index 36052afaf..076a95975 100644 --- a/embedded-hal/src/i2c.rs +++ b/embedded-hal/src/i2c.rs @@ -176,6 +176,14 @@ pub trait Error: core::fmt::Debug { fn kind(&self) -> ErrorKind; } +impl core::fmt::Display for dyn Error { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self) + } +} + +impl core::error::Error for dyn Error {} + impl Error for core::convert::Infallible { #[inline] fn kind(&self) -> ErrorKind { diff --git a/embedded-hal/src/pwm.rs b/embedded-hal/src/pwm.rs index 68a94f54f..1046ff321 100644 --- a/embedded-hal/src/pwm.rs +++ b/embedded-hal/src/pwm.rs @@ -13,6 +13,14 @@ pub trait Error: core::fmt::Debug { fn kind(&self) -> ErrorKind; } +impl core::fmt::Display for dyn Error { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self) + } +} + +impl core::error::Error for dyn Error {} + impl Error for core::convert::Infallible { #[inline] fn kind(&self) -> ErrorKind { diff --git a/embedded-hal/src/spi.rs b/embedded-hal/src/spi.rs index 508a4a9b1..498fa0f09 100644 --- a/embedded-hal/src/spi.rs +++ b/embedded-hal/src/spi.rs @@ -240,6 +240,14 @@ pub trait Error: Debug { fn kind(&self) -> ErrorKind; } +impl core::fmt::Display for dyn Error { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self) + } +} + +impl core::error::Error for dyn Error {} + impl Error for core::convert::Infallible { #[inline] fn kind(&self) -> ErrorKind { diff --git a/embedded-io/CHANGELOG.md b/embedded-io/CHANGELOG.md index 286d1b707..e3d1b6b02 100644 --- a/embedded-io/CHANGELOG.md +++ b/embedded-io/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +- Added blanket `core::error::Error` and `core::fmt::Display` implementations for the custom `Error` traits +- Migrated `std` feature-gated `std::error::Error` implementations to `core::error::Error` +- Increased MSRV to 1.81 due to `core::error::Error` + + ## 0.6.1 - 2023-10-22 - Make `SliceWriteError` publicly available. diff --git a/embedded-io/Cargo.toml b/embedded-io/Cargo.toml index e92714f7a..dc878f7b6 100644 --- a/embedded-io/Cargo.toml +++ b/embedded-io/Cargo.toml @@ -2,7 +2,7 @@ name = "embedded-io" version = "0.6.1" edition = "2021" -rust-version = "1.60" +rust-version = "1.81" description = "Embedded IO traits" repository = "https://github.com/rust-embedded/embedded-hal" readme = "README.md" diff --git a/embedded-io/README.md b/embedded-io/README.md index 04ea97771..106db51e6 100644 --- a/embedded-io/README.md +++ b/embedded-io/README.md @@ -21,13 +21,13 @@ targets. ## Optional Cargo features -- **`std`**: Adds `From` impls to convert to/from `std::io` structs, adds `std::error::Error` impls. +- **`std`**: Adds `From` impls to convert to/from `std::io` structs. - **`alloc`**: Adds blanket impls for `Box`, adds `Write` impl to `Vec`. - **`defmt-03`**: Derive `defmt::Format` from `defmt` 0.3 for enums and structs. ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.60 and up. It *might* +This crate is guaranteed to compile on stable Rust 1.81 and up. It *might* compile with older versions but that may change in any new patch release. See [here](../docs/msrv.md) for details on how the MSRV may be upgraded. diff --git a/embedded-io/src/impls/slice_mut.rs b/embedded-io/src/impls/slice_mut.rs index 4608ee45b..322f26c69 100644 --- a/embedded-io/src/impls/slice_mut.rs +++ b/embedded-io/src/impls/slice_mut.rs @@ -19,10 +19,6 @@ impl core::fmt::Display for SliceWriteError { } } -#[cfg(feature = "std")] -#[cfg_attr(docsrs, doc(cfg(feature = "std")))] -impl std::error::Error for SliceWriteError {} - /// Write is implemented for `&mut [u8]` by copying into the slice, overwriting /// its data. /// diff --git a/embedded-io/src/lib.rs b/embedded-io/src/lib.rs index f050abb1d..31eaf1476 100644 --- a/embedded-io/src/lib.rs +++ b/embedded-io/src/lib.rs @@ -181,6 +181,14 @@ pub trait Error: fmt::Debug { fn kind(&self) -> ErrorKind; } +impl fmt::Display for dyn Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self) + } +} + +impl core::error::Error for dyn Error {} + impl Error for core::convert::Infallible { fn kind(&self) -> ErrorKind { match *self {} @@ -255,9 +263,7 @@ impl fmt::Display for ReadExactError { } } -#[cfg(feature = "std")] -#[cfg_attr(docsrs, doc(cfg(feature = "std")))] -impl std::error::Error for ReadExactError {} +impl core::error::Error for ReadExactError {} /// Errors that could be returned by `Write` on `&mut [u8]`. #[derive(Debug, Copy, Clone, Eq, PartialEq)] @@ -290,9 +296,7 @@ impl fmt::Display for WriteFmtError { } } -#[cfg(feature = "std")] -#[cfg_attr(docsrs, doc(cfg(feature = "std")))] -impl std::error::Error for WriteFmtError {} +impl core::error::Error for WriteFmtError {} /// Blocking reader. ///