clippy: Allow some unnecessary casts

This commit is contained in:
Joining7943 2022-12-16 18:35:14 +01:00
parent c94a039358
commit ca0414d867
3 changed files with 9 additions and 23 deletions

View file

@ -2702,13 +2702,7 @@ fn file_is_executable(md: &Metadata) -> bool {
// S_IXUSR -> user has execute permission
// S_IXGRP -> group has execute permission
// S_IXOTH -> other users have execute permission
#[cfg(all(
not(target_os = "android"),
not(target_os = "freebsd"),
not(target_vendor = "apple")
))]
return md.mode() & (S_IXUSR | S_IXGRP | S_IXOTH) != 0;
#[cfg(any(target_os = "android", target_os = "freebsd", target_vendor = "apple"))]
#[allow(clippy::unnecessary_cast)]
return md.mode() & ((S_IXUSR | S_IXGRP | S_IXOTH) as u32) != 0;
}

View file

@ -277,17 +277,15 @@ impl Pinky {
let mesg;
let last_change;
match pts_path.metadata() {
#[allow(clippy::unnecessary_cast)]
Ok(meta) => {
#[cfg(all(
not(target_os = "android"),
not(target_os = "freebsd"),
not(target_vendor = "apple")
))]
let iwgrp = S_IWGRP;
#[cfg(any(target_os = "android", target_os = "freebsd", target_vendor = "apple"))]
let iwgrp = S_IWGRP as u32;
mesg = if meta.mode() & iwgrp != 0 { ' ' } else { '*' };
mesg = if meta.mode() & S_IWGRP as u32 != 0 {
' '
} else {
'*'
};
last_change = meta.atime();
}
_ => {

View file

@ -520,13 +520,7 @@ fn handle_writable_directory(path: &Path, options: &Options, metadata: &Metadata
let mode = metadata.permissions().mode();
// Check if directory has user write permissions
// Why is S_IWUSR showing up as a u16 on macos?
#[cfg(all(
not(target_os = "android"),
not(target_vendor = "apple"),
not(target_os = "freebsd")
))]
let user_writable = (mode & libc::S_IWUSR) != 0;
#[cfg(any(target_os = "android", target_os = "freebsd", target_vendor = "apple"))]
#[allow(clippy::unnecessary_cast)]
let user_writable = (mode & (libc::S_IWUSR as u32)) != 0;
if !user_writable {
prompt_yes!("remove write-protected directory {}?", path.quote())