Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up clippy errors from nightly on macos and linux targets #148

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tz_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ mod openwrt {
}
}

timezone.ok_or_else(|| crate::GetTimezoneError::OsError)
timezone.ok_or(crate::GetTimezoneError::OsError)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crate::GetTimezoneError::OsError is Copy which is why clippy says the closure is not needed.

}

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
Expand Down
9 changes: 6 additions & 3 deletions src/tz_macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ mod system_time_zone {
mod string_ref {
//! create safe wrapper around `CFStringRef`

use std::convert::TryInto;
use core::convert::TryInto;

use core_foundation_sys::base::{Boolean, CFRange};
use core_foundation_sys::string::{
Expand All @@ -100,7 +100,10 @@ mod string_ref {
// SAFETY: `StringRef` is only ever created with a valid `CFStringRef`.
let v = unsafe { CFStringGetCStringPtr(self.string, kCFStringEncodingUTF8) };
if !v.is_null() {
// SAFETY: `CFStringGetCStringPtr()` returns NUL-terminated strings.
// SAFETY: `CFStringGetCStringPtr()` returns NUL-terminated
// strings and will return NULL if the internal representation
// of the `CFString`` is not compatible with the requested
// encoding.
let v = unsafe { std::ffi::CStr::from_ptr(v) };
if let Ok(v) = v.to_str() {
return Some(v);
Expand All @@ -119,8 +122,8 @@ mod string_ref {
length,
};

// SAFETY: `StringRef` is only ever created with a valid `CFStringRef`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clippy::undocumented_unsafe_blocks wants the SAFETY comment on the block itself, not inside of it.

let converted_bytes = unsafe {
// SAFETY: `StringRef` is only ever created with a valid `CFStringRef`.
CFStringGetBytes(
self.string,
range,
Expand Down