Skip to content

Commit 1512a95

Browse files
authored
Add anyhow stuff to our internal wasmtime crate prelude (#8804)
* Add `anyhow` stuff to our internal `wasmtime` crate prelude We use it basically everywhere and it is annoying to have to import. I also did an audit of existing `use` statements and removed the now-redundant ones and replaced one-off imports with usage of the prelude, so that the prelude is available by default in more places. * Fix `cargo doc`
1 parent 3bcbd5e commit 1512a95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+40
-113
lines changed

crates/wasmtime/src/compile.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
2525
use crate::prelude::*;
2626
use crate::Engine;
27-
use anyhow::{Context, Result};
2827
use std::{
2928
any::Any,
3029
borrow::Cow,

crates/wasmtime/src/compile/code_builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22
use crate::Engine;
3-
use anyhow::{anyhow, bail, Context, Result};
43
use std::borrow::Cow;
54
use std::path::Path;
65

crates/wasmtime/src/compile/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::compile::HashedEngineCompileEnv;
22
#[cfg(feature = "component-model")]
33
use crate::component::Component;
4+
use crate::prelude::*;
45
use crate::runtime::vm::MmapVec;
56
use crate::{CodeBuilder, CodeMemory, Engine, Module};
6-
use anyhow::{Context, Error, Result};
77
use object::write::WritableBuffer;
88
use std::sync::Arc;
99
use wasmtime_environ::{FinishedObject, ObjectBuilder, ObjectKind};

crates/wasmtime/src/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22
use alloc::sync::Arc;
3-
use anyhow::{bail, ensure, Result};
43
use core::fmt;
54
use core::str::FromStr;
65
use hashbrown::{HashMap, HashSet};

crates/wasmtime/src/engine.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::runtime::vm::GcRuntime;
66
use crate::sync::OnceLock;
77
use crate::Config;
88
use alloc::sync::Arc;
9-
use anyhow::{Context, Result};
109
use core::sync::atomic::{AtomicU64, Ordering};
1110
#[cfg(any(feature = "cranelift", feature = "winch"))]
1211
use object::write::{Object, StandardSegment};

crates/wasmtime/src/engine/serialization.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
2424
use crate::prelude::*;
2525
use crate::{Engine, ModuleVersionStrategy, Precompiled};
26-
use anyhow::{anyhow, bail, ensure, Context, Result};
2726
use core::str::FromStr;
2827
use object::endian::NativeEndian;
2928
#[cfg(any(feature = "cranelift", feature = "winch"))]

crates/wasmtime/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@
281281
extern crate std;
282282
extern crate alloc;
283283

284-
use wasmtime_environ::prelude;
284+
pub(crate) mod prelude {
285+
pub use crate::{Error, Result};
286+
pub use anyhow::{anyhow, bail, ensure, format_err, Context};
287+
pub use wasmtime_environ::prelude::*;
288+
}
285289

286290
/// A helper macro to safely map `MaybeUninit<T>` to `MaybeUninit<U>` where `U`
287291
/// is a field projection within `T`.
@@ -375,6 +379,7 @@ use sync_nostd as sync;
375379
///
376380
/// This type can be used to interact with `wasmtimes`'s extensive use
377381
/// of `anyhow::Error` while still not directly depending on `anyhow`.
382+
///
378383
/// This type alias is identical to `anyhow::Result`.
379384
#[doc(no_inline)]
380385
pub use anyhow::{Error, Result};

crates/wasmtime/src/profiling_agent.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use crate::prelude::*;
2-
#[allow(unused)]
3-
use anyhow::{bail, Result};
42

53
cfg_if::cfg_if! {
64
if #[cfg(all(feature = "profiling", target_os = "linux"))] {

crates/wasmtime/src/profiling_agent/jitdump.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
1414
use crate::prelude::*;
1515
use crate::profiling_agent::ProfilingAgent;
16-
use anyhow::Result;
16+
use object::elf;
1717
use std::process;
1818
use std::sync::Mutex;
1919
use target_lexicon::Architecture;
2020
use wasmtime_jit_debug::perf_jitdump::*;
2121

22-
use object::elf;
23-
2422
/// Interface for driving the creation of jitdump files
2523
struct JitDumpAgent {
2624
pid: u32,

crates/wasmtime/src/profiling_agent/perfmap.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22
use crate::profiling_agent::ProfilingAgent;
3-
use anyhow::Result;
43
use std::io::{self, BufWriter, Write};
54
use std::process;
65
use std::{fs::File, sync::Mutex};

0 commit comments

Comments
 (0)