Skip to content

Commit 2fcd413

Browse files
authored
[naga] Make Naga tests build when no features are enabled. (#7989)
1 parent b8c462a commit 2fcd413

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

naga/tests/naga/validation.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn populate_atomic_result() {
3434
// the differences between the test cases.
3535
fn try_variant(
3636
variant: Variant,
37-
) -> Result<naga::valid::ModuleInfo, naga::WithSpan<naga::valid::ValidationError>> {
37+
) -> Result<ModuleInfo, naga::WithSpan<naga::valid::ValidationError>> {
3838
let span = naga::Span::default();
3939
let mut module = Module::default();
4040
let ty_u32 = module.types.insert(
@@ -135,7 +135,7 @@ fn populate_call_result() {
135135
// the differences between the test cases.
136136
fn try_variant(
137137
variant: Variant,
138-
) -> Result<naga::valid::ModuleInfo, naga::WithSpan<naga::valid::ValidationError>> {
138+
) -> Result<ModuleInfo, naga::WithSpan<naga::valid::ValidationError>> {
139139
let span = naga::Span::default();
140140
let mut module = Module::default();
141141
let ty_u32 = module.types.insert(
@@ -211,9 +211,7 @@ fn emit_workgroup_uniform_load_result() {
211211
//
212212
// Looking at uses of the `wg_load` makes it easy to identify the
213213
// differences between the two variants.
214-
fn variant(
215-
wg_load: bool,
216-
) -> Result<naga::valid::ModuleInfo, naga::WithSpan<naga::valid::ValidationError>> {
214+
fn variant(wg_load: bool) -> Result<ModuleInfo, naga::WithSpan<naga::valid::ValidationError>> {
217215
let span = naga::Span::default();
218216
let mut module = Module::default();
219217
let ty_u32 = module.types.insert(
@@ -284,7 +282,7 @@ fn builtin_cross_product_args() {
284282
fn variant(
285283
size: VectorSize,
286284
arity: usize,
287-
) -> Result<naga::valid::ModuleInfo, naga::WithSpan<naga::valid::ValidationError>> {
285+
) -> Result<ModuleInfo, naga::WithSpan<naga::valid::ValidationError>> {
288286
let span = naga::Span::default();
289287
let mut module = Module::default();
290288
let ty_vec3f = module.types.insert(
@@ -546,7 +544,7 @@ fn main(input: VertexOutput) {{
546544

547545
#[allow(dead_code)]
548546
struct BindingArrayFixture {
549-
module: naga::Module,
547+
module: Module,
550548
span: naga::Span,
551549
ty_u32: naga::Handle<naga::Type>,
552550
ty_array: naga::Handle<naga::Type>,
@@ -556,7 +554,7 @@ struct BindingArrayFixture {
556554

557555
impl BindingArrayFixture {
558556
fn new() -> Self {
559-
let mut module = naga::Module::default();
557+
let mut module = Module::default();
560558
let span = naga::Span::default();
561559
let ty_u32 = module.types.insert(
562560
naga::Type {
@@ -694,7 +692,7 @@ error: Function [1] 'main' is invalid
694692
#[cfg(feature = "wgsl-in")]
695693
#[test]
696694
fn bad_texture_dimensions_level() {
697-
fn validate(level: &str) -> Result<naga::valid::ModuleInfo, naga::valid::ValidationError> {
695+
fn validate(level: &str) -> Result<ModuleInfo, naga::valid::ValidationError> {
698696
let source = format!(
699697
r#"
700698
@group(0) @binding(0)
@@ -710,9 +708,7 @@ fn bad_texture_dimensions_level() {
710708
.map_err(|err| err.into_inner()) // discard spans
711709
}
712710

713-
fn is_bad_level_error(
714-
result: Result<naga::valid::ModuleInfo, naga::valid::ValidationError>,
715-
) -> bool {
711+
fn is_bad_level_error(result: Result<ModuleInfo, naga::valid::ValidationError>) -> bool {
716712
matches!(
717713
result,
718714
Err(naga::valid::ValidationError::Function {
@@ -739,7 +735,7 @@ fn arity_check() {
739735
use naga::Span;
740736
let _ = env_logger::builder().is_test(true).try_init();
741737

742-
type Result = core::result::Result<naga::valid::ModuleInfo, naga::valid::ValidationError>;
738+
type Result = core::result::Result<ModuleInfo, naga::valid::ValidationError>;
743739

744740
fn validate(fun: ir::MathFunction, args: &[usize]) -> Result {
745741
let nowhere = Span::default();
@@ -924,6 +920,7 @@ fn main() {
924920
/// Parse and validate the module defined in `source`.
925921
///
926922
/// Panics if unsuccessful.
923+
#[cfg(feature = "wgsl-in")]
927924
fn parse_validate(source: &str) -> (Module, ModuleInfo) {
928925
let module = naga::front::wgsl::parse_str(source).expect("module should parse");
929926
let info = valid::Validator::new(Default::default(), valid::Capabilities::all())
@@ -947,6 +944,7 @@ fn parse_validate(source: &str) -> (Module, ModuleInfo) {
947944
///
948945
/// The optional `unused_body` can introduce additional objects to the module,
949946
/// to verify that they are adjusted correctly by compaction.
947+
#[cfg(feature = "wgsl-in")]
950948
fn override_test(test_case: &str, unused_body: Option<&str>) {
951949
use hashbrown::HashMap;
952950
use naga::back::pipeline_constants::PipelineConstantError;

0 commit comments

Comments
 (0)