schell / schell/wgsl-rs

Support todo!() macro inside #[wgsl] modules

Open
#89 0 comments 0 reactions 0 assignees View on GitHub
enhancement P3
Dominant language
Rust
Stars
61
Forks
4
Avg merge
1d 21h
Merged PRs (30d)
9

Description

## Summary

Allow `todo!()` to be used inside `#[wgsl]` modules as a placeholder for unfinished code during development.

## Motivation

When iterating on shader code, it's common to stub out functions with `todo!()` in Rust. Currently the `#[wgsl]` proc macro doesn't recognize `todo!()` and will either reject it or produce incorrect output. Supporting it would make the development workflow smoother.

## Proposed behavior

- **Rust world (CPU):** `todo!()` should continue to panic at runtime as usual.
- **WGSL world (GPU):** The transpiler could either:
1. Emit a dummy/zero value appropriate for the return type, or
2. Emit an early return with a sentinel value, or
3. Simply omit the body and let naga validation catch it.

Option (1) is probably the most practical — it keeps the shader valid so compilation succeeds and other parts of the module can be tested.

## Example

```rust
#[wgsl]
mod my_shader {
fn compute_lighting(normal: Vec3f, light_dir: Vec3f) -> Vec4f {
todo!()
}
}
```

Should compile and produce valid WGSL (e.g. returning `vec4(0.0, 0.0, 0.0, 0.0)`).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.