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_IXUSR -> user has execute permission
// S_IXGRP -> group has execute permission // S_IXGRP -> group has execute permission
// S_IXOTH -> other users have execute permission // S_IXOTH -> other users have execute permission
#[cfg(all( #[allow(clippy::unnecessary_cast)]
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"))]
return md.mode() & ((S_IXUSR | S_IXGRP | S_IXOTH) as u32) != 0; return md.mode() & ((S_IXUSR | S_IXGRP | S_IXOTH) as u32) != 0;
} }

View file

@ -277,17 +277,15 @@ impl Pinky {
let mesg; let mesg;
let last_change; let last_change;
match pts_path.metadata() { match pts_path.metadata() {
#[allow(clippy::unnecessary_cast)]
Ok(meta) => { Ok(meta) => {
#[cfg(all( mesg = if meta.mode() & S_IWGRP as u32 != 0 {
not(target_os = "android"), ' '
not(target_os = "freebsd"), } else {
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 { '*' };
last_change = meta.atime(); 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(); let mode = metadata.permissions().mode();
// Check if directory has user write permissions // Check if directory has user write permissions
// Why is S_IWUSR showing up as a u16 on macos? // Why is S_IWUSR showing up as a u16 on macos?
#[cfg(all( #[allow(clippy::unnecessary_cast)]
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"))]
let user_writable = (mode & (libc::S_IWUSR as u32)) != 0; let user_writable = (mode & (libc::S_IWUSR as u32)) != 0;
if !user_writable { if !user_writable {
prompt_yes!("remove write-protected directory {}?", path.quote()) prompt_yes!("remove write-protected directory {}?", path.quote())