diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 48f862f8ba..e0b3d31e84 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -6,6 +6,8 @@ use crate::{ proc::{self, NameKey, TypeResolution}, valid, FastHashMap, FastHashSet, }; +#[cfg(test)] +use std::ptr; use std::{ fmt::{Display, Error as FmtError, Formatter, Write}, iter, @@ -1411,9 +1413,8 @@ impl Writer { ) -> BackendResult { // Add to the set in order to track the stack size. #[cfg(test)] - #[allow(trivial_casts)] self.put_expression_stack_pointers - .insert(&expr_handle as *const _ as *const ()); + .insert(ptr::from_ref(&expr_handle).cast()); if let Some(name) = self.named_expressions.get(&expr_handle) { write!(self.out, "{name}")?; @@ -2792,9 +2793,8 @@ impl Writer { ) -> BackendResult { // Add to the set in order to track the stack size. #[cfg(test)] - #[allow(trivial_casts)] self.put_block_stack_pointers - .insert(&level as *const _ as *const ()); + .insert(ptr::from_ref(&level).cast()); for statement in statements { log::trace!("statement[{}] {:?}", level.0, statement); diff --git a/wgpu-hal/src/dynamic/device.rs b/wgpu-hal/src/dynamic/device.rs index c1baf5b76d..1386196d60 100644 --- a/wgpu-hal/src/dynamic/device.rs +++ b/wgpu-hal/src/dynamic/device.rs @@ -1,6 +1,3 @@ -// Box casts are needed, alternative would be a temporaries which are more verbose and not more expressive. -#![allow(trivial_casts)] - use crate::{ AccelerationStructureBuildSizes, AccelerationStructureDescriptor, Api, BindGroupDescriptor, BindGroupLayoutDescriptor, BufferDescriptor, BufferMapping, CommandEncoderDescriptor, @@ -261,7 +258,7 @@ impl DynDevice for D { queue: desc.queue.expect_downcast_ref(), }; unsafe { D::create_command_encoder(self, &desc) } - .map(|b| Box::new(b) as Box) + .map(|b| -> Box { Box::new(b) }) } unsafe fn destroy_command_encoder(&self, encoder: Box) { @@ -273,7 +270,7 @@ impl DynDevice for D { desc: &BindGroupLayoutDescriptor, ) -> Result, DeviceError> { unsafe { D::create_bind_group_layout(self, desc) } - .map(|b| Box::new(b) as Box) + .map(|b| -> Box { Box::new(b) }) } unsafe fn destroy_bind_group_layout(&self, bg_layout: Box) { @@ -297,7 +294,7 @@ impl DynDevice for D { }; unsafe { D::create_pipeline_layout(self, &desc) } - .map(|b| Box::new(b) as Box) + .map(|b| -> Box { Box::new(b) }) } unsafe fn destroy_pipeline_layout(&self, pipeline_layout: Box) { @@ -345,7 +342,8 @@ impl DynDevice for D { acceleration_structures: &acceleration_structures, }; - unsafe { D::create_bind_group(self, &desc) }.map(|b| Box::new(b) as Box) + unsafe { D::create_bind_group(self, &desc) } + .map(|b| -> Box { Box::new(b) }) } unsafe fn destroy_bind_group(&self, group: Box) { @@ -358,7 +356,7 @@ impl DynDevice for D { shader: ShaderInput, ) -> Result, ShaderError> { unsafe { D::create_shader_module(self, desc, shader) } - .map(|b| Box::new(b) as Box) + .map(|b| -> Box { Box::new(b) }) } unsafe fn destroy_shader_module(&self, module: Box) { @@ -388,7 +386,7 @@ impl DynDevice for D { }; unsafe { D::create_render_pipeline(self, &desc) } - .map(|b| Box::new(b) as Box) + .map(|b| -> Box { Box::new(b) }) } unsafe fn destroy_render_pipeline(&self, pipeline: Box) { @@ -411,7 +409,7 @@ impl DynDevice for D { }; unsafe { D::create_compute_pipeline(self, &desc) } - .map(|b| Box::new(b) as Box) + .map(|b| -> Box { Box::new(b) }) } unsafe fn destroy_compute_pipeline(&self, pipeline: Box) { @@ -423,7 +421,7 @@ impl DynDevice for D { desc: &PipelineCacheDescriptor<'_>, ) -> Result, PipelineCacheError> { unsafe { D::create_pipeline_cache(self, desc) } - .map(|b| Box::new(b) as Box) + .map(|b| -> Box { Box::new(b) }) } fn pipeline_cache_validation_key(&self) -> Option<[u8; 16]> { @@ -438,7 +436,7 @@ impl DynDevice for D { &self, desc: &wgt::QuerySetDescriptor