From cf1f618a7bf08a1a1dcfa2aa4f1a702a1307fbb0 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Tue, 16 Dec 2025 16:34:35 +0000 Subject: [PATCH] clippy: fix ptr_cast_constness lint https://rust-lang.github.io/rust-clippy/master/index.html#ptr_cast_constness --- Cargo.toml | 1 - src/uucore/src/lib/features/entries.rs | 6 +++--- src/uucore/src/lib/features/utmpx.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2a7364644..85acff949 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -667,7 +667,6 @@ should_panic_without_expect = "allow" # 2 doc_markdown = "allow" unused_self = "allow" enum_glob_use = "allow" -ptr_cast_constness = "allow" needless_raw_string_hashes = "allow" unreadable_literal = "allow" unnested_or_patterns = "allow" diff --git a/src/uucore/src/lib/features/entries.rs b/src/uucore/src/lib/features/entries.rs index d3796890a..6a067e132 100644 --- a/src/uucore/src/lib/features/entries.rs +++ b/src/uucore/src/lib/features/entries.rs @@ -290,7 +290,7 @@ macro_rules! f { unsafe { let data = $fid(k); if !data.is_null() { - Ok($st::from_raw(ptr::read(data as *const _))) + Ok($st::from_raw(ptr::read(data.cast_const()))) } else { // FIXME: Resource limits, signals and I/O failure may // cause this too. See getpwnam(3). @@ -317,12 +317,12 @@ macro_rules! f { // f!(getgrnam, getgrgid, gid_t, Group); let data = $fnam(cstring.as_ptr()); if !data.is_null() { - return Ok($st::from_raw(ptr::read(data as *const _))); + return Ok($st::from_raw(ptr::read(data.cast_const()))); } if let Ok(id) = k.parse::<$t>() { let data = $fid(id); if !data.is_null() { - Ok($st::from_raw(ptr::read(data as *const _))) + Ok($st::from_raw(ptr::read(data.cast_const()))) } else { Err(IOError::new( ErrorKind::NotFound, diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index 3c18cc16f..8832caff3 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -525,7 +525,7 @@ impl Iterator for UtmpxIter { // All the strings live inline in the struct as arrays, which // makes things easier. Some(UtmpxRecord::Traditional(Box::new(Utmpx { - inner: ptr::read(res as *const _), + inner: ptr::read(res.cast_const()), }))) } }