fix: discard arguments in empty backend #87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The WGPU project uses
profiling
for debugging, and speaking as a maintainer of it, it's been lovely. Thank you so much for this crate!We wanted to give back by fixing an issue we noticed just now in gfx-rs/wgpu#6422 (comment) where arguments to
profiling
macros aren't evaluated. This causes the compiler to completely ignore whatever is provided as arguments when no features/backends forprofiling
are enabled. In turn, this can cause divergence in compiler errors if one accidentally writes code that wouldn't compile when a backend is disabled. For example, this Rust program compiles just fine withprofiling
1.0.16 anddefault-features = false
:As soon as a feature corresponding to a backend of
profiling
is enabled, the above would fail to compile, as one might expect. This is because Rust actually tries to use the expression arguments provided.This PR fixes this by explicitly discarding each argument in the empty backend, thus forcing Rust to actually try to use the expressions written. This should make any code written against the empty backend portable across all backends.