@@ -24,9 +24,9 @@ use core::{
2424} ;
2525use wasmtime_core:: slab:: { Id as SlabId , Slab } ;
2626use wasmtime_environ:: {
27- EngineOrModuleTypeIndex , EntityRef , GcLayout , ModuleInternedTypeIndex , ModuleTypes , TypeTrace ,
28- Undo , VMSharedTypeIndex , WasmRecGroup , WasmSubType ,
29- collections:: { HashSet , PrimaryMap , SecondaryMap , TryClone as _ , Vec } ,
27+ EngineOrModuleTypeIndex , EntityRef , GcLayout , ModuleInternedTypeIndex , ModuleTypes ,
28+ PanicOnOom as _ , TypeTrace , Undo , VMSharedTypeIndex , WasmRecGroup , WasmSubType ,
29+ collections:: { HashSet , PrimaryMap , SecondaryMap , TryClone , Vec } ,
3030 iter_entity_range,
3131 packed_option:: { PackedOption , ReservedValue } ,
3232} ;
@@ -273,15 +273,21 @@ impl Debug for RegisteredType {
273273
274274impl Clone for RegisteredType {
275275 fn clone ( & self ) -> Self {
276+ self . try_clone ( ) . panic_on_oom ( )
277+ }
278+ }
279+
280+ impl TryClone for RegisteredType {
281+ fn try_clone ( & self ) -> Result < Self , OutOfMemory > {
276282 self . engine . signatures ( ) . debug_assert_contains ( self . index ) ;
277- self . entry . incref ( "RegisteredType::clone " ) ;
278- RegisteredType {
283+ self . entry . incref ( "RegisteredType::try_clone " ) ;
284+ Ok ( RegisteredType {
279285 engine : self . engine . clone ( ) ,
280286 entry : self . entry . clone ( ) ,
281287 ty : self . ty . clone ( ) ,
282288 index : self . index ,
283289 layout : self . layout . clone ( ) ,
284- }
290+ } )
285291 }
286292}
287293
@@ -457,6 +463,12 @@ impl RegisteredType {
457463#[ derive( Clone ) ]
458464struct RecGroupEntry ( Arc < RecGroupEntryInner > ) ;
459465
466+ impl TryClone for RecGroupEntry {
467+ fn try_clone ( & self ) -> Result < Self , OutOfMemory > {
468+ Ok ( self . clone ( ) )
469+ }
470+ }
471+
460472impl Debug for RecGroupEntry {
461473 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
462474 struct FormatAsPtr < ' a , P > ( & ' a P ) ;
0 commit comments