Skip to content

Commit

Permalink
final review bits
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen committed Feb 22, 2024
1 parent 538ea91 commit 62555ad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions crates/runtime/src/externref/no_gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ impl Drop for VMExternRef {
}

impl VMExternRef {
/// This method is only available when the `gc` cargo feature is *disabled*.
pub fn assert_unreachable<T>(&self) -> T {
match self.0 {}
}

pub fn as_raw(&self) -> *mut u8 {
match self.0 {}
}
Expand Down
6 changes: 2 additions & 4 deletions crates/runtime/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! `Table` is to WebAssembly tables what `LinearMemory` is to WebAssembly linear memories.

#![cfg_attr(feature = "gc", allow(irrefutable_let_patterns))]

use crate::externref::VMExternRef;
use crate::vmcontext::{VMFuncRef, VMTableDefinition};
use crate::{SendSyncPtr, Store};
Expand Down Expand Up @@ -584,10 +586,6 @@ impl Drop for Table {
let ty = self.element_type();

// `funcref` tables don't need drops.
//
// This is an irrefutable pattern when the `gc` cargo feature is not
// enabled.
#[allow(irrefutable_let_patterns)]
if let TableElementType::Func = ty {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions crates/wasmtime/src/runtime/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2027,9 +2027,8 @@ impl<T> Caller<'_, T> {
/// Perform garbage collection of `ExternRef`s.
///
/// Same as [`Store::gc`](crate::Store::gc).
///
/// This method is only available when the `gc` cargo feature is enabled.
#[cfg(feature = "gc")]
#[cfg_attr(docsrs, doc(cfg(feature = "gc")))]
pub fn gc(&mut self) {
self.store.gc()
}
Expand Down
6 changes: 3 additions & 3 deletions crates/wasmtime/src/runtime/ref/no_gc_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ use wasmtime_runtime::VMExternRef;
/// `gc` cargo feature to properly use this type.
#[derive(Clone, Debug)]
pub struct ExternRef {
pub(crate) _inner: Uninhabited,
_inner: Uninhabited,
}

impl ExternRef {
pub(crate) fn from_vm_extern_ref(_inner: VMExternRef) -> Self {
unreachable!()
pub(crate) fn from_vm_extern_ref(inner: VMExternRef) -> Self {
inner.assert_unreachable()
}

pub(crate) fn into_vm_extern_ref(self) -> VMExternRef {
Expand Down

0 comments on commit 62555ad

Please sign in to comment.