Skip to content

Commit

Permalink
Implement std::fmt::Pointer for ExternRef (bytecodealliance#4504)
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen authored Jul 21, 2022
1 parent b24c561 commit 35b750a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/runtime/src/externref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ use wasmtime_environ::StackMap;
#[repr(transparent)]
pub struct VMExternRef(NonNull<VMExternData>);

impl std::fmt::Pointer for VMExternRef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Pointer::fmt(&self.0, f)
}
}

// Data contained is always Send+Sync so these should be safe.
unsafe impl Send for VMExternRef {}
unsafe impl Sync for VMExternRef {}
Expand Down
6 changes: 6 additions & 0 deletions crates/wasmtime/src/ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,9 @@ impl ExternRef {
externref_ptr as usize
}
}

impl std::fmt::Pointer for ExternRef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Pointer::fmt(&self.inner, f)
}
}

0 comments on commit 35b750a

Please sign in to comment.