-
Notifications
You must be signed in to change notification settings - Fork 963
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
[naga] parse @must_use
attribute
#6801
base: trunk
Are you sure you want to change the base?
Conversation
17da613
to
1331f0f
Compare
@must_use
attribute@must_use
attribute
1331f0f
to
201ce67
Compare
Looking at discussion in the
I expect that many particularities may complicate validation, so tests are provided for slightly complex valid examples. I'm unfamiliar with how naga's AST behaves, and looking through the validation code, it didn't seem obvious where/how to validate that a |
Are there likely to be important validation differences between constant and variable values? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some commentary
pub struct FunctionResult<'a> { | ||
pub ty: Handle<Type<'a>>, | ||
pub binding: Option<Binding<'a>>, | ||
pub must_use: bool, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must_use
is a required member of wgsl ast FunctionResult
.
Some(ast::FunctionResult { | ||
ty, | ||
binding, | ||
must_use, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ast::FunctionResult
creations are updated
naga/src/front/wgsl/parse/mod.rs
Outdated
@@ -2455,6 +2460,7 @@ impl Parser { | |||
let (mut bind_index, mut bind_group) = | |||
(ParsedAttribute::default(), ParsedAttribute::default()); | |||
let mut id = ParsedAttribute::default(); | |||
let mut must_use = ParsedAttribute::default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attribute is handled in global_decl
is there another location in which @must_use
might validly appear?
should invalid locations recognize the attribute at all?
possibly, some global declarations should not have the @must_use
attribute. no checks are performed.
naga/src/front/wgsl/parse/mod.rs
Outdated
@@ -2333,6 +2333,7 @@ impl Parser { | |||
diagnostic_filter_leaf: Option<Handle<DiagnosticFilterNode>>, | |||
out: &mut ast::TranslationUnit<'a>, | |||
dependencies: &mut FastIndexSet<ast::Dependency<'a>>, | |||
must_use: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added a parameter to function_decl
for this attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these examples seem to be permitted, but as a rule never result in use of the return at runtime.
i'm going to revise this now that i can run conformance tests after #6840 it is not presently ready for review |
201ce67
to
31b3e47
Compare
Signed-off-by: sagudev <[email protected]>
{"fail_fast": false, "matrix": [{"name": "WebGPU CTS", "workflow": "linux", "wpt_layout": "2020", "profile": "production", "unit_tests": false, "bencher": false, "wpt_args": "_webgpu"}]}
Unfortunately am not sure how relevant information from cts_runner actually is, as there is no concept of (bad) expectations (so only selected tests are run) and it uses old CTS version. The most useful results come from browsers running CTS, either Firefox or Servo as both run all test and have expectations properly set, so you know what results become different using your PR. In servo you can simply override wgpu in Cargo.toml (ensuring that your PR bases from same revision of wgpu previous used in servo) then run |
yes, realizing this since i patched things together. i was hoping to have canonical tests for edge cases and ambiguities, that could execute in a nice automated way, but it seems like the validation tests can't run in cts_runner without more api work. maybe this repo should remove cts_runner and the documentation that suggests using it, if it's no longer relevant. thanks for the instructions for executing in servo's ci! this is very useful |
not ready for review
to be revised now that i can run conformance tests
Connections
initial work on #5186
Description
This PR is based on an old commit, because it is the commit which Firefox nightly uses, but it doesn't seem to conflict with anything on the tip of main.
When the wgsl parser encounters the
@must_use
function attribute, it should not error. This PR will recognize the attribute and emit a boolean flag in the AST.A skipped test is added for a single unacceptable example.
Several tests are added for various acceptable examples. They all pass, because the presence of the flag is a no-op, and no validation is implemented.
Testing
Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.