Skip to content

Commit

Permalink
Merge pull request #56 from mkroening/ci-warnings
Browse files Browse the repository at this point in the history
Fix warnings and deny warnings in CI
  • Loading branch information
phil-opp authored Apr 26, 2024
2 parents d45ab47 + 04ba536 commit 1b97156
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@ name: Build
permissions:
contents: read

env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo check --workspace
- run: cargo check --workspace --features derive

test:
name: Test Suite
runs-on: ubuntu-latest
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)
Expand All @@ -47,4 +51,4 @@ jobs:
with:
components: clippy, rustfmt
- run: cargo fmt --all --check
- run: cargo clippy --workspace
- run: cargo clippy --workspace --features derive
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))))]
Expand All @@ -62,7 +63,7 @@
///
/// ```
/// use volatile::access::ReadOnly;
/// use volatile::{VolatileFieldAccess, VolatilePtr, VolatileRef};
/// use volatile::{VolatileFieldAccess, VolatileRef};
///
/// #[repr(C)]
/// #[derive(VolatileFieldAccess, Default)]
Expand All @@ -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);
Expand All @@ -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>;
///
Expand Down
3 changes: 2 additions & 1 deletion src/volatile_ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand All @@ -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())
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/volatile_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand All @@ -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())
}
}
Expand Down

0 comments on commit 1b97156

Please sign in to comment.