diff --git a/wgpu-core/src/command/bind.rs b/wgpu-core/src/command/bind.rs index 0a210e2b23..e8b13c60fd 100644 --- a/wgpu-core/src/command/bind.rs +++ b/wgpu-core/src/command/bind.rs @@ -20,7 +20,7 @@ mod compat { } impl Default for Entry { fn default() -> Self { - Entry { + Self { assigned: None, expected: None, } @@ -43,7 +43,7 @@ mod compat { impl Manager { pub fn new() -> Self { - Manager { + Self { entries: Default::default(), } } @@ -146,7 +146,7 @@ pub(super) struct Binder { impl Binder { pub(super) fn new() -> Self { - Binder { + Self { pipeline_layout_id: None, manager: compat::Manager::new(), payloads: Default::default(), diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 526c842b65..76813896a1 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -222,8 +222,8 @@ enum OptionalState { impl OptionalState { fn require(&mut self, require: bool) { - if require && *self == OptionalState::Unused { - *self = OptionalState::Required; + if require && *self == Self::Unused { + *self = Self::Required; } } } @@ -268,7 +268,7 @@ struct VertexBufferState { } impl VertexBufferState { - const EMPTY: Self = VertexBufferState { + const EMPTY: Self = Self { total_size: 0, stride: 0, rate: VertexStepMode::Vertex, diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index b831ac77c3..593830f1ce 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -84,7 +84,7 @@ impl RenderPassContext { // Assumed the renderpass only contains one subpass pub(crate) fn check_compatible( &self, - other: &RenderPassContext, + other: &Self, ) -> Result<(), RenderPassCompatibilityError> { if self.attachments.colors != other.attachments.colors { return Err(RenderPassCompatibilityError::IncompatibleColorAttachment( @@ -119,7 +119,7 @@ pub struct UserClosures { } impl UserClosures { - fn extend(&mut self, other: UserClosures) { + fn extend(&mut self, other: Self) { self.mappings.extend(other.mappings); self.submissions.extend(other.submissions); } diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 12afdeb16d..227020ae31 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -170,9 +170,9 @@ pub(crate) enum TextureInner { impl TextureInner { pub fn as_raw(&self) -> Option<&A::Texture> { match *self { - TextureInner::Native { raw: Some(ref tex) } => Some(tex), - TextureInner::Native { raw: None } => None, - TextureInner::Surface { + Self::Native { raw: Some(ref tex) } => Some(tex), + Self::Native { raw: None } => None, + Self::Surface { ref raw, parent_id: _, } => Some(std::borrow::Borrow::borrow(raw)), diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index 743f25e4d0..fc9ebf956a 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -923,7 +923,7 @@ impl Interface { entry_points.insert((entry_point.stage, entry_point.name.clone()), ep); } - Interface { + Self { features, resources, entry_points, diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 32905c6c94..3f47f791e1 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -545,7 +545,7 @@ struct MapContext { impl MapContext { fn new(total_size: BufferAddress) -> Self { - MapContext { + Self { total_size, initial_range: 0..0, sub_ranges: Vec::new(), @@ -1383,7 +1383,7 @@ impl Instance { /// - `backends` - Controls from which [backends][Backends] wgpu will choose /// during instantiation. pub fn new(backends: Backends) -> Self { - Instance { + Self { context: Arc::new(C::init(backends)), } } @@ -1399,7 +1399,7 @@ impl Instance { /// Refer to the creation of wgpu-hal Instance for every backend. #[cfg(not(target_arch = "wasm32"))] pub unsafe fn from_hal(hal_instance: A::Instance) -> Self { - Instance { + Self { context: Arc::new(C::from_hal_instance::(hal_instance)), } }