layouter: rich and careful errors

This commit is contained in:
Dzmitry Malyshau
2022-01-13 16:27:28 -05:00
parent a069361bf4
commit ab02ec7904
10 changed files with 90 additions and 48 deletions

View File

@@ -824,6 +824,7 @@ impl super::Validator {
module: &crate::Module,
mod_info: &ModuleInfo,
) -> Result<FunctionInfo, WithSpan<FunctionError>> {
#[cfg_attr(not(feature = "validate"), allow(unused_mut))]
let mut info = mod_info.process_function(fun, module, self.flags)?;
#[cfg(feature = "validate")]
@@ -842,13 +843,13 @@ impl super::Validator {
#[cfg(feature = "validate")]
for (index, argument) in fun.arguments.iter().enumerate() {
let ty = module.types.get_handle(argument.ty).ok_or(
let ty = module.types.get_handle(argument.ty).ok_or_else(|| {
FunctionError::InvalidArgumentType {
index,
name: argument.name.clone().unwrap_or_default(),
}
.with_span_handle(argument.ty, &module.types),
)?;
.with_span_handle(argument.ty, &module.types)
})?;
match ty.inner.pointer_class() {
Some(crate::StorageClass::Private)
| Some(crate::StorageClass::Function)