Skip to content

Commit 0c59b5e

Browse files
authored
wasmtime-environ: use crate::error instead of anyhow (#12203)
* Temporarily re-export `anyhow` as `wasmtime_environ::error` This is intended to ease the migration to the `wasmtime-internal-error` crate. Follow up PRs will start moving crates in our workspace over to using this re-export and not depending on `anyhow` directly themselves. Finally, we will swap out this re-export for a re-export of the `wasmtime-internal-error` crate. * rename existing `error` module to `wasm_error` * wasmtime-environ: use `crate::error` instead of `anyhow` Part of migrating to the `wasmtime-internal-error` crate. Depends on #12202
1 parent f8d2795 commit 0c59b5e

File tree

11 files changed

+18
-15
lines changed

11 files changed

+18
-15
lines changed

crates/environ/examples/factc.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
use anyhow::{Context, Result, bail};
21
use clap::Parser;
32
use std::io::{IsTerminal, Write};
43
use std::path::{Path, PathBuf};
54
use wasmparser::{Validator, WasmFeatures};
6-
use wasmtime_environ::{ScopeVec, Tunables, component::*};
5+
use wasmtime_environ::{
6+
ScopeVec, Tunables,
7+
component::*,
8+
error::{Context, Result, bail},
9+
};
710

811
/// A small helper utility to explore generated adapter modules from Wasmtime's
912
/// adapter fusion compiler.

crates/environ/src/compile/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! A `Compilation` contains the compiled function bodies for a WebAssembly
22
//! module.
33
4+
use crate::error::Result;
45
use crate::prelude::*;
56
use crate::{
67
DefinedFuncIndex, FlagValue, FuncKey, FunctionLoc, ObjectKind, PrimaryMap, StaticModuleIndex,
78
TripleExt, Tunables, WasmError, WasmFuncType, obj,
89
};
9-
use anyhow::Result;
1010
use object::write::{Object, SymbolId};
1111
use object::{Architecture, BinaryFormat, FileFlags};
1212
use std::any::Any;

crates/environ/src/compile/module_artifacts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! Definitions of runtime structures and metadata which are serialized into ELF
22
//! with `postcard` as part of a module's compilation process.
33
4+
use crate::error::{Result, bail};
45
use crate::prelude::*;
56
use crate::{
67
CompiledModuleInfo, DebugInfoData, FunctionName, MemoryInitialization, Metadata,
78
ModuleTranslation, Tunables, obj,
89
};
9-
use anyhow::{Result, bail};
1010
use object::SectionKind;
1111
use object::write::{Object, SectionId, StandardSegment, WritableBuffer};
1212
use std::ops::Range;

crates/environ/src/compile/module_environ.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::error::{Result, bail};
12
use crate::module::{
23
FuncRefIndex, Initializer, MemoryInitialization, MemoryInitializer, Module, TableSegment,
34
TableSegmentElements,
@@ -11,7 +12,6 @@ use crate::{
1112
TypeIndex, WasmError, WasmHeapTopType, WasmHeapType, WasmResult, WasmValType,
1213
WasmparserTypeConverter,
1314
};
14-
use anyhow::{Result, bail};
1515
use cranelift_entity::SecondaryMap;
1616
use cranelift_entity::packed_option::ReservedValue;
1717
use std::borrow::Cow;

crates/environ/src/component/compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::component::{ComponentTranslation, ComponentTypesBuilder, UnsafeIntrinsic};
2+
use crate::error::Result;
23
use crate::{Abi, CompiledFunctionBody, FuncKey, Tunables};
3-
use anyhow::Result;
44

55
/// Compilation support necessary for components.
66
pub trait ComponentCompiler: Send + Sync {

crates/environ/src/component/dfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
//! fused adapters, what arguments make their way to core wasm modules, etc.
2929
3030
use crate::component::*;
31+
use crate::error::Result;
3132
use crate::prelude::*;
3233
use crate::{EntityIndex, EntityRef, ModuleInternedTypeIndex, PrimaryMap, WasmValType};
33-
use anyhow::Result;
3434
use cranelift_entity::packed_option::PackedOption;
3535
use indexmap::IndexMap;
3636
use info::LinearMemoryOptions;

crates/environ/src/component/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use core::str::FromStr;
44

5-
use anyhow::{Result, bail};
5+
use crate::error::{Result, bail};
66
use serde_derive::{Deserialize, Serialize};
77

88
/// Invoke a macro for each of our unsafe intrinsics.

crates/environ/src/component/names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::error::{Result, bail};
12
use crate::prelude::*;
2-
use anyhow::{Result, bail};
33
use core::hash::Hash;
44
use semver::Version;
55
use serde_derive::{Deserialize, Serialize};

crates/environ/src/component/translate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use crate::Abi;
22
use crate::component::dfg::AbstractInstantiations;
33
use crate::component::*;
4+
use crate::error::Context;
5+
use crate::error::anyhow;
6+
use crate::error::ensure;
7+
use crate::error::{Result, bail};
48
use crate::prelude::*;
59
use crate::{
610
EngineOrModuleTypeIndex, EntityIndex, FuncKey, ModuleEnvironment, ModuleInternedTypeIndex,
711
ModuleTranslation, ModuleTypesBuilder, PrimaryMap, ScopeVec, TagIndex, Tunables, TypeConvert,
812
WasmHeapType, WasmResult, WasmValType,
913
};
10-
use anyhow::Context;
11-
use anyhow::anyhow;
12-
use anyhow::ensure;
13-
use anyhow::{Result, bail};
1414
use core::str::FromStr;
1515
use cranelift_entity::SecondaryMap;
1616
use cranelift_entity::packed_option::PackedOption;

crates/environ/src/component/types_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::component::*;
2+
use crate::error::{Result, bail};
23
use crate::prelude::*;
34
use crate::{
45
EngineOrModuleTypeIndex, EntityType, ModuleInternedTypeIndex, ModuleTypes, ModuleTypesBuilder,
56
PrimaryMap, TypeConvert, WasmHeapType, WasmValType,
67
};
7-
use anyhow::{Result, bail};
88
use cranelift_entity::EntityRef;
99
use std::collections::HashMap;
1010
use std::hash::Hash;

0 commit comments

Comments
 (0)