nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: gfx-rs/wgpu
Pull request #5917 (2024-07-05 01:49:06)

refactor!: suppress `dead_code` in `wgpu::util::DownloadBuffer`
**Connections**

N/A

**Description**

We actually want to keep the `Arc<…>` holding the GPU resource until the CPU-accessible buffer is done being used, so make `DownloadBuffer` a `struct` with named fields, and give the field the name `_gpu_buffer`.

**Testing**

Still compiles!

**Checklist**

- [x] Run `cargo fmt`.
- [x] Run `cargo clippy`. If applicable, add:
  - [x] `--target wasm32-unknown-unknown`
  - [x] `--target wasm32-unknown-emscripten`
- [x] Run `cargo xtask test` to run tests.
- [x] ~~Add change to `CHANGELOG.md`. See simple instructions inside file.~~ Not necessary.



Patch:
diff --git a/wgpu/src/util/mod.rs b/wgpu/src/util/mod.rs
index d83263bcf..f52b82a9c 100644
--- a/wgpu/src/util/mod.rs
+++ b/wgpu/src/util/mod.rs
@@ -82,10 +82,10 @@ pub fn make_spirv_raw(data: &[u8]) -> Cow<'_, [u32]> {
 }
 
 /// CPU accessible buffer used to download data back from the GPU.
-pub struct DownloadBuffer(
-    Arc<super::Buffer>,
-    Box<dyn crate::context::BufferMappedRange>,
-);
+pub struct DownloadBuffer {
+    _gpu_buffer: Arc<super::Buffer>,
+    mapped_range: Box<dyn crate::context::BufferMappedRange>,
+}
 
 impl DownloadBuffer {
     /// Asynchronously read the contents of a buffer.
@@ -129,7 +129,10 @@ impl DownloadBuffer {
                     download.data.as_ref(),
                     0..size,
                 );
-                callback(Ok(Self(download, mapped_range)));
+                callback(Ok(Self {
+                    _gpu_buffer: download,
+                    mapped_range,
+                }));
             });
     }
 }
@@ -137,7 +140,7 @@ impl DownloadBuffer {
 impl std::ops::Deref for DownloadBuffer {
     type Target = [u8];
     fn deref(&self) -> &[u8] {
-        self.1.slice()
+        self.mapped_range.slice()
     }
 }
 


Test patch:
diff --git a/tests/Cargo.toml b/tests/Cargo.toml
index d6b5ae672..63776a174 100644
--- a/tests/Cargo.toml
+++ b/tests/Cargo.toml
@@ -38,7 +38,7 @@ serde_json.workspace = true
 serde.workspace = true
 strum = { workspace = true, features = ["derive"] }
 wgpu-macros.workspace = true
-wgpu.workspace = true
+wgpu = { workspace = true, features = ["wgsl"] }
 wgt = { workspace = true, features = ["serde"] }
 
 [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Repository: gfx-rs/wgpu
Pull request #6000 (2024-07-20 03:22:24)

Remove `allow(unknown_lints)` and `clippy::if_then_panic`
**Description**
These were present for 2 reasons:

* Allowing the use of `clippy::derivable_impls` while it was nightly only. This is no longer nightly only for a long time.
* Allowing the use of `clippy::if_then_panic` while it was nightly only. This was renamed to `clippy::manual_assert` in Rust 1.59 and doesn't trigger within the repository.

**Testing**
CI passes.

**Checklist**

- [x] Run `cargo fmt`.
- [x] Run `cargo clippy`. If applicable, add:
  - [ ] `--target wasm32-unknown-unknown`
  - [ ] `--target wasm32-unknown-emscripten`
- [x] Run `cargo xtask test` to run tests.
- [ ] Add change to `CHANGELOG.md`. See simple instructions inside file.



Patch:
diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs
index 550befd14..706c369eb 100644
--- a/wgpu-hal/src/lib.rs
+++ b/wgpu-hal/src/lib.rs
@@ -207,8 +207,6 @@
 #![allow(
     // this happens on the GL backend, where it is both thread safe and non-thread safe in the same code.
     clippy::arc_with_non_send_sync,
-    // for `if_then_panic` until it reaches stable
-    unknown_lints,
     // We don't use syntax sugar where it's not necessary.
     clippy::match_like_matches_macro,
     // Redundant matching is more explicit.
@@ -221,8 +219,6 @@
     clippy::single_match,
     // Push commands are more regular than macros.
     clippy::vec_init_then_push,
-    // "if panic" is a good uniform construct.
-    clippy::if_then_panic,
     // We unsafe impl `Send` for a reason.
     clippy::non_send_fields_in_send_ty,
     // TODO!
diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs
index 59b5bf57a..dbe3a010b 100644
--- a/wgpu-types/src/lib.rs
+++ b/wgpu-types/src/lib.rs
@@ -1482,7 +1482,6 @@ impl Limits {
 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
 pub struct DownlevelLimits {}
 
-#[allow(unknown_lints)] // derivable_impls is nightly only currently
 #[allow(clippy::derivable_impls)]
 impl Default for DownlevelLimits {
     fn default() -> Self {


Test patch:
diff --git a/player/tests/test.rs b/player/tests/test.rs
index a5aba15bd..864f9429a 100644
--- a/player/tests/test.rs
+++ b/player/tests/test.rs
@@ -171,7 +171,6 @@ impl Test<'_> {
                     .collect::<Vec<u8>>(),
             };
 
-            #[allow(unknown_lints, clippy::if_then_panic)]
             if &expected_data[..] != contents {
                 panic!(
                     "Test expectation is not met!\nBuffer content was:\n{:?}\nbut expected:\n{:?}",