diff --git a/crates/spirv-builder/src/lib.rs b/crates/spirv-builder/src/lib.rs index da3209f5c0..0afba9116d 100644 --- a/crates/spirv-builder/src/lib.rs +++ b/crates/spirv-builder/src/lib.rs @@ -92,7 +92,7 @@ pub use rustc_codegen_spirv_types::Capability; pub use rustc_codegen_spirv_types::{CompileResult, ModuleResult}; #[cfg(feature = "watch")] -pub use self::watch::Watch; +pub use self::watch::{AcceptFirstCompile, Watch}; #[cfg(feature = "include-target-specs")] pub use rustc_codegen_spirv_target_specs::TARGET_SPEC_DIR_PATH; diff --git a/crates/spirv-builder/src/watch.rs b/crates/spirv-builder/src/watch.rs index 5689393210..b54ec6ad4a 100644 --- a/crates/spirv-builder/src/watch.rs +++ b/crates/spirv-builder/src/watch.rs @@ -13,15 +13,10 @@ impl SpirvBuilder { /// Watches the module for changes using [`notify`], rebuilding it upon changes. /// /// Calls `on_compilation_finishes` after each successful compilation. - /// The second `Option>` param allows you to return some `T` - /// on the first compile, which is then returned by this function - /// in pair with [`JoinHandle`] to the watching thread. - pub fn watch( - &self, - mut on_compilation_finishes: impl FnMut(CompileResult, Option>) - + Send - + 'static, - ) -> Result, SpirvBuilderError> { + pub fn watch(&self, mut on_compilation_finishes: F) -> Result, SpirvBuilderError> + where + F: FnMut(CompileResult, Option>) + Send + 'static, + { let path_to_crate = self .path_to_crate .as_ref() @@ -79,15 +74,14 @@ impl SpirvBuilder { } } +/// The second parameter of the callback passed to [`SpirvBuilder::watch()`] +/// which allows it to return some value of `T` on the first compile. pub struct AcceptFirstCompile<'a, T>(&'a mut Option); impl<'a, T> AcceptFirstCompile<'a, T> { - pub fn new(write: &'a mut Option) -> Self { - Self(write) - } - - pub fn submit(self, t: T) { - *self.0 = Some(t); + /// Accepts some value of `T` to be later returned by [`SpirvBuilder::watch()`]. + pub fn submit(self, value: T) { + *self.0 = Some(value); } } diff --git a/tests/difftests/lib/src/scaffold/compute/wgpu.rs b/tests/difftests/lib/src/scaffold/compute/wgpu.rs index 7033f70fe7..a8cee4ec4c 100644 --- a/tests/difftests/lib/src/scaffold/compute/wgpu.rs +++ b/tests/difftests/lib/src/scaffold/compute/wgpu.rs @@ -64,7 +64,6 @@ where #[cfg(target_os = "windows")] dx12: wgpu::Dx12BackendOptions { shader_compiler: wgpu::Dx12Compiler::StaticDxc, - ..Default::default() }, ..Default::default() },