#[test] fn parse_type_inference() {
parse_str( " fn foo() { let a = 2u; let b: u32 = a;
var x = 3.;
var y = vec2<f32>(1, 2);
}",
)
.unwrap();
assert!(parse_str( " fn foo() { let c : i32 = 2.0; }",
)
.is_err());
}
let shader = "@compute fn vs() -> vec4<f32> { return vec4<f32>(0.0); }"; let result = Frontend::new().inner(shader);
assert!(matches!(
result.unwrap_err(),
Error::MissingWorkgroupSize(span) if span == Span::new(1, 8)
));
}
mod diagnostic_filter { usecrate::front::wgsl::assert_parse_err;
#[test] fn intended_global_directive() { let shader = "@diagnostic(off, my.lint);";
assert_parse_err(
shader, "\
error: `@diagnostic(…)` attribute(s) on semicolons are not supported
┌─ wgsl:1:1
│ 1 │ @diagnostic(off, my.lint);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^
│
= note: `@diagnostic(…)` attributes are only permitted on `fn`s, some statements, and `switch`/`loop` bodies.
= note: If you meant to declare a diagnostic filter that applies to the entire module, move this line to the top of the file and remove the `@` symbol.
"
);
}
mod parse_sites_not_yet_supported { usecrate::front::wgsl::assert_parse_err;
#[test] fn user_rules() { let shader = " fn myfunc() { if (true) @diagnostic(off, my.lint) { // ^^^^^^^^^^^^^^^^^^^^^^^^^ not yet supported, should report an error
}
} ";
assert_parse_err(shader, "\
error: `@diagnostic(…)` attribute(s) not yet implemented
┌─ wgsl:3:15
│ 3 │ if (true) @diagnostic(off, my.lint) {
│ ^^^^^^^^^^^^^^^^^^^^^^^^^ can't use this on compound statements (yet)
│
= note: Let Naga maintainers know that you ran into this at <https://github.com/gfx-rs/wgpu/issues/5320>, so they can prioritize it!
");
}
#[test] fn unknown_rules() { let shader = " fn myfunc() { if (true) @diagnostic(off, wat_is_this) { // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ should emit a warning
}
} ";
assert_parse_err(shader, "\
error: `@diagnostic(…)` attribute(s) not yet implemented
┌─ wgsl:3:12
│ 3 │ if (true) @diagnostic(off, wat_is_this) {
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't use this on compound statements (yet)
│
= note: Let Naga maintainers know that you ran into this at <https://github.com/gfx-rs/wgpu/issues/5320>, so they can prioritize it!
");
}
}
mod directive_conflict { usecrate::front::wgsl::assert_parse_err;
#[test] fn user_rules() { let shader = "
diagnostic(off, my.lint);
diagnostic(warning, my.lint); ";
assert_parse_err(shader, "\
error: found conflicting `diagnostic(…)` rule(s)
┌─ wgsl:2:1
│ 2 │ diagnostic(off, my.lint);
│ ^^^^^^^^^^^^^^^^^^^^^^^^ first rule 3 │ diagnostic(warning, my.lint);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second rule
│
= note: Multiple `diagnostic(…)` rules with the same rule name conflict unless they are directives and the severity is the same.
= note: You should delete the rule you don't want.
");
}
#[test] fn unknown_rules() { let shader = "
diagnostic(off, wat_is_this);
diagnostic(warning, wat_is_this); ";
assert_parse_err(shader, "\
error: found conflicting `diagnostic(…)` rule(s)
┌─ wgsl:2:1
│ 2 │ diagnostic(off, wat_is_this);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ first rule 3 │ diagnostic(warning, wat_is_this);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second rule
│
= note: Multiple `diagnostic(…)` rules with the same rule name conflict unless they are directives and the severity is the same.
= note: You should delete the rule you don't want.
");
}
}
mod attribute_conflict { usecrate::front::wgsl::assert_parse_err;
#[test] fn user_rules() { let shader = "
diagnostic(off, my.lint);
diagnostic(warning, my.lint); ";
assert_parse_err(shader, "\
error: found conflicting `diagnostic(…)` rule(s)
┌─ wgsl:2:1
│ 2 │ diagnostic(off, my.lint);
│ ^^^^^^^^^^^^^^^^^^^^^^^^ first rule 3 │ diagnostic(warning, my.lint);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second rule
│
= note: Multiple `diagnostic(…)` rules with the same rule name conflict unless they are directives and the severity is the same.
= note: You should delete the rule you don't want.
");
}
#[test] fn unknown_rules() { let shader = "
diagnostic(off, wat_is_this);
diagnostic(warning, wat_is_this); ";
assert_parse_err(shader, "\
error: found conflicting `diagnostic(…)` rule(s)
┌─ wgsl:2:1
│ 2 │ diagnostic(off, wat_is_this);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ first rule 3 │ diagnostic(warning, wat_is_this);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second rule
│
= note: Multiple `diagnostic(…)` rules with the same rule name conflict unless they are directives and the severity is the same.
= note: You should delete the rule you don't want.
");
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet am 2026-06-19)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.