Commit Graph

5 Commits

Author SHA1 Message Date
Yury Delendik
6632a7da37 [wasmtime-api] reduce examples complexity: hostref for store/engine (#489)
* reduce amount of store.clone()

* use HostRef Engine as ref / use Engine::default()
2019-11-07 11:39:23 -06:00
Josh Triplett
56ce6e9c9f Migrate from failure to thiserror and anyhow (#436)
* Migrate from failure to thiserror and anyhow

The failure crate invents its own traits that don't use
std::error::Error (because failure predates certain features added to
Error); this prevents using ? on an error from failure in a function
using Error. The thiserror and anyhow crates integrate with the standard
Error trait instead.

This change does not attempt to semantically change or refactor the
approach to error-handling in any portion of the code, to ensure that
the change remains straightforward to review. Modules using specific
differentiated error types move from failure_derive and derive(Fail) to
thiserror and derive(Error). Modules boxing all errors opaquely move
from failure::Error to anyhow. Modules using String as an error type
continue to do so. Code using unwrap or expect continues to do so.

Drop Display implementations when thiserror can easily derive an
identical instance.

Drop manual traversal of iter_causes; anyhow's Debug instance prints the
chain of causes by default.

Use anyhow's type alias anyhow::Result<T> in place of
std::result::Result<T, anyhow::Error> whenever possible.

* wasm2obj: Simplify error handling using existing messages

handle_module in wasm2obj manually maps
cranelift_codegen::isa::LookupError values to strings, but LookupError
values already have strings that say almost exactly the same thing.
Rely on the strings from cranelift.

* wasmtime: Rely on question-mark-in-main

The main() wrapper around rmain() completely matches the behavior of
question-mark-in-main (print error to stderr and return 1), so switch to
question-mark-in-main.

* Update to walrus 0.13 and wasm-webidl-bindings 0.6

Both crates switched from failure to anyhow; updating lets us avoid a
translation from failure to anyhow within wasmtime-interface-types.
2019-11-04 20:43:25 -08:00
Dan Gohman
8e1b44b29c Make more code work with no_std. (#407)
* Make more code work with no_std.

no_std support is still incomplete, but this patch takes care of the
bulk of the straightforward parts.
2019-10-08 16:53:32 -07:00
Yury Delendik
9c747db429 Make data() unsafe 2019-09-18 09:15:14 -07:00
Yury Delendik
6a41417b52 Add examples; refactor HostRef 2019-09-18 09:15:14 -07:00