@@ -298,10 +298,7 @@ impl StructBoxedDeconstructLibfunc {
298298 let arg_type_info = context. get_type_info ( ty. clone ( ) ) ?;
299299 let is_snapshot = arg_type_info. long_id . generic_id == SnapshotType :: id ( ) ;
300300 if is_snapshot {
301- ty = match & arg_type_info. long_id . generic_args [ 0 ] {
302- GenericArg :: Type ( ty) => ty. clone ( ) ,
303- _ => return Err ( SpecializationError :: UnsupportedGenericArg ) ,
304- }
301+ ty = args_as_single_type ( & arg_type_info. long_id . generic_args ) ?;
305302 }
306303 let struct_type = StructConcreteType :: try_from_concrete_type ( context, & ty) ?;
307304 Ok ( ( struct_type. members , is_snapshot) )
@@ -321,22 +318,26 @@ impl StructBoxedDeconstructLibfunc {
321318 & self ,
322319 context : & dyn SignatureSpecializationContext ,
323320 ty : ConcreteTypeId ,
324- member_types : Vec < ConcreteTypeId > ,
321+ member_types : impl IntoIterator < Item = ConcreteTypeId > ,
325322 is_snapshot : bool ,
326323 ) -> Result < LibfuncSignature , SpecializationError > {
324+ let mut is_shifted = false ;
327325 Ok ( LibfuncSignature :: new_non_branch_ex (
328326 vec ! [ ParamSignature :: new( box_ty( context, ty) ?) . with_allow_add_const( ) ] ,
329327 member_types
330328 . into_iter ( )
331329 . map ( |member_ty| {
330+ let ref_info = if is_shifted {
331+ OutputVarReferenceInfo :: Deferred ( DeferredOutputKind :: AddConst {
332+ param_idx : 0 ,
333+ } )
334+ } else {
335+ is_shifted = !context. get_type_info ( member_ty. clone ( ) ) ?. zero_sized ;
336+ OutputVarReferenceInfo :: SameAsParam { param_idx : 0 }
337+ } ;
332338 let inner_type =
333339 if is_snapshot { snapshot_ty ( context, member_ty) ? } else { member_ty } ;
334- Ok ( OutputVarInfo {
335- ty : box_ty ( context, inner_type) ?,
336- ref_info : OutputVarReferenceInfo :: Deferred (
337- crate :: extensions:: lib_func:: DeferredOutputKind :: Generic ,
338- ) ,
339- } )
340+ Ok ( OutputVarInfo { ty : box_ty ( context, inner_type) ?, ref_info } )
340341 } )
341342 . collect :: < Result < Vec < _ > , _ > > ( ) ?,
342343 SierraApChange :: Known { new_vars_only : true } ,
@@ -367,7 +368,7 @@ impl NamedLibfunc for StructBoxedDeconstructLibfunc {
367368 let ty = args_as_single_type ( args) ?;
368369 let ( members, is_snapshot) = self . analyze_struct_type ( context, ty. clone ( ) ) ?;
369370 let signature =
370- self . inner_specialize_signature ( context, ty, members. clone ( ) , is_snapshot) ?;
371+ self . inner_specialize_signature ( context, ty, members. iter ( ) . cloned ( ) , is_snapshot) ?;
371372 Ok ( ConcreteStructBoxedDeconstructLibfunc { members, signature } )
372373 }
373374}
0 commit comments