From 0539497eedb999ac015993962ff379409b676e4c Mon Sep 17 00:00:00 2001 From: Victorien Elvinger Date: Thu, 2 Oct 2025 12:24:22 +0200 Subject: [PATCH 1/3] io: use clippy to ensure that methods are forwarded in adapters --- embedded-io-adapters/src/std.rs | 16 ++++++++++++++++ embedded-io-async/src/impls/boxx.rs | 16 ++++++++++++++++ embedded-io-async/src/lib.rs | 16 ++++++++++++++++ embedded-io/src/impls/boxx.rs | 28 ++++++++++++++++++++++++++++ embedded-io/src/lib.rs | 29 +++++++++++++++++++++++++++++ 5 files changed, 105 insertions(+) diff --git a/embedded-io-adapters/src/std.rs b/embedded-io-adapters/src/std.rs index 776bc875..83f6e65e 100644 --- a/embedded-io-adapters/src/std.rs +++ b/embedded-io-adapters/src/std.rs @@ -36,6 +36,10 @@ impl embedded_io::ErrorType for FromStd { type Error = std::io::Error; } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl embedded_io::Read for FromStd { fn read(&mut self, buf: &mut [u8]) -> Result { self.inner.read(buf) @@ -55,6 +59,10 @@ impl embedded_io::Read for FromStd { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl embedded_io::BufRead for FromStd { fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { self.inner.fill_buf() @@ -65,6 +73,10 @@ impl embedded_io::BufRead for FromStd { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl embedded_io::Write for FromStd { fn write(&mut self, buf: &[u8]) -> Result { match self.inner.write(buf) { @@ -90,6 +102,10 @@ impl embedded_io::Write for FromStd { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl embedded_io::Seek for FromStd { fn seek(&mut self, pos: embedded_io::SeekFrom) -> Result { self.inner.seek(pos.into()) diff --git a/embedded-io-async/src/impls/boxx.rs b/embedded-io-async/src/impls/boxx.rs index b3c1bab5..2075bb68 100644 --- a/embedded-io-async/src/impls/boxx.rs +++ b/embedded-io-async/src/impls/boxx.rs @@ -2,6 +2,10 @@ use crate::{BufRead, Read, Seek, SeekFrom, Write}; use alloc::boxed::Box; #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Read for Box { #[inline] async fn read(&mut self, buf: &mut [u8]) -> Result { @@ -18,6 +22,10 @@ impl Read for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl BufRead for Box { #[inline] async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { @@ -31,6 +39,10 @@ impl BufRead for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Write for Box { #[inline] async fn write(&mut self, buf: &[u8]) -> Result { @@ -49,6 +61,10 @@ impl Write for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Seek for Box { #[inline] async fn seek(&mut self, pos: SeekFrom) -> Result { diff --git a/embedded-io-async/src/lib.rs b/embedded-io-async/src/lib.rs index a421e54c..5e7e6a27 100644 --- a/embedded-io-async/src/lib.rs +++ b/embedded-io-async/src/lib.rs @@ -168,6 +168,10 @@ pub trait Seek: ErrorType { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Read for &mut T { #[inline] async fn read(&mut self, buf: &mut [u8]) -> Result { @@ -180,6 +184,10 @@ impl Read for &mut T { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl BufRead for &mut T { #[inline] async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { @@ -192,6 +200,10 @@ impl BufRead for &mut T { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Write for &mut T { #[inline] async fn write(&mut self, buf: &[u8]) -> Result { @@ -209,6 +221,10 @@ impl Write for &mut T { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Seek for &mut T { #[inline] async fn seek(&mut self, pos: SeekFrom) -> Result { diff --git a/embedded-io/src/impls/boxx.rs b/embedded-io/src/impls/boxx.rs index c7bb01a5..0eb3f0e5 100644 --- a/embedded-io/src/impls/boxx.rs +++ b/embedded-io/src/impls/boxx.rs @@ -2,11 +2,19 @@ use crate::{BufRead, ErrorType, Read, ReadReady, Seek, Write, WriteReady}; use alloc::boxed::Box; #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl ErrorType for Box { type Error = T::Error; } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Read for Box { #[inline] fn read(&mut self, buf: &mut [u8]) -> Result { @@ -20,6 +28,10 @@ impl Read for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl BufRead for Box { fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { T::fill_buf(self) @@ -32,6 +44,10 @@ impl BufRead for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Write for Box { #[inline] fn write(&mut self, buf: &[u8]) -> Result { @@ -58,6 +74,10 @@ impl Write for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Seek for Box { #[inline] fn seek(&mut self, pos: crate::SeekFrom) -> Result { @@ -81,6 +101,10 @@ impl Seek for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl ReadReady for Box { #[inline] fn read_ready(&mut self) -> Result { @@ -89,6 +113,10 @@ impl ReadReady for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl WriteReady for Box { #[inline] fn write_ready(&mut self) -> Result { diff --git a/embedded-io/src/lib.rs b/embedded-io/src/lib.rs index 0918cdb5..21c35551 100644 --- a/embedded-io/src/lib.rs +++ b/embedded-io/src/lib.rs @@ -553,6 +553,10 @@ pub trait WriteReady: ErrorType { fn write_ready(&mut self) -> Result; } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Read for &mut T { #[inline] fn read(&mut self, buf: &mut [u8]) -> Result { @@ -565,6 +569,10 @@ impl Read for &mut T { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl BufRead for &mut T { #[inline] fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { @@ -577,6 +585,10 @@ impl BufRead for &mut T { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Write for &mut T { #[inline] fn write(&mut self, buf: &[u8]) -> Result { @@ -592,8 +604,17 @@ impl Write for &mut T { fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> { T::write_all(self, buf) } + + #[inline] + fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> Result<(), WriteFmtError> { + T::write_fmt(self, fmt) + } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl Seek for &mut T { #[inline] fn seek(&mut self, pos: SeekFrom) -> Result { @@ -616,6 +637,10 @@ impl Seek for &mut T { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl ReadReady for &mut T { #[inline] fn read_ready(&mut self) -> Result { @@ -623,6 +648,10 @@ impl ReadReady for &mut T { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl WriteReady for &mut T { #[inline] fn write_ready(&mut self) -> Result { From 202c88cdb817d910b880e35cb532303421992587 Mon Sep 17 00:00:00 2001 From: Victorien Elvinger Date: Thu, 2 Oct 2025 15:08:55 +0200 Subject: [PATCH 2/3] io: reduce noise using module-level clippy deny --- embedded-io-adapters/src/std.rs | 21 ++--- embedded-io-async/src/impls/blanket.rs | 66 +++++++++++++++ embedded-io-async/src/impls/boxx.rs | 21 ++--- embedded-io-async/src/impls/mod.rs | 1 + embedded-io-async/src/lib.rs | 74 ----------------- embedded-io/src/impls/blanket.rs | 92 +++++++++++++++++++++ embedded-io/src/impls/boxx.rs | 33 ++------ embedded-io/src/impls/mod.rs | 1 + embedded-io/src/lib.rs | 106 ------------------------- 9 files changed, 175 insertions(+), 240 deletions(-) create mode 100644 embedded-io-async/src/impls/blanket.rs create mode 100644 embedded-io/src/impls/blanket.rs diff --git a/embedded-io-adapters/src/std.rs b/embedded-io-adapters/src/std.rs index 83f6e65e..7d7c5627 100644 --- a/embedded-io-adapters/src/std.rs +++ b/embedded-io-adapters/src/std.rs @@ -1,5 +1,10 @@ //! Adapters to/from `std::io` traits. +#![deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] + use embedded_io::Error as _; /// Adapter from `std::io` traits. @@ -36,10 +41,6 @@ impl embedded_io::ErrorType for FromStd { type Error = std::io::Error; } -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl embedded_io::Read for FromStd { fn read(&mut self, buf: &mut [u8]) -> Result { self.inner.read(buf) @@ -59,10 +60,6 @@ impl embedded_io::Read for FromStd { } } -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl embedded_io::BufRead for FromStd { fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { self.inner.fill_buf() @@ -73,10 +70,6 @@ impl embedded_io::BufRead for FromStd { } } -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl embedded_io::Write for FromStd { fn write(&mut self, buf: &[u8]) -> Result { match self.inner.write(buf) { @@ -102,10 +95,6 @@ impl embedded_io::Write for FromStd { } } -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl embedded_io::Seek for FromStd { fn seek(&mut self, pos: embedded_io::SeekFrom) -> Result { self.inner.seek(pos.into()) diff --git a/embedded-io-async/src/impls/blanket.rs b/embedded-io-async/src/impls/blanket.rs new file mode 100644 index 00000000..67e69736 --- /dev/null +++ b/embedded-io-async/src/impls/blanket.rs @@ -0,0 +1,66 @@ +#![deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] + +use embedded_io::{ReadExactError, SeekFrom}; + +use crate::{BufRead, Read, Seek, Write}; + +impl Read for &mut T { + #[inline] + async fn read(&mut self, buf: &mut [u8]) -> Result { + T::read(self, buf).await + } + + #[inline] + async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError> { + T::read_exact(self, buf).await + } +} + +impl BufRead for &mut T { + #[inline] + async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { + T::fill_buf(self).await + } + + #[inline] + fn consume(&mut self, amt: usize) { + T::consume(self, amt); + } +} + +impl Write for &mut T { + #[inline] + async fn write(&mut self, buf: &[u8]) -> Result { + T::write(self, buf).await + } + + #[inline] + async fn flush(&mut self) -> Result<(), Self::Error> { + T::flush(self).await + } + + #[inline] + async fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> { + T::write_all(self, buf).await + } +} + +impl Seek for &mut T { + #[inline] + async fn seek(&mut self, pos: SeekFrom) -> Result { + T::seek(self, pos).await + } + + #[inline] + async fn rewind(&mut self) -> Result<(), Self::Error> { + T::rewind(self).await + } + + #[inline] + async fn stream_position(&mut self) -> Result { + T::stream_position(self).await + } +} diff --git a/embedded-io-async/src/impls/boxx.rs b/embedded-io-async/src/impls/boxx.rs index 2075bb68..c8ee9e84 100644 --- a/embedded-io-async/src/impls/boxx.rs +++ b/embedded-io-async/src/impls/boxx.rs @@ -1,11 +1,12 @@ +#![deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] + use crate::{BufRead, Read, Seek, SeekFrom, Write}; use alloc::boxed::Box; #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl Read for Box { #[inline] async fn read(&mut self, buf: &mut [u8]) -> Result { @@ -22,10 +23,6 @@ impl Read for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl BufRead for Box { #[inline] async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { @@ -39,10 +36,6 @@ impl BufRead for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl Write for Box { #[inline] async fn write(&mut self, buf: &[u8]) -> Result { @@ -61,10 +54,6 @@ impl Write for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl Seek for Box { #[inline] async fn seek(&mut self, pos: SeekFrom) -> Result { diff --git a/embedded-io-async/src/impls/mod.rs b/embedded-io-async/src/impls/mod.rs index 83c0f33a..69565952 100644 --- a/embedded-io-async/src/impls/mod.rs +++ b/embedded-io-async/src/impls/mod.rs @@ -1,3 +1,4 @@ +mod blanket; mod slice_mut; mod slice_ref; diff --git a/embedded-io-async/src/lib.rs b/embedded-io-async/src/lib.rs index 5e7e6a27..b90935f2 100644 --- a/embedded-io-async/src/lib.rs +++ b/embedded-io-async/src/lib.rs @@ -167,77 +167,3 @@ pub trait Seek: ErrorType { self.seek(SeekFrom::Current(0)).await } } - -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] -impl Read for &mut T { - #[inline] - async fn read(&mut self, buf: &mut [u8]) -> Result { - T::read(self, buf).await - } - - #[inline] - async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError> { - T::read_exact(self, buf).await - } -} - -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] -impl BufRead for &mut T { - #[inline] - async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { - T::fill_buf(self).await - } - - #[inline] - fn consume(&mut self, amt: usize) { - T::consume(self, amt); - } -} - -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] -impl Write for &mut T { - #[inline] - async fn write(&mut self, buf: &[u8]) -> Result { - T::write(self, buf).await - } - - #[inline] - async fn flush(&mut self) -> Result<(), Self::Error> { - T::flush(self).await - } - - #[inline] - async fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> { - T::write_all(self, buf).await - } -} - -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] -impl Seek for &mut T { - #[inline] - async fn seek(&mut self, pos: SeekFrom) -> Result { - T::seek(self, pos).await - } - - #[inline] - async fn rewind(&mut self) -> Result<(), Self::Error> { - T::rewind(self).await - } - - #[inline] - async fn stream_position(&mut self) -> Result { - T::stream_position(self).await - } -} diff --git a/embedded-io/src/impls/blanket.rs b/embedded-io/src/impls/blanket.rs new file mode 100644 index 00000000..a62f654e --- /dev/null +++ b/embedded-io/src/impls/blanket.rs @@ -0,0 +1,92 @@ +#![deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] + +use core::fmt; + +use crate::{ + BufRead, Read, ReadExactError, ReadReady, Seek, SeekFrom, Write, WriteFmtError, WriteReady, +}; + +impl Read for &mut T { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> Result { + T::read(self, buf) + } + + #[inline] + fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError> { + T::read_exact(self, buf) + } +} + +impl BufRead for &mut T { + #[inline] + fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { + T::fill_buf(self) + } + + #[inline] + fn consume(&mut self, amt: usize) { + T::consume(self, amt); + } +} + +impl Write for &mut T { + #[inline] + fn write(&mut self, buf: &[u8]) -> Result { + T::write(self, buf) + } + + #[inline] + fn flush(&mut self) -> Result<(), Self::Error> { + T::flush(self) + } + + #[inline] + fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> { + T::write_all(self, buf) + } + + #[inline] + fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> Result<(), WriteFmtError> { + T::write_fmt(self, fmt) + } +} + +impl Seek for &mut T { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> Result { + T::seek(self, pos) + } + + #[inline] + fn rewind(&mut self) -> Result<(), Self::Error> { + T::rewind(self) + } + + #[inline] + fn stream_position(&mut self) -> Result { + T::stream_position(self) + } + + #[inline] + fn seek_relative(&mut self, offset: i64) -> Result<(), Self::Error> { + T::seek_relative(self, offset) + } +} + +impl ReadReady for &mut T { + #[inline] + fn read_ready(&mut self) -> Result { + T::read_ready(self) + } +} + +impl WriteReady for &mut T { + #[inline] + fn write_ready(&mut self) -> Result { + T::write_ready(self) + } +} diff --git a/embedded-io/src/impls/boxx.rs b/embedded-io/src/impls/boxx.rs index 0eb3f0e5..476b9158 100644 --- a/embedded-io/src/impls/boxx.rs +++ b/embedded-io/src/impls/boxx.rs @@ -1,20 +1,17 @@ +#![deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] + use crate::{BufRead, ErrorType, Read, ReadReady, Seek, Write, WriteReady}; use alloc::boxed::Box; #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl ErrorType for Box { type Error = T::Error; } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl Read for Box { #[inline] fn read(&mut self, buf: &mut [u8]) -> Result { @@ -28,10 +25,6 @@ impl Read for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl BufRead for Box { fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { T::fill_buf(self) @@ -44,10 +37,6 @@ impl BufRead for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl Write for Box { #[inline] fn write(&mut self, buf: &[u8]) -> Result { @@ -74,10 +63,6 @@ impl Write for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl Seek for Box { #[inline] fn seek(&mut self, pos: crate::SeekFrom) -> Result { @@ -101,10 +86,6 @@ impl Seek for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl ReadReady for Box { #[inline] fn read_ready(&mut self) -> Result { @@ -113,10 +94,6 @@ impl ReadReady for Box { } #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] impl WriteReady for Box { #[inline] fn write_ready(&mut self) -> Result { diff --git a/embedded-io/src/impls/mod.rs b/embedded-io/src/impls/mod.rs index 83c0f33a..69565952 100644 --- a/embedded-io/src/impls/mod.rs +++ b/embedded-io/src/impls/mod.rs @@ -1,3 +1,4 @@ +mod blanket; mod slice_mut; mod slice_ref; diff --git a/embedded-io/src/lib.rs b/embedded-io/src/lib.rs index 21c35551..cdd89534 100644 --- a/embedded-io/src/lib.rs +++ b/embedded-io/src/lib.rs @@ -552,109 +552,3 @@ pub trait WriteReady: ErrorType { /// If this returns `true`, it's guaranteed that the next call to [`Write::write`] will not block. fn write_ready(&mut self) -> Result; } - -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] -impl Read for &mut T { - #[inline] - fn read(&mut self, buf: &mut [u8]) -> Result { - T::read(self, buf) - } - - #[inline] - fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError> { - T::read_exact(self, buf) - } -} - -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] -impl BufRead for &mut T { - #[inline] - fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { - T::fill_buf(self) - } - - #[inline] - fn consume(&mut self, amt: usize) { - T::consume(self, amt); - } -} - -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] -impl Write for &mut T { - #[inline] - fn write(&mut self, buf: &[u8]) -> Result { - T::write(self, buf) - } - - #[inline] - fn flush(&mut self) -> Result<(), Self::Error> { - T::flush(self) - } - - #[inline] - fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> { - T::write_all(self, buf) - } - - #[inline] - fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> Result<(), WriteFmtError> { - T::write_fmt(self, fmt) - } -} - -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] -impl Seek for &mut T { - #[inline] - fn seek(&mut self, pos: SeekFrom) -> Result { - T::seek(self, pos) - } - - #[inline] - fn rewind(&mut self) -> Result<(), Self::Error> { - T::rewind(self) - } - - #[inline] - fn stream_position(&mut self) -> Result { - T::stream_position(self) - } - - #[inline] - fn seek_relative(&mut self, offset: i64) -> Result<(), Self::Error> { - T::seek_relative(self, offset) - } -} - -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] -impl ReadReady for &mut T { - #[inline] - fn read_ready(&mut self) -> Result { - T::read_ready(self) - } -} - -#[deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] -impl WriteReady for &mut T { - #[inline] - fn write_ready(&mut self) -> Result { - T::write_ready(self) - } -} From 2b721664a0b0bc850088c001ed7ea7bf8946f487 Mon Sep 17 00:00:00 2001 From: Victorien Elvinger Date: Thu, 2 Oct 2025 22:17:24 +0200 Subject: [PATCH 3/3] io: make clippy happy --- embedded-io-adapters/src/std.rs | 21 ++++++++++++++++----- embedded-io/src/impls/boxx.rs | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/embedded-io-adapters/src/std.rs b/embedded-io-adapters/src/std.rs index 7d7c5627..83f6e65e 100644 --- a/embedded-io-adapters/src/std.rs +++ b/embedded-io-adapters/src/std.rs @@ -1,10 +1,5 @@ //! Adapters to/from `std::io` traits. -#![deny( - clippy::missing_trait_methods, - reason = "Methods should be forwarded to the underlying type" -)] - use embedded_io::Error as _; /// Adapter from `std::io` traits. @@ -41,6 +36,10 @@ impl embedded_io::ErrorType for FromStd { type Error = std::io::Error; } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl embedded_io::Read for FromStd { fn read(&mut self, buf: &mut [u8]) -> Result { self.inner.read(buf) @@ -60,6 +59,10 @@ impl embedded_io::Read for FromStd { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl embedded_io::BufRead for FromStd { fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { self.inner.fill_buf() @@ -70,6 +73,10 @@ impl embedded_io::BufRead for FromStd { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl embedded_io::Write for FromStd { fn write(&mut self, buf: &[u8]) -> Result { match self.inner.write(buf) { @@ -95,6 +102,10 @@ impl embedded_io::Write for FromStd { } } +#[deny( + clippy::missing_trait_methods, + reason = "Methods should be forwarded to the underlying type" +)] impl embedded_io::Seek for FromStd { fn seek(&mut self, pos: embedded_io::SeekFrom) -> Result { self.inner.seek(pos.into()) diff --git a/embedded-io/src/impls/boxx.rs b/embedded-io/src/impls/boxx.rs index 476b9158..02282eee 100644 --- a/embedded-io/src/impls/boxx.rs +++ b/embedded-io/src/impls/boxx.rs @@ -26,6 +26,7 @@ impl Read for Box { #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] impl BufRead for Box { + #[inline] fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { T::fill_buf(self) }