Skip to content

Commit

Permalink
deps: Remove usage of unmaintained derivative crate
Browse files Browse the repository at this point in the history
The crate is unmaintained and shows up in cargo-deny lints.

Do a manual std::fmt::Debug impl where appropriate

use derive_more instead
  • Loading branch information
theduke committed Nov 16, 2024
1 parent 821875c commit d55cb77
Show file tree
Hide file tree
Showing 54 changed files with 137 additions and 208 deletions.
48 changes: 27 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ base64 = "0.22.0"
time = "0.3.36"
target-lexicon = { version = "0.12.2", default-features = false }
object = "0.32.0"
derive_more = { version = "1", features = ["debug"] }

[build-dependencies]
test-generator = { path = "tests/lib/test-generator" }
Expand Down
1 change: 0 additions & 1 deletion lib/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ indexmap = { version = "1.6" }
cfg-if = "1.0"
thiserror = "1.0"
more-asserts = "0.2"
derivative = { version = "^2" }
bytes = "1"
tracing = { version = "0.1" }
# - Optional shared dependencies.
Expand Down
1 change: 1 addition & 0 deletions lib/api/src/c_api/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
pub(crate) use objects::{InternalStoreHandle, StoreObject};
pub use objects::{StoreHandle, StoreObjects};

#[derive(Debug)]
pub(crate) struct Store {
pub(crate) engine: Engine,
pub(crate) inner: *mut wasm_store_t,
Expand Down
1 change: 1 addition & 0 deletions lib/api/src/js/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::engine::{AsEngineRef, Engine, EngineRef};
pub(crate) use objects::{InternalStoreHandle, StoreObject};
pub use objects::{StoreHandle, StoreObjects};

#[derive(Debug)]
pub(crate) struct Store {
pub(crate) engine: Engine,
}
Expand Down
1 change: 1 addition & 0 deletions lib/api/src/jsc/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::engine::{AsEngineRef, Engine, EngineRef};
pub(crate) use objects::{InternalStoreHandle, StoreObject};
pub use objects::{StoreHandle, StoreObjects};

#[derive(Debug)]
pub(crate) struct Store {
pub(crate) engine: Engine,
}
Expand Down
15 changes: 10 additions & 5 deletions lib/api/src/store.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::engine::{AsEngineRef, Engine, EngineRef};
#[cfg(feature = "sys")]
use crate::sys::NativeStoreExt;
use derivative::Derivative;
use std::{
fmt,
ops::{Deref, DerefMut},
Expand Down Expand Up @@ -45,16 +44,22 @@ pub type OnCalledHandler = Box<
/// We require the context to have a fixed memory address for its lifetime since
/// various bits of the VM have raw pointers that point back to it. Hence we
/// wrap the actual context in a box.
#[derive(Derivative)]
#[derivative(Debug)]
pub(crate) struct StoreInner {
pub(crate) objects: StoreObjects,
#[derivative(Debug = "ignore")]
pub(crate) store: store_imp::Store,
#[derivative(Debug = "ignore")]
pub(crate) on_called: Option<OnCalledHandler>,
}

impl std::fmt::Debug for StoreInner {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("StoreInner")
.field("objects", &self.objects)
.field("store", &self.store)
.field("on_called", &"<...>")
.finish()
}
}

/// The store represents all global state that can be manipulated by
/// WebAssembly programs. It consists of the runtime representation
/// of all instances of functions, tables, memories, and globals that
Expand Down
9 changes: 8 additions & 1 deletion lib/api/src/sys/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ use wasmer_vm::TrapHandlerFn;

pub(crate) struct Store {
pub(crate) engine: Engine,

pub(crate) trap_handler: Option<Box<TrapHandlerFn<'static>>>,
}

impl std::fmt::Debug for Store {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("Store")
.field("engine", &self.engine)
.finish()
}
}

impl Store {
pub(crate) fn new(engine: Engine) -> Self {
init_traps();
Expand Down
2 changes: 1 addition & 1 deletion lib/api/src/typed_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::store::AsStoreRef;

/// A WebAssembly function that can be called natively
/// (using the Native ABI).
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct TypedFunction<Args, Rets> {
pub(crate) func: Function,
_phantom: PhantomData<fn(Args) -> Rets>,
Expand Down
3 changes: 2 additions & 1 deletion lib/journal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ virtual-net = { path = "../virtual-net", version = "0.11.0", default-features =
"rkyv",
] }
virtual-fs = { path = "../virtual-fs", version = "0.19.0", default-features = false }

shared-buffer = { workspace = true, optional = true }
base64.workspace = true
derive_more.workspace = true
rkyv = { workspace = true }

thiserror = "1"
bytes = "1.1"
async-trait = { version = "^0.1" }
tracing = "0.1"
derivative = { version = "^2" }
bincode = { version = "1.3" }
serde = { version = "1.0", default-features = false, features = ["derive"] }
anyhow = "1.0"
Expand Down
22 changes: 10 additions & 12 deletions lib/journal/src/entry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use derivative::Derivative;
use serde::{Deserialize, Serialize};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::net::{Shutdown, SocketAddr};
Expand Down Expand Up @@ -79,8 +78,7 @@ pub enum SocketOptTimeType {
/// Represents a log entry in a snapshot log stream that represents the total
/// state of a WASM process at a point in time.
#[allow(clippy::large_enum_variant)]
#[derive(Derivative, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derivative(Debug)]
#[derive(derive_more::Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum JournalEntry<'a> {
InitModuleV1 {
Expand All @@ -89,7 +87,7 @@ pub enum JournalEntry<'a> {
ClearEtherealV1,
UpdateMemoryRegionV1 {
region: Range<u64>,
#[derivative(Debug = "ignore")]
#[debug(ignore)]
#[serde(with = "base64")]
compressed_data: Cow<'a, [u8]>,
},
Expand All @@ -98,13 +96,13 @@ pub enum JournalEntry<'a> {
},
SetThreadV1 {
id: u32,
#[derivative(Debug = "ignore")]
#[debug(ignore)]
#[serde(with = "base64")]
call_stack: Cow<'a, [u8]>,
#[derivative(Debug = "ignore")]
#[debug(ignore)]
#[serde(with = "base64")]
memory_stack: Cow<'a, [u8]>,
#[derivative(Debug = "ignore")]
#[debug(ignore)]
#[serde(with = "base64")]
store_data: Cow<'a, [u8]>,
start: ThreadStartType,
Expand All @@ -123,7 +121,7 @@ pub enum JournalEntry<'a> {
FileDescriptorWriteV1 {
fd: Fd,
offset: u64,
#[derivative(Debug = "ignore")]
#[debug(ignore)]
#[serde(with = "base64")]
data: Cow<'a, [u8]>,
is_64bit: bool,
Expand All @@ -141,9 +139,9 @@ pub enum JournalEntry<'a> {
dirflags: LookupFlags,
path: Cow<'a, str>,
o_flags: Oflags,
#[derivative(Debug = "ignore")]
#[debug(ignore)]
fs_rights_base: Rights,
#[derivative(Debug = "ignore")]
#[debug(ignore)]
fs_rights_inheriting: Rights,
fs_flags: Fdflags,
},
Expand Down Expand Up @@ -330,7 +328,7 @@ pub enum JournalEntry<'a> {
},
SocketSendToV1 {
fd: Fd,
#[derivative(Debug = "ignore")]
#[debug(ignore)]
#[serde(with = "base64")]
data: Cow<'a, [u8]>,
flags: SiFlags,
Expand All @@ -339,7 +337,7 @@ pub enum JournalEntry<'a> {
},
SocketSendV1 {
fd: Fd,
#[derivative(Debug = "ignore")]
#[debug(ignore)]
#[serde(with = "base64")]
data: Cow<'a, [u8]>,
flags: SiFlags,
Expand Down
2 changes: 1 addition & 1 deletion lib/virtual-fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ rust-version.workspace = true
[dependencies]
wasmer-package.workspace = true
dashmap.workspace = true
derive_more.workspace = true
dunce = "1.0.4"
anyhow = { version = "1.0.66", optional = true }
async-trait = { version = "^0.1" }
bytes = "1"
derivative = "2.2.0"
filetime = { version = "0.2.18", optional = true }
fs_extra = { version = "1.2.0", optional = true }
futures = { version = "0.3" }
Expand Down
5 changes: 1 addition & 4 deletions lib/virtual-fs/src/arc_box_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ use std::{
task::{Context, Poll},
};

use derivative::Derivative;
use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite};

use crate::VirtualFile;

#[derive(Derivative, Clone)]
#[derivative(Debug)]
#[derive(Debug, Clone)]
pub struct ArcBoxFile {
#[derivative(Debug = "ignore")]
inner: Arc<Mutex<Box<dyn VirtualFile + Send + Sync + 'static>>>,
}

Expand Down
5 changes: 1 addition & 4 deletions lib/virtual-fs/src/arc_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//! effectively this is a symbolic link without all the complex path redirection
use crate::{ClonableVirtualFile, VirtualFile};
use derivative::Derivative;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{
Expand All @@ -11,13 +10,11 @@ use std::{
};
use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite};

#[derive(Derivative)]
#[derivative(Debug)]
#[derive(Debug)]
pub struct ArcFile<T>
where
T: VirtualFile + Send + Sync + 'static,
{
#[derivative(Debug = "ignore")]
inner: Arc<Mutex<Box<T>>>,
}

Expand Down
5 changes: 1 addition & 4 deletions lib/virtual-fs/src/combine_file.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use derivative::Derivative;

use super::*;

use crate::VirtualFile;

#[derive(Derivative)]
#[derivative(Debug)]
#[derive(Debug)]
pub struct CombineFile {
tx: Box<dyn VirtualFile + Send + Sync + 'static>,
rx: Box<dyn VirtualFile + Send + Sync + 'static>,
Expand Down
Loading

0 comments on commit d55cb77

Please sign in to comment.