@@ -846,7 +846,7 @@ impl WasmFuncType {
846846}
847847
848848/// WebAssembly continuation type -- equivalent of `wasmparser`'s ContType.
849- #[ derive( Debug , Clone , Eq , PartialEq , Hash , Serialize , Deserialize ) ]
849+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Hash , Serialize , Deserialize ) ]
850850pub struct WasmContType ( EngineOrModuleTypeIndex ) ;
851851
852852impl fmt:: Display for WasmContType {
@@ -926,6 +926,15 @@ pub struct WasmExnType {
926926 pub fields : Box < [ WasmFieldType ] > ,
927927}
928928
929+ impl TryClone for WasmExnType {
930+ fn try_clone ( & self ) -> Result < Self , OutOfMemory > {
931+ Ok ( Self {
932+ func_ty : self . func_ty ,
933+ fields : self . fields . try_clone ( ) ?,
934+ } )
935+ }
936+ }
937+
929938impl fmt:: Display for WasmExnType {
930939 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
931940 write ! ( f, "(exn ({})" , self . func_ty) ?;
@@ -1018,7 +1027,7 @@ impl WasmStorageType {
10181027}
10191028
10201029/// The type of a struct field or array element.
1021- #[ derive( Debug , Clone , Eq , PartialEq , Hash , Serialize , Deserialize ) ]
1030+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Hash , Serialize , Deserialize ) ]
10221031pub struct WasmFieldType {
10231032 /// The field's element type.
10241033 pub element_type : WasmStorageType ,
@@ -1027,6 +1036,12 @@ pub struct WasmFieldType {
10271036 pub mutable : bool ,
10281037}
10291038
1039+ impl TryClone for WasmFieldType {
1040+ fn try_clone ( & self ) -> Result < Self , OutOfMemory > {
1041+ Ok ( * self )
1042+ }
1043+ }
1044+
10301045impl fmt:: Display for WasmFieldType {
10311046 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
10321047 if self . mutable {
@@ -1054,7 +1069,7 @@ impl TypeTrace for WasmFieldType {
10541069}
10551070
10561071/// A concrete array type.
1057- #[ derive( Debug , Clone , Eq , PartialEq , Hash , Serialize , Deserialize ) ]
1072+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Hash , Serialize , Deserialize ) ]
10581073pub struct WasmArrayType ( pub WasmFieldType ) ;
10591074
10601075impl fmt:: Display for WasmArrayType {
@@ -1086,6 +1101,14 @@ pub struct WasmStructType {
10861101 pub fields : Box < [ WasmFieldType ] > ,
10871102}
10881103
1104+ impl TryClone for WasmStructType {
1105+ fn try_clone ( & self ) -> Result < Self , OutOfMemory > {
1106+ Ok ( Self {
1107+ fields : self . fields . try_clone ( ) ?,
1108+ } )
1109+ }
1110+ }
1111+
10891112impl fmt:: Display for WasmStructType {
10901113 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
10911114 write ! ( f, "(struct" ) ?;
@@ -1128,6 +1151,15 @@ pub struct WasmCompositeType {
11281151 pub shared : bool ,
11291152}
11301153
1154+ impl TryClone for WasmCompositeType {
1155+ fn try_clone ( & self ) -> Result < Self , OutOfMemory > {
1156+ Ok ( Self {
1157+ inner : self . inner . try_clone ( ) ?,
1158+ shared : self . shared ,
1159+ } )
1160+ }
1161+ }
1162+
11311163impl fmt:: Display for WasmCompositeType {
11321164 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
11331165 if self . shared {
@@ -1152,6 +1184,18 @@ pub enum WasmCompositeInnerType {
11521184 Exn ( WasmExnType ) ,
11531185}
11541186
1187+ impl TryClone for WasmCompositeInnerType {
1188+ fn try_clone ( & self ) -> Result < Self , OutOfMemory > {
1189+ Ok ( match self {
1190+ Self :: Array ( ty) => Self :: Array ( * ty) ,
1191+ Self :: Func ( ty) => Self :: Func ( ty. try_clone ( ) ?) ,
1192+ Self :: Struct ( ty) => Self :: Struct ( ty. try_clone ( ) ?) ,
1193+ Self :: Cont ( ty) => Self :: Cont ( * ty) ,
1194+ Self :: Exn ( ty) => Self :: Exn ( ty. try_clone ( ) ?) ,
1195+ } )
1196+ }
1197+ }
1198+
11551199impl fmt:: Display for WasmCompositeInnerType {
11561200 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
11571201 match self {
@@ -1299,6 +1343,16 @@ pub struct WasmSubType {
12991343 pub composite_type : WasmCompositeType ,
13001344}
13011345
1346+ impl TryClone for WasmSubType {
1347+ fn try_clone ( & self ) -> Result < Self , OutOfMemory > {
1348+ Ok ( Self {
1349+ is_final : self . is_final ,
1350+ supertype : self . supertype ,
1351+ composite_type : self . composite_type . try_clone ( ) ?,
1352+ } )
1353+ }
1354+ }
1355+
13021356impl fmt:: Display for WasmSubType {
13031357 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
13041358 if self . is_final && self . supertype . is_none ( ) {
0 commit comments