A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Implement `TryClone` for `RegisteredType` and `RecGroupEntry` in the types registry (#12619)
Nick Fitzgeraldfd7418ed5ce8
diff --git a/crates/wasmtime/src/runtime/type_registry.rs b/crates/wasmtime/src/runtime/type_registry.rsindex cac203b5d4..abf9dc59e4 100644--- a/crates/wasmtime/src/runtime/type_registry.rs+++ b/crates/wasmtime/src/runtime/type_registry.rs@@ -24,9 +24,9 @@ use core::{};use wasmtime_core::slab::{Id as SlabId, Slab};use wasmtime_environ::{- EngineOrModuleTypeIndex, EntityRef, GcLayout, ModuleInternedTypeIndex, ModuleTypes, TypeTrace,- Undo, VMSharedTypeIndex, WasmRecGroup, WasmSubType,- collections::{HashSet, PrimaryMap, SecondaryMap, TryClone as _, Vec},+ EngineOrModuleTypeIndex, EntityRef, GcLayout, ModuleInternedTypeIndex, ModuleTypes,+ PanicOnOom as _, TypeTrace, Undo, VMSharedTypeIndex, WasmRecGroup, WasmSubType,+ collections::{HashSet, PrimaryMap, SecondaryMap, TryClone, Vec},iter_entity_range,packed_option::{PackedOption, ReservedValue},};@@ -273,15 +273,21 @@ impl Debug for RegisteredType {impl Clone for RegisteredType {fn clone(&self) -> Self {+ self.try_clone().panic_on_oom()+ }+}++impl TryClone for RegisteredType {+ fn try_clone(&self) -> Result<Self, OutOfMemory> {self.engine.signatures().debug_assert_contains(self.index);- self.entry.incref("RegisteredType::clone");- RegisteredType {+ self.entry.incref("RegisteredType::try_clone");+ Ok(RegisteredType {engine: self.engine.clone(),entry: self.entry.clone(),ty: self.ty.clone(),index: self.index,layout: self.layout.clone(),- }+ })}}@@ -457,6 +463,12 @@ impl RegisteredType {#[derive(Clone)]struct RecGroupEntry(Arc<RecGroupEntryInner>);+impl TryClone for RecGroupEntry {+ fn try_clone(&self) -> Result<Self, OutOfMemory> {+ Ok(self.clone())+ }+}+impl Debug for RecGroupEntry {fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {struct FormatAsPtr<'a, P>(&'a P);