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

Detect a common syntax error case for diagnostic_directive #6718

Merged

Conversation

e-hat
Copy link
Contributor

@e-hat e-hat commented Dec 13, 2024

If the user has a global_decl of the form @diagnostic(...);, display a note suggesting they remove the @ to create a global diagnostic_directive, which will apply the diagnostic filter to the entire module.

Connections
Addresses #6536.

Description
Sometimes the user will intend to declare a diagnostic_directive to apply a diagnostic filter to the entire module using the following incorrect syntax, i.e.:

@diagnostic(off, my.lint);

The @ symbol is used to declare a scoped diagnostic attribute (diagnostic_attr) but not a global diagnostic_directive. This change adds a note to the error message in this case to use the correct syntax:

diagnostic(off, my.list);

Testing
Added a test front::wgsl::tests::diagnostic_filter::intended_global_directive that tests the case described above against the expected error message + notes.

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Not sure about some steps in the checklist, maybe these checks are failing because of my local setup. Also not sure if this small change belongs in the changelog. Thanks.

If the user has a global_decl of the form `@diagnostic(...);`, display a
note suggesting they remove the `@` to create a diagnostic_directive, if
that is their intent.
@e-hat e-hat requested a review from a team as a code owner December 13, 2024 00:32
@cwfitzgerald
Copy link
Member

cwfitzgerald commented Dec 13, 2024

Definitely want a note on the changelog, will also make sure you get listed as a contributor to the release :)

@ErichDonGubler ErichDonGubler self-assigned this Dec 16, 2024
@ErichDonGubler ErichDonGubler added type: enhancement New feature or request naga Shader Translator area: naga front-end lang: WGSL WebGPU Shading Language kind: diagnostics Error message should be better labels Dec 16, 2024
Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a few tweaks to the original changes. @e-hat, did you have any thoughts on what I pushed up before merging?

@ErichDonGubler
Copy link
Member

@e-hat: Also welcome, and thanks for making diagnostics in naga better! 😀

@cwfitzgerald cwfitzgerald merged commit 79280bc into gfx-rs:trunk Dec 18, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga front-end kind: diagnostics Error message should be better lang: WGSL WebGPU Shading Language naga Shader Translator type: enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants