From f32e54779f7fabfd6474a47ec623cb98a97f0f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= <martin.kroening@eonerc.rwth-aachen.de> Date: Thu, 25 Apr 2024 15:28:05 +0200 Subject: [PATCH 1/6] fix: implement `PartialOrd` via `Ord` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de> --- src/volatile_ptr/mod.rs | 2 +- src/volatile_ref.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/volatile_ptr/mod.rs b/src/volatile_ptr/mod.rs index 0f1cbad..b9056b7 100644 --- a/src/volatile_ptr/mod.rs +++ b/src/volatile_ptr/mod.rs @@ -79,7 +79,7 @@ where T: ?Sized, { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { - Some(Ord::cmp(&self.pointer.as_ptr(), &other.pointer.as_ptr())) + Some(self.cmp(other)) } } diff --git a/src/volatile_ref.rs b/src/volatile_ref.rs index 836b87d..013efbd 100644 --- a/src/volatile_ref.rs +++ b/src/volatile_ref.rs @@ -314,7 +314,7 @@ where T: ?Sized, { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { - Some(Ord::cmp(&self.pointer.as_ptr(), &other.pointer.as_ptr())) + Some(self.cmp(other)) } } From a9770d07dab74b68cf1c8b9389599282ada43a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= <martin.kroening@eonerc.rwth-aachen.de> Date: Thu, 25 Apr 2024 15:29:28 +0200 Subject: [PATCH 2/6] fix: allow intentional wide pointer comparisons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de> --- src/volatile_ptr/mod.rs | 1 + src/volatile_ref.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/volatile_ptr/mod.rs b/src/volatile_ptr/mod.rs index b9056b7..f625192 100644 --- a/src/volatile_ptr/mod.rs +++ b/src/volatile_ptr/mod.rs @@ -88,6 +88,7 @@ where T: ?Sized, { fn cmp(&self, other: &Self) -> Ordering { + #[allow(ambiguous_wide_pointer_comparisons)] Ord::cmp(&self.pointer.as_ptr(), &other.pointer.as_ptr()) } } diff --git a/src/volatile_ref.rs b/src/volatile_ref.rs index 013efbd..3b98ac5 100644 --- a/src/volatile_ref.rs +++ b/src/volatile_ref.rs @@ -323,6 +323,7 @@ where T: ?Sized, { fn cmp(&self, other: &Self) -> Ordering { + #[allow(ambiguous_wide_pointer_comparisons)] Ord::cmp(&self.pointer.as_ptr(), &other.pointer.as_ptr()) } } From a486be03315c2f19d2dea8c6656682fd4a19c1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= <martin.kroening@eonerc.rwth-aachen.de> Date: Thu, 25 Apr 2024 15:20:04 +0200 Subject: [PATCH 3/6] fix: allow `internal_features` when opting in via `unstable` feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de> --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 5dab31b..51b5b55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,6 +40,7 @@ #![cfg_attr(feature = "very_unstable", feature(fn_traits))] #![cfg_attr(feature = "very_unstable", feature(effects))] #![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![cfg_attr(feature = "unstable", allow(internal_features))] #![warn(missing_docs)] #![deny(unsafe_op_in_unsafe_fn)] #![doc(test(attr(deny(warnings))))] From c4a9e2df0dc72da51f5755390977aa1e2e61c131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= <martin.kroening@eonerc.rwth-aachen.de> Date: Thu, 25 Apr 2024 13:53:26 +0200 Subject: [PATCH 4/6] docs: fix warnings in derive examples --- src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 51b5b55..4cc9d61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,7 +63,7 @@ /// /// ``` /// use volatile::access::ReadOnly; -/// use volatile::{VolatileFieldAccess, VolatilePtr, VolatileRef}; +/// use volatile::{VolatileFieldAccess, VolatileRef}; /// /// #[repr(C)] /// #[derive(VolatileFieldAccess, Default)] @@ -75,7 +75,7 @@ /// /// let mut device_config = DeviceConfig::default(); /// let mut volatile_ref = VolatileRef::from_mut_ref(&mut device_config); -/// let mut volatile_ptr = volatile_ref.as_mut_ptr(); +/// let volatile_ptr = volatile_ref.as_mut_ptr(); /// /// volatile_ptr.feature_select().write(42); /// assert_eq!(volatile_ptr.feature_select().read(), 42); @@ -93,6 +93,14 @@ /// The example above results in (roughly) the following code: /// /// ``` +/// # #[repr(C)] +/// # pub struct DeviceConfig { +/// # feature_select: u32, +/// # feature: u32, +/// # } +/// use volatile::access::{ReadOnly, ReadWrite}; +/// use volatile::{map_field, VolatilePtr}; +/// /// pub trait DeviceConfigVolatileFieldAccess<'a> { /// fn feature_select(self) -> VolatilePtr<'a, u32, ReadWrite>; /// From 879c897fcd84f920c2dd89365e42dc486c7baf17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= <martin.kroening@eonerc.rwth-aachen.de> Date: Thu, 25 Apr 2024 13:54:38 +0200 Subject: [PATCH 5/6] ci: enable derive feature on stable --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 92b5702..e9d3357 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - run: cargo check --workspace + - run: cargo check --workspace --features derive test: name: Test Suite @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - run: cargo test --workspace + - run: cargo test --workspace --features derive unstable: name: Test Suite (unstable) @@ -47,4 +47,4 @@ jobs: with: components: clippy, rustfmt - run: cargo fmt --all --check - - run: cargo clippy --workspace + - run: cargo clippy --workspace --features derive From 04ba536629f2b5c2c4be3db7279520619ec7624c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= <martin.kroening@eonerc.rwth-aachen.de> Date: Thu, 25 Apr 2024 15:17:42 +0200 Subject: [PATCH 6/6] ci: deny warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de> --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e9d3357..f9137f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,10 @@ name: Build permissions: contents: read +env: + RUSTFLAGS: -Dwarnings + RUSTDOCFLAGS: -Dwarnings + jobs: check: name: Check