diff --git a/embedded-hal-async/src/digital.rs b/embedded-hal-async/src/digital.rs index 4fb3843cb..c59f7e2ec 100644 --- a/embedded-hal-async/src/digital.rs +++ b/embedded-hal-async/src/digital.rs @@ -50,27 +50,27 @@ pub trait Wait: embedded_hal::digital::ErrorType { impl Wait for &mut T { #[inline] - async fn wait_for_high(&mut self) -> Result<(), Self::Error> { + async fn wait_for_high(&mut self) -> Result<(), T::Error> { T::wait_for_high(self).await } #[inline] - async fn wait_for_low(&mut self) -> Result<(), Self::Error> { + async fn wait_for_low(&mut self) -> Result<(), T::Error> { T::wait_for_low(self).await } #[inline] - async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { + async fn wait_for_rising_edge(&mut self) -> Result<(), T::Error> { T::wait_for_rising_edge(self).await } #[inline] - async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { + async fn wait_for_falling_edge(&mut self) -> Result<(), T::Error> { T::wait_for_falling_edge(self).await } #[inline] - async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { + async fn wait_for_any_edge(&mut self) -> Result<(), T::Error> { T::wait_for_any_edge(self).await } } diff --git a/embedded-hal-async/src/i2c.rs b/embedded-hal-async/src/i2c.rs index 1a8f07a48..ff5d125e4 100644 --- a/embedded-hal-async/src/i2c.rs +++ b/embedded-hal-async/src/i2c.rs @@ -127,12 +127,12 @@ pub trait I2c: ErrorType { impl + ?Sized> I2c for &mut T { #[inline] - async fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error> { + async fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), T::Error> { T::read(self, address, read).await } #[inline] - async fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error> { + async fn write(&mut self, address: A, write: &[u8]) -> Result<(), T::Error> { T::write(self, address, write).await } @@ -142,7 +142,7 @@ impl + ?Sized> I2c for &mut T { address: A, write: &[u8], read: &mut [u8], - ) -> Result<(), Self::Error> { + ) -> Result<(), T::Error> { T::write_read(self, address, write, read).await } @@ -151,7 +151,7 @@ impl + ?Sized> I2c for &mut T { &mut self, address: A, operations: &mut [Operation<'_>], - ) -> Result<(), Self::Error> { + ) -> Result<(), T::Error> { T::transaction(self, address, operations).await } } diff --git a/embedded-hal-async/src/lib.rs b/embedded-hal-async/src/lib.rs index 5fe9168e7..927dd672d 100644 --- a/embedded-hal-async/src/lib.rs +++ b/embedded-hal-async/src/lib.rs @@ -1,7 +1,7 @@ #![doc = include_str!("../README.md")] #![warn(missing_docs)] #![no_std] -#![feature(async_fn_in_trait, impl_trait_projections)] +#![feature(async_fn_in_trait)] pub mod delay; pub mod digital; diff --git a/embedded-hal-async/src/spi.rs b/embedded-hal-async/src/spi.rs index 38d471d9a..6ff4d2506 100644 --- a/embedded-hal-async/src/spi.rs +++ b/embedded-hal-async/src/spi.rs @@ -79,27 +79,27 @@ impl + ?Sized> SpiDevice for &mut async fn transaction( &mut self, operations: &mut [Operation<'_, Word>], - ) -> Result<(), Self::Error> { + ) -> Result<(), T::Error> { T::transaction(self, operations).await } #[inline] - async fn read(&mut self, buf: &mut [Word]) -> Result<(), Self::Error> { + async fn read(&mut self, buf: &mut [Word]) -> Result<(), T::Error> { T::read(self, buf).await } #[inline] - async fn write(&mut self, buf: &[Word]) -> Result<(), Self::Error> { + async fn write(&mut self, buf: &[Word]) -> Result<(), T::Error> { T::write(self, buf).await } #[inline] - async fn transfer(&mut self, read: &mut [Word], write: &[Word]) -> Result<(), Self::Error> { + async fn transfer(&mut self, read: &mut [Word], write: &[Word]) -> Result<(), T::Error> { T::transfer(self, read, write).await } #[inline] - async fn transfer_in_place(&mut self, buf: &mut [Word]) -> Result<(), Self::Error> { + async fn transfer_in_place(&mut self, buf: &mut [Word]) -> Result<(), T::Error> { T::transfer_in_place(self, buf).await } } @@ -154,27 +154,27 @@ pub trait SpiBus: ErrorType { impl + ?Sized, Word: 'static + Copy> SpiBus for &mut T { #[inline] - async fn read(&mut self, words: &mut [Word]) -> Result<(), Self::Error> { + async fn read(&mut self, words: &mut [Word]) -> Result<(), T::Error> { T::read(self, words).await } #[inline] - async fn write(&mut self, words: &[Word]) -> Result<(), Self::Error> { + async fn write(&mut self, words: &[Word]) -> Result<(), T::Error> { T::write(self, words).await } #[inline] - async fn transfer(&mut self, read: &mut [Word], write: &[Word]) -> Result<(), Self::Error> { + async fn transfer(&mut self, read: &mut [Word], write: &[Word]) -> Result<(), T::Error> { T::transfer(self, read, write).await } #[inline] - async fn transfer_in_place(&mut self, words: &mut [Word]) -> Result<(), Self::Error> { + async fn transfer_in_place(&mut self, words: &mut [Word]) -> Result<(), T::Error> { T::transfer_in_place(self, words).await } #[inline] - async fn flush(&mut self) -> Result<(), Self::Error> { + async fn flush(&mut self) -> Result<(), T::Error> { T::flush(self).await } } diff --git a/embedded-hal-bus/src/lib.rs b/embedded-hal-bus/src/lib.rs index 6feef548b..5bc765979 100644 --- a/embedded-hal-bus/src/lib.rs +++ b/embedded-hal-bus/src/lib.rs @@ -2,7 +2,7 @@ #![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(docsrs, feature(doc_cfg))] -#![cfg_attr(feature = "async", feature(async_fn_in_trait, impl_trait_projections))] +#![cfg_attr(feature = "async", feature(async_fn_in_trait))] // needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`. #[cfg(feature = "defmt-03")] diff --git a/embedded-io-adapters/src/lib.rs b/embedded-io-adapters/src/lib.rs index d11316405..50221a212 100644 --- a/embedded-io-adapters/src/lib.rs +++ b/embedded-io-adapters/src/lib.rs @@ -2,7 +2,7 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr( any(feature = "tokio-1", feature = "futures-03"), - feature(async_fn_in_trait, impl_trait_projections) + feature(async_fn_in_trait) )] #![warn(missing_docs)] #![doc = include_str!("../README.md")] diff --git a/embedded-io-async/src/impls/slice_mut.rs b/embedded-io-async/src/impls/slice_mut.rs index 4a195e3f4..d02d85d29 100644 --- a/embedded-io-async/src/impls/slice_mut.rs +++ b/embedded-io-async/src/impls/slice_mut.rs @@ -1,5 +1,5 @@ use crate::Write; -use core::mem; +use core::{convert::Infallible, mem}; /// Write is implemented for `&mut [u8]` by copying into the slice, overwriting /// its data. @@ -12,7 +12,7 @@ use core::mem; /// kind `ErrorKind::WriteZero`. impl Write for &mut [u8] { #[inline] - async fn write(&mut self, buf: &[u8]) -> Result { + async fn write(&mut self, buf: &[u8]) -> Result { let amt = core::cmp::min(buf.len(), self.len()); let (a, b) = mem::take(self).split_at_mut(amt); a.copy_from_slice(&buf[..amt]); diff --git a/embedded-io-async/src/impls/slice_ref.rs b/embedded-io-async/src/impls/slice_ref.rs index a6a4ba807..bd804bc91 100644 --- a/embedded-io-async/src/impls/slice_ref.rs +++ b/embedded-io-async/src/impls/slice_ref.rs @@ -1,3 +1,5 @@ +use core::convert::Infallible; + use crate::{BufRead, Read}; /// Read is implemented for `&[u8]` by copying from the slice. @@ -6,7 +8,7 @@ use crate::{BufRead, Read}; /// The slice will be empty when EOF is reached. impl Read for &[u8] { #[inline] - async fn read(&mut self, buf: &mut [u8]) -> Result { + async fn read(&mut self, buf: &mut [u8]) -> Result { let amt = core::cmp::min(buf.len(), self.len()); let (a, b) = self.split_at(amt); @@ -26,7 +28,7 @@ impl Read for &[u8] { impl BufRead for &[u8] { #[inline] - async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { + async fn fill_buf(&mut self) -> Result<&[u8], Infallible> { Ok(*self) } diff --git a/embedded-io-async/src/lib.rs b/embedded-io-async/src/lib.rs index 98a656be8..abbe9143a 100644 --- a/embedded-io-async/src/lib.rs +++ b/embedded-io-async/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(async_fn_in_trait, impl_trait_projections)] +#![feature(async_fn_in_trait)] #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(docsrs, feature(doc_cfg))] #![warn(missing_docs)] @@ -159,13 +159,13 @@ pub trait Seek: ErrorType { impl Read for &mut T { #[inline] - async fn read(&mut self, buf: &mut [u8]) -> Result { + async fn read(&mut self, buf: &mut [u8]) -> Result { T::read(self, buf).await } } impl BufRead for &mut T { - async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { + async fn fill_buf(&mut self) -> Result<&[u8], T::Error> { T::fill_buf(self).await } @@ -176,19 +176,19 @@ impl BufRead for &mut T { impl Write for &mut T { #[inline] - async fn write(&mut self, buf: &[u8]) -> Result { + async fn write(&mut self, buf: &[u8]) -> Result { T::write(self, buf).await } #[inline] - async fn flush(&mut self) -> Result<(), Self::Error> { + async fn flush(&mut self) -> Result<(), T::Error> { T::flush(self).await } } impl Seek for &mut T { #[inline] - async fn seek(&mut self, pos: SeekFrom) -> Result { + async fn seek(&mut self, pos: SeekFrom) -> Result { T::seek(self, pos).await } }