From ccaf9a84f8118f4a991e0046dbaecef4ea1c6950 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sun, 23 Mar 2025 00:17:34 +0700 Subject: [PATCH] Fix `clippy::implicit_saturating_sub` lints (#7395) --- wgpu-core/src/device/global.rs | 4 +--- wgpu-core/src/resource.rs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index fea06c146..af928dfb0 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -2188,10 +2188,8 @@ impl Global { let range_size = if let Some(size) = size { size - } else if offset > buffer.size { - 0 } else { - buffer.size - offset + buffer.size.saturating_sub(offset) }; if offset % wgt::MAP_ALIGNMENT != 0 { diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index f7f0fd652..f8a252d7c 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -439,10 +439,8 @@ impl Buffer { ) -> Result { let range_size = if let Some(size) = size { size - } else if offset > self.size { - 0 } else { - self.size - offset + self.size.saturating_sub(offset) }; if offset % wgt::MAP_ALIGNMENT != 0 {