Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We should consider using #[rustc_on_unimplemented] on spirv-std helper traits. #983

Open
eddyb opened this issue Jan 5, 2023 · 0 comments
Labels
t: enhancement A new feature or improvement to an existing one.

Comments

@eddyb
Copy link
Contributor

eddyb commented Jan 5, 2023

I was reviewing this nightly bump PR:

And its diff shows some nightly diagnostic improvements of the form:

 12  |     *output = image.query_levels();
-    |               ^^^^^ ------------ required by a bound introduced by this call
-    |               |
-    |               the trait `HasQueryLevels` is not implemented for `Image<f32, 4, 2, 0, 0, 1, 0>`
+    |                     ^^^^^^^^^^^^ the trait `HasQueryLevels` is not implemented for `Image<f32, 4, 2, 0, 0, 1, 0>`
     |
     = help: the following other types implement trait `HasQueryLevels`:
               Image<SampledType, 0, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT>

That's definitely better, but the trait can't really explain itself and its connection to the types (i.e. "Image types support query_levels only if such and such parameters have these values" etc.).

Except, in core/std, traits can and very much do do this, using #[rustc_on_unimplemented]!

It's perma-unstable, and there might be efforts to stabilize a subset of it, but even ignoring that, we can still use it under #[cfg_attr(target_arch = "spirv", ...)], just like all the other rustc internals we rely on.

@eddyb eddyb added the t: enhancement A new feature or improvement to an existing one. label Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: enhancement A new feature or improvement to an existing one.
Projects
None yet
Development

No branches or pull requests

1 participant