From a4d0d1c87be20ac2967e422c076c767937c1671a Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Thu, 19 Dec 2024 16:15:46 +0100 Subject: [PATCH] rusticl/util: fix ptr_to_integer_transmute_in_consts warning We simply remove the const attribute :) Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12288 Reviewed-by: @LingMan Part-of: --- src/gallium/frontends/rusticl/util/ptr.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/frontends/rusticl/util/ptr.rs b/src/gallium/frontends/rusticl/util/ptr.rs index 7e6b31d624b..be4cfa6efe8 100644 --- a/src/gallium/frontends/rusticl/util/ptr.rs +++ b/src/gallium/frontends/rusticl/util/ptr.rs @@ -109,7 +109,7 @@ macro_rules! offset_of { // See https://github.com/rust-lang/rust/issues/96284 #[must_use] #[inline] -pub const fn is_aligned(ptr: *const T) -> bool +pub fn is_aligned(ptr: *const T) -> bool where T: Sized, { @@ -121,7 +121,7 @@ where // See https://github.com/rust-lang/rust/issues/95228 #[must_use] #[inline(always)] -pub const fn addr(ptr: *const T) -> usize { +pub fn addr(ptr: *const T) -> usize { // The libcore implementations of `addr` and `expose_addr` suggest that, while both transmuting // and casting to usize will give you the address of a ptr in the end, they are not identical // in their side-effects. @@ -129,8 +129,8 @@ pub const fn addr(ptr: *const T) -> usize { // aggressively around it. // Let's trust the libcore devs over clippy on whether a transmute also exposes a ptr. #[allow(clippy::transmutes_expressible_as_ptr_casts)] - // SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the - // provenance). + // SAFETY: Pointer-to-integer transmutes are valid outside of const contexts (if you are okay + // with losing the provenance). unsafe { mem::transmute(ptr.cast::<()>()) }