diff --git a/src/front/wgsl/mod.rs b/src/front/wgsl/mod.rs index 8bae91cff4..09bc350cfe 100644 --- a/src/front/wgsl/mod.rs +++ b/src/front/wgsl/mod.rs @@ -75,8 +75,8 @@ pub enum Error<'a> { BadTypeCast(&'a str), #[error(transparent)] InvalidResolve(ResolveError), - #[error("invalid statement {0:?}, expected {1}")] - InvalidStatement(crate::Statement, &'a str), + #[error("for(;;) initializer is not an assignment or a function call")] + InvalidForInitializer, #[error("resource type {0:?} is invalid")] InvalidResourceType(Handle), #[error("unknown import: `{0}`")] @@ -2232,14 +2232,9 @@ impl Parser { is_uniform_control_flow, )?; if block.len() != num_statements { - match block.last().unwrap() { - &crate::Statement::Store { .. } | &crate::Statement::Call { .. } => {} - other => { - return Err(Error::InvalidStatement( - other.clone(), - "variable, assignment or function call", - )) - } + match *block.last().unwrap() { + crate::Statement::Store { .. } | crate::Statement::Call { .. } => {} + _ => return Err(Error::InvalidForInitializer), } } }; diff --git a/src/lib.rs b/src/lib.rs index d48db7ef96..10cbdc1c8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -779,6 +779,7 @@ pub struct SwitchCase { pub fall_through: bool, } +//TODO: consider removing `Clone`. It's not valid to clone `Statement::Emit` anyway. /// Instructions which make up an executable block. // Clone is used only for error reporting and is not intended for end users #[derive(Clone, Debug)]