[wgsl] don't clone statements

This commit is contained in:
Dzmitry Malyshau
2021-03-27 00:24:42 -04:00
committed by Dzmitry Malyshau
parent ba055bfbad
commit c55bdf57bf
2 changed files with 6 additions and 10 deletions

View File

@@ -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<crate::Type>),
#[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),
}
}
};

View File

@@ -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)]