diff --git a/Cargo.toml b/Cargo.toml index 05d4c4ec593..a743def7d49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,7 +83,6 @@ wgpu = { version = "29.0.0", path = "./wgpu", default-features = false, features "vulkan-portability", "angle", "static-dxc", - "noop", # This should be removed if we ever have non-test crates that depend on wgpu ] } wgpu-core = { version = "29.0.0", path = "./wgpu-core" } wgpu-hal = { version = "29.0.0", path = "./wgpu-hal" } diff --git a/tests/tests/wgpu-dependency/main.rs b/tests/tests/wgpu-dependency/main.rs index ac96afdb0e1..a2d1c6ca2ed 100644 --- a/tests/tests/wgpu-dependency/main.rs +++ b/tests/tests/wgpu-dependency/main.rs @@ -24,7 +24,7 @@ fn check_feature_dependency(requirement: Requirement) { println!("Checking: {}", requirement.human_readable_name); let mut args = Vec::new(); - args.extend(["tree", "--target", requirement.target]); + args.extend(["tree", "--edges", "no-dev", "--target", requirement.target]); for package in requirement.packages { args.push("--package"); @@ -43,11 +43,15 @@ fn check_feature_dependency(requirement: Requirement) { println!("$ cargo {}", args.join(" ")); - let output = Command::new("cargo") - .args(&args) - .output() - .expect("Failed to run cargo tree") - .stdout; + let output = match Command::new("cargo").args(&args).output() { + Ok(o) if o.status.success() => o.stdout, + Ok(o) => panic!( + "cargo tree failed ({}):\n{}", + o.status, + String::from_utf8_lossy(&o.stderr) + ), + Err(e) => panic!("Failed to run cargo tree: {e}"), + }; let output = String::from_utf8(output).expect("Output is not valid UTF-8"); let mut any_failed = false; @@ -117,6 +121,15 @@ fn wasm32_without_webgl_or_noop_does_not_depend_on_wgpu_core() { default_features: false, search_terms: &[Search::Negative("wgpu-core")], }); + + check_feature_dependency(Requirement { + human_readable_name: "wasm32 with only `webgpu` feature does not depend on `wgpu-core`", + target: "wasm32-unknown-unknown", + packages: &["wgpu-examples"], + features: &["webgpu"], + default_features: false, + search_terms: &[Search::Negative("wgpu-core")], + }); } #[test] @@ -129,6 +142,15 @@ fn wasm32_with_webgpu_and_wgsl_does_not_depend_on_naga() { default_features: false, search_terms: &[Search::Negative("naga")], }); + + check_feature_dependency(Requirement { + human_readable_name: "wasm32 with only `webgpu` feature does not depend on `naga`", + target: "wasm32-unknown-unknown", + packages: &["wgpu-examples"], + features: &["webgpu"], + default_features: false, + search_terms: &[Search::Negative("naga")], + }); } #[test] diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index 7c62d605ca9..e71254d117b 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -44,7 +44,7 @@ serde = ["dep:serde", "bitflags/serde"] # Enables some internal instrumentation for debugging purposes. counters = [] # Enables variants of `Trace` other than `Trace::Off` -trace = ["std"] +trace = ["std", "serde/std"] # Enable web-specific dependencies for wasm. web = ["dep:js-sys", "dep:web-sys"] exhaust = ["dep:exhaust"] diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 9a92244cc6a..f39f32ca122 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -130,8 +130,8 @@ strict_asserts = ["wgpu-core?/strict_asserts", "wgpu-types/strict_asserts"] ## Enables serialization via `serde` on common wgpu types. serde = ["wgpu-core?/serde", "wgpu-types/serde"] -# ## Allow writing of trace capture files. See [`Adapter::request_device`]. -trace = ["serde", "wgpu-core?/trace"] +## Allow writing of trace capture files. See [`Adapter::request_device`]. +trace = ["serde", "wgpu-core?/trace", "wgpu-types/trace"] #! ### External libraries # -------------------------------------------------------------------- diff --git a/wgpu/src/api/buffer.rs b/wgpu/src/api/buffer.rs index 3f1c7e66163..2619f9df311 100644 --- a/wgpu/src/api/buffer.rs +++ b/wgpu/src/api/buffer.rs @@ -2,7 +2,7 @@ use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec}; use core::{ error, fmt, num::NonZero, - ops::{Bound, Deref, Range, RangeBounds}, + ops::{Bound, Range, RangeBounds}, }; use crate::util::Mutex; @@ -287,7 +287,7 @@ impl Buffer { #[cfg(wgpu_core)] pub unsafe fn as_hal( &self, - ) -> Option + WasmNotSendSync> { + ) -> Option + WasmNotSendSync> { let buffer = self.inner.as_core_opt()?; unsafe { buffer.context.buffer_as_hal::(buffer) } } diff --git a/wgpu/src/api/queue.rs b/wgpu/src/api/queue.rs index 2d0fbd70ce9..93c43158ecf 100644 --- a/wgpu/src/api/queue.rs +++ b/wgpu/src/api/queue.rs @@ -1,5 +1,5 @@ use alloc::boxed::Box; -use core::ops::{Deref, RangeBounds}; +use core::ops::RangeBounds; use crate::{api::DeferredCommandBufferActions, *}; @@ -338,7 +338,7 @@ impl Queue { #[cfg(wgpu_core)] pub unsafe fn as_hal( &self, - ) -> Option + WasmNotSendSync> { + ) -> Option + WasmNotSendSync> { let queue = self.inner.as_core_opt()?; unsafe { queue.context.queue_as_hal::(queue) } } diff --git a/wgpu/src/dispatch.rs b/wgpu/src/dispatch.rs index 2f8031ee80b..57c0511c87e 100644 --- a/wgpu/src/dispatch.rs +++ b/wgpu/src/dispatch.rs @@ -603,6 +603,8 @@ pub trait QueueWriteBufferInterface: CommonTraits { } pub trait BufferMappedRangeInterface: CommonTraits { + // Used only in wgpu_core's `impl QueueWriteBufferInterface` + #[cfg_attr(not(wgpu_core), expect(unused))] fn len(&self) -> usize; /// # Safety diff --git a/wgpu/src/macros/mod.rs b/wgpu/src/macros/mod.rs index 7adb6b169d7..95979796e6a 100644 --- a/wgpu/src/macros/mod.rs +++ b/wgpu/src/macros/mod.rs @@ -1,4 +1,5 @@ //! Convenience macros +#![cfg_attr(not(wgpu_core), expect(unused_macros, unused_imports))] #[cfg(doc)] use crate::{VertexAttribute, VertexBufferLayout, VertexFormat};