diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 92b5702..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 @@ -12,7 +16,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 +24,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 +51,4 @@ jobs: with: components: clippy, rustfmt - run: cargo fmt --all --check - - run: cargo clippy --workspace + - run: cargo clippy --workspace --features derive diff --git a/src/lib.rs b/src/lib.rs index 5dab31b..4cc9d61 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))))] @@ -62,7 +63,7 @@ /// /// ``` /// use volatile::access::ReadOnly; -/// use volatile::{VolatileFieldAccess, VolatilePtr, VolatileRef}; +/// use volatile::{VolatileFieldAccess, VolatileRef}; /// /// #[repr(C)] /// #[derive(VolatileFieldAccess, Default)] @@ -74,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); @@ -92,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>; /// diff --git a/src/volatile_ptr/mod.rs b/src/volatile_ptr/mod.rs index 0f1cbad..f625192 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 { - Some(Ord::cmp(&self.pointer.as_ptr(), &other.pointer.as_ptr())) + Some(self.cmp(other)) } } @@ -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 836b87d..3b98ac5 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 { - Some(Ord::cmp(&self.pointer.as_ptr(), &other.pointer.as_ptr())) + Some(self.cmp(other)) } } @@ -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()) } }