Skip to content

Commit 5988118

Browse files
committed
bevy_render: dropped texture view is not Drop in wasm (#22303)
# Objective - `cargo clippy --no-deps --package bevy_render --target wasm32-unknown-unknown` fails: ``` warning: call to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes --> crates/bevy_render/src/view/window/mod.rs:416:13 | 416 | drop(window.swap_chain_texture_view.take()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type `std::option::Option<render_resource::texture::TextureView>` --> crates/bevy_render/src/view/window/mod.rs:416:18 | 416 | drop(window.swap_chain_texture_view.take()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#drop_non_drop = note: `#[warn(clippy::drop_non_drop)]` on by default warning: `bevy_render` (lib) generated 1 warning ``` ## Solution - Expect the lint in wasm. It's not an actual problem, and special casing for wasm wouldn't be better
1 parent 8c207fb commit 5988118

File tree

1 file changed

+4
-0
lines changed
  • crates/bevy_render/src/view/window

1 file changed

+4
-0
lines changed

crates/bevy_render/src/view/window/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ pub fn create_surfaces(
413413
// normally this is dropped on present but we double check here to be safe as failure to
414414
// drop it will cause validation errors in wgpu
415415
drop(window.swap_chain_texture.take());
416+
#[cfg_attr(
417+
target_arch = "wasm32",
418+
expect(clippy::drop_non_drop, reason = "texture views are not drop on wasm")
419+
)]
416420
drop(window.swap_chain_texture_view.take());
417421

418422
data.configuration.width = window.physical_width;

0 commit comments

Comments
 (0)