Update wat crate.

Update the `wat` crate to latest version and use `Error::set_path` in
`Module::from_file` to properly record the path associated with errors.
This commit is contained in:
Peter Huene
2021-04-01 12:04:47 -07:00
parent 3da03bcfcf
commit 4ad0099da4
7 changed files with 23 additions and 10 deletions

View File

@@ -228,10 +228,23 @@ impl Module {
/// # }
/// ```
pub fn from_file(engine: &Engine, file: impl AsRef<Path>) -> Result<Module> {
Self::new(
match Self::new(
engine,
&fs::read(file).with_context(|| "failed to read input file")?,
)
&fs::read(&file).with_context(|| "failed to read input file")?,
) {
Ok(m) => Ok(m),
Err(e) => {
cfg_if::cfg_if! {
if #[cfg(feature = "wat")] {
let mut e = e.downcast::<wat::Error>()?;
e.set_path(file);
bail!(e)
} else {
Err(e)
}
}
}
}
}
/// Creates a new WebAssembly `Module` from the given in-memory `binary`