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

4
Cargo.lock generated
View File

@@ -3598,9 +3598,9 @@ dependencies = [
[[package]] [[package]]
name = "wat" name = "wat"
version = "1.0.36" version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b0fa059022c5dabe129f02b429d67086400deb8277f89c975555dacc1dadbcc" checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02"
dependencies = [ dependencies = [
"wast 35.0.1", "wast 35.0.1",
] ]

View File

@@ -38,7 +38,7 @@ anyhow = "1.0.19"
target-lexicon = { version = "0.12.0", default-features = false } target-lexicon = { version = "0.12.0", default-features = false }
pretty_env_logger = "0.4.0" pretty_env_logger = "0.4.0"
file-per-thread-logger = "0.1.1" file-per-thread-logger = "0.1.1"
wat = "1.0.36" wat = "1.0.37"
libc = "0.2.60" libc = "0.2.60"
log = "0.4.8" log = "0.4.8"
rayon = "1.2.1" rayon = "1.2.1"

View File

@@ -24,7 +24,7 @@ smallvec = "1.6.1"
thiserror = "1.0.4" thiserror = "1.0.4"
[dev-dependencies] [dev-dependencies]
wat = "1.0.36" wat = "1.0.37"
target-lexicon = "0.12" target-lexicon = "0.12"
# Enable the riscv feature for cranelift-codegen, as some tests require it # Enable the riscv feature for cranelift-codegen, as some tests require it
cranelift-codegen = { path = "../codegen", version = "0.72.0", default-features = false, features = ["riscv"] } cranelift-codegen = { path = "../codegen", version = "0.72.0", default-features = false, features = ["riscv"] }

View File

@@ -22,7 +22,7 @@ wasm-smith = "0.4.4"
wasmi = "0.7.0" wasmi = "0.7.0"
[dev-dependencies] [dev-dependencies]
wat = "1.0.36" wat = "1.0.37"
[features] [features]
experimental_x64 = ["wasmtime/experimental_x64"] experimental_x64 = ["wasmtime/experimental_x64"]

View File

@@ -28,7 +28,7 @@ wasmparser = "0.77"
[dev-dependencies] [dev-dependencies]
lazy_static = "1.2" lazy_static = "1.2"
wat = "1.0.36" wat = "1.0.37"
quickcheck = "1.0.0" quickcheck = "1.0.0"
anyhow = "1.0" anyhow = "1.0"

View File

@@ -20,7 +20,7 @@ pretty_env_logger = "0.4.0"
tempfile = "3.1.0" tempfile = "3.1.0"
os_pipe = "0.9" os_pipe = "0.9"
anyhow = "1.0.19" anyhow = "1.0.19"
wat = "1.0.36" wat = "1.0.37"
cap-std = "0.13" cap-std = "0.13"
[features] [features]

View File

@@ -228,10 +228,23 @@ impl Module {
/// # } /// # }
/// ``` /// ```
pub fn from_file(engine: &Engine, file: impl AsRef<Path>) -> Result<Module> { pub fn from_file(engine: &Engine, file: impl AsRef<Path>) -> Result<Module> {
Self::new( match Self::new(
engine, 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` /// Creates a new WebAssembly `Module` from the given in-memory `binary`