Skip to content

fix(spirv-builder): remove unwraps from SpirvWatcher - #690

Closed
sorinirimies wants to merge 1 commit into
Rust-GPU:mainfrom
sorinirimies:fix/spirv-watcher-no-unwrap
Closed

sorinirimies wants to merge 1 commit into
Rust-GPU:mainfrom
sorinirimies:fix/spirv-watcher-no-unwrap

Conversation

@sorinirimies

Copy link
Copy Markdown

Summary

Removes two unwrap()s from SpirvWatcher that could take down a long-running watch loop.

 fn watch_leaf_deps(deps)
-  for dep in deps
-    let path = dep.to_path().unwrap()     // panics on non-UTF-8 (non-Unix)
+  for path in deps.filter_map(dep_to_path) // logs + skips non-UTF-8 paths

 fn recv()
-  recv_inner(blocking).map(|r| r.unwrap())
+  loop { if let Some(r) = recv_inner(blocking)? { return Ok(r) } }

A blocking recv never reports Empty, so the loop is only reached if that invariant breaks — and waiting for the next change is the correct fallback there instead of a panic.

Evidence

New tests in watch::tests:

dep_to_path_converts_utf8_paths   ok
dep_to_path_handles_empty_path    ok
dep_to_path_non_utf8              ok   (Unix: accepted; elsewhere: None)

cargo test -p spirv-builder --features watch,clap: 7 passed. Clippy -D warnings clean. The non-Unix branch of dep_to_path_non_utf8 is exercised by Windows CI.

Merge Danger

Door: two-way

Blast Radius: small — watch feature only; behavior changes solely in the previously-panicking cases.

- Non-UTF-8 dep-file paths (non-Unix only) are logged and skipped
  instead of panicking the watcher.
- `recv` no longer unwraps the build result of `recv_inner`.
@Firestar99 Firestar99 closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants