A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
`wasmtime-environ`: use `crate::error` instead of `anyhow` (#12203)
Nick Fitzgerald0c59b5ec9268
diff --git a/crates/environ/examples/factc.rs b/crates/environ/examples/factc.rsindex 0d00f0fa4b..2d682e8f74 100644--- a/crates/environ/examples/factc.rs+++ b/crates/environ/examples/factc.rs@@ -1,9 +1,12 @@-use anyhow::{Context, Result, bail};use clap::Parser;use std::io::{IsTerminal, Write};use std::path::{Path, PathBuf};use wasmparser::{Validator, WasmFeatures};-use wasmtime_environ::{ScopeVec, Tunables, component::*};+use wasmtime_environ::{+ ScopeVec, Tunables,+ component::*,+ error::{Context, Result, bail},+};/// A small helper utility to explore generated adapter modules from Wasmtime's/// adapter fusion compiler.diff --git a/crates/environ/src/compile/mod.rs b/crates/environ/src/compile/mod.rsindex 5dbccb311e..26f8d06694 100644--- a/crates/environ/src/compile/mod.rs+++ b/crates/environ/src/compile/mod.rs@@ -1,12 +1,12 @@//! A `Compilation` contains the compiled function bodies for a WebAssembly//! module.+use crate::error::Result;use crate::prelude::*;use crate::{DefinedFuncIndex, FlagValue, FuncKey, FunctionLoc, ObjectKind, PrimaryMap, StaticModuleIndex,TripleExt, Tunables, WasmError, WasmFuncType, obj,};-use anyhow::Result;use object::write::{Object, SymbolId};use object::{Architecture, BinaryFormat, FileFlags};use std::any::Any;diff --git a/crates/environ/src/compile/module_artifacts.rs b/crates/environ/src/compile/module_artifacts.rsindex a4301a1fed..7221e6c410 100644--- a/crates/environ/src/compile/module_artifacts.rs+++ b/crates/environ/src/compile/module_artifacts.rs@@ -1,12 +1,12 @@//! Definitions of runtime structures and metadata which are serialized into ELF//! with `postcard` as part of a module's compilation process.+use crate::error::{Result, bail};use crate::prelude::*;use crate::{CompiledModuleInfo, DebugInfoData, FunctionName, MemoryInitialization, Metadata,ModuleTranslation, Tunables, obj,};-use anyhow::{Result, bail};use object::SectionKind;use object::write::{Object, SectionId, StandardSegment, WritableBuffer};use std::ops::Range;diff --git a/crates/environ/src/compile/module_environ.rs b/crates/environ/src/compile/module_environ.rsindex 00c252ff47..a2c6640f74 100644--- a/crates/environ/src/compile/module_environ.rs+++ b/crates/environ/src/compile/module_environ.rs@@ -1,3 +1,4 @@+use crate::error::{Result, bail};use crate::module::{FuncRefIndex, Initializer, MemoryInitialization, MemoryInitializer, Module, TableSegment,TableSegmentElements,@@ -11,7 +12,6 @@ use crate::{TypeIndex, WasmError, WasmHeapTopType, WasmHeapType, WasmResult, WasmValType,WasmparserTypeConverter,};-use anyhow::{Result, bail};use cranelift_entity::SecondaryMap;use cranelift_entity::packed_option::ReservedValue;use std::borrow::Cow;diff --git a/crates/environ/src/component/compiler.rs b/crates/environ/src/component/compiler.rsindex 1c386108b6..9e98fcac64 100644--- a/crates/environ/src/component/compiler.rs+++ b/crates/environ/src/component/compiler.rs@@ -1,6 +1,6 @@use crate::component::{ComponentTranslation, ComponentTypesBuilder, UnsafeIntrinsic};+use crate::error::Result;use crate::{Abi, CompiledFunctionBody, FuncKey, Tunables};-use anyhow::Result;/// Compilation support necessary for components.pub trait ComponentCompiler: Send + Sync {diff --git a/crates/environ/src/component/dfg.rs b/crates/environ/src/component/dfg.rsindex 7e1e89a64e..e98ff58e88 100644--- a/crates/environ/src/component/dfg.rs+++ b/crates/environ/src/component/dfg.rs@@ -28,9 +28,9 @@//! fused adapters, what arguments make their way to core wasm modules, etc.use crate::component::*;+use crate::error::Result;use crate::prelude::*;use crate::{EntityIndex, EntityRef, ModuleInternedTypeIndex, PrimaryMap, WasmValType};-use anyhow::Result;use cranelift_entity::packed_option::PackedOption;use indexmap::IndexMap;use info::LinearMemoryOptions;diff --git a/crates/environ/src/component/intrinsic.rs b/crates/environ/src/component/intrinsic.rsindex 391c9038f8..81cc538396 100644--- a/crates/environ/src/component/intrinsic.rs+++ b/crates/environ/src/component/intrinsic.rs@@ -2,7 +2,7 @@use core::str::FromStr;-use anyhow::{Result, bail};+use crate::error::{Result, bail};use serde_derive::{Deserialize, Serialize};/// Invoke a macro for each of our unsafe intrinsics.diff --git a/crates/environ/src/component/names.rs b/crates/environ/src/component/names.rsindex 69174d9aa0..6f2fe24ab4 100644--- a/crates/environ/src/component/names.rs+++ b/crates/environ/src/component/names.rs@@ -1,5 +1,5 @@+use crate::error::{Result, bail};use crate::prelude::*;-use anyhow::{Result, bail};use core::hash::Hash;use semver::Version;use serde_derive::{Deserialize, Serialize};diff --git a/crates/environ/src/component/translate.rs b/crates/environ/src/component/translate.rsindex ed0a953ad7..841c90a87e 100644--- a/crates/environ/src/component/translate.rs+++ b/crates/environ/src/component/translate.rs@@ -1,16 +1,16 @@use crate::Abi;use crate::component::dfg::AbstractInstantiations;use crate::component::*;+use crate::error::Context;+use crate::error::anyhow;+use crate::error::ensure;+use crate::error::{Result, bail};use crate::prelude::*;use crate::{EngineOrModuleTypeIndex, EntityIndex, FuncKey, ModuleEnvironment, ModuleInternedTypeIndex,ModuleTranslation, ModuleTypesBuilder, PrimaryMap, ScopeVec, TagIndex, Tunables, TypeConvert,WasmHeapType, WasmResult, WasmValType,};-use anyhow::Context;-use anyhow::anyhow;-use anyhow::ensure;-use anyhow::{Result, bail};use core::str::FromStr;use cranelift_entity::SecondaryMap;use cranelift_entity::packed_option::PackedOption;diff --git a/crates/environ/src/component/types_builder.rs b/crates/environ/src/component/types_builder.rsindex d14fa99f40..3d5897ff4b 100644--- a/crates/environ/src/component/types_builder.rs+++ b/crates/environ/src/component/types_builder.rs@@ -1,10 +1,10 @@use crate::component::*;+use crate::error::{Result, bail};use crate::prelude::*;use crate::{EngineOrModuleTypeIndex, EntityType, ModuleInternedTypeIndex, ModuleTypes, ModuleTypesBuilder,PrimaryMap, TypeConvert, WasmHeapType, WasmValType,};-use anyhow::{Result, bail};use cranelift_entity::EntityRef;use std::collections::HashMap;use std::hash::Hash;diff --git a/crates/environ/src/tunables.rs b/crates/environ/src/tunables.rsindex 694228d872..6f8f8f7298 100644--- a/crates/environ/src/tunables.rs+++ b/crates/environ/src/tunables.rs@@ -1,5 +1,5 @@+use crate::error::{Error, Result, anyhow, bail};use crate::{IndexType, Limits, Memory, TripleExt};-use anyhow::{Error, Result, anyhow, bail};use core::{fmt, str::FromStr};use serde_derive::{Deserialize, Serialize};use target_lexicon::{PointerWidth, Triple};