Skip to content

Commit

Permalink
Fix Clippy, MSRV and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 20, 2024
1 parent 08f7562 commit b510931
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crates/dispatch2/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ macro_rules! create_opaque_type {
#[allow(missing_docs)]
pub type $typedef_name = *mut $type_name;

// SAFETY: Dispatch types are internally objects.
#[cfg(feature = "objc2")]
// SAFETY: Dispatch types are internally objects.
unsafe impl RefEncode for $type_name {
const ENCODING_REF: Encoding = Encoding::Object;
}
Expand All @@ -52,13 +52,14 @@ macro_rules! enum_with_val {
}
}

// SAFETY: Marked with `#[repr(transparent)]` above.
#[cfg(feature = "objc2")]
// SAFETY: Marked with `#[repr(transparent)]` above.
unsafe impl Encode for $ident {
const ENCODING: Encoding = <$ty>::ENCODING;
}

#[cfg(feature = "objc2")]
// SAFETY: Same as above.
unsafe impl RefEncode for $ident {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
Expand All @@ -81,13 +82,14 @@ pub type dispatch_function_t = extern "C" fn(*mut c_void);
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Eq, Ord)]
pub struct dispatch_time_t(pub u64);

// SAFETY: `dispatch_time_t` is `#[repr(transparent)]`
#[cfg(feature = "objc2")]
// SAFETY: `dispatch_time_t` is `#[repr(transparent)]`.
unsafe impl Encode for dispatch_time_t {
const ENCODING: Encoding = u64::ENCODING;
}

#[cfg(feature = "objc2")]
// SAFETY: Same as above.
unsafe impl RefEncode for dispatch_time_t {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
Expand Down Expand Up @@ -233,7 +235,9 @@ extern "C-unwind" {
pub fn dispatch_main() -> !;
}

pub const extern "C" fn dispatch_get_main_queue() -> dispatch_queue_main_t {
// Inline function in the header
addr_of!(_dispatch_main_q) as dispatch_queue_main_t
// Inline function in the header
#[allow(unused_unsafe)] // MSRV. Also, we'd like to mark this as `const`
pub extern "C" fn dispatch_get_main_queue() -> dispatch_queue_main_t {
// SAFETY: Always safe to get pointer from static, only needed for MSRV.
unsafe { addr_of!(_dispatch_main_q) as dispatch_queue_main_t }
}
1 change: 1 addition & 0 deletions crates/dispatch2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use self::ffi::dispatch_qos_class_t;

pub mod ffi;
#[allow(clippy::undocumented_unsafe_blocks)]
mod generated;
pub mod group;
pub mod object;
Expand Down
1 change: 1 addition & 0 deletions framework-crates/objc2-core-foundation/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ impl CGSize {
/// assert_eq!(CGSize::new(-1.0, 1.0).abs(), CGSize::new(1.0, 1.0));
/// ```
#[inline]
#[cfg(feature = "std")] // Only available in core since Rust 1.85
pub fn abs(self) -> Self {
Self::new(self.width.abs(), self.height.abs())
}
Expand Down

0 comments on commit b510931

Please sign in to comment.