@@ -56,23 +56,7 @@ impl<'tcx> GotocCtx<'tcx> {
5656 . assign ( self . codegen_rvalue ( r, location) , location)
5757 }
5858 }
59- StatementKind :: Deinit ( place) => {
60- // From rustc doc: "This writes `uninit` bytes to the entire place."
61- // Our model of GotoC has a similar statement, which is later lowered
62- // to assigning a Nondet in CBMC, with a comment specifying that it
63- // corresponds to a Deinit.
64- let dst_mir_ty = self . place_ty ( place) ;
65- let dst_type = self . codegen_ty ( dst_mir_ty) ;
66- let layout = self . layout_of ( dst_mir_ty) ;
67- if layout. is_zst ( ) || dst_type. sizeof_in_bits ( & self . symbol_table ) == 0 {
68- // We ignore assignment for all zero size types
69- Stmt :: skip ( location)
70- } else {
71- unwrap_or_return_codegen_unimplemented_stmt ! ( self , self . codegen_place( place) )
72- . goto_expr
73- . deinit ( location)
74- }
75- }
59+ StatementKind :: Deinit ( place) => self . codegen_deinit ( place, location) ,
7660 StatementKind :: SetDiscriminant { place, variant_index } => {
7761 // this requires place points to an enum type.
7862 let pt = self . place_ty ( place) ;
@@ -277,6 +261,25 @@ impl<'tcx> GotocCtx<'tcx> {
277261 }
278262 }
279263
264+ /// From rustc doc: "This writes `uninit` bytes to the entire place."
265+ /// Our model of GotoC has a similar statement, which is later lowered
266+ /// to assigning a Nondet in CBMC, with a comment specifying that it
267+ /// corresponds to a Deinit.
268+ #[ cfg( not( feature = "unsound_experiments" ) ) ]
269+ fn codegen_deinit ( & mut self , place : & Place < ' tcx > , loc : Location ) -> Stmt {
270+ let dst_mir_ty = self . place_ty ( place) ;
271+ let dst_type = self . codegen_ty ( dst_mir_ty) ;
272+ let layout = self . layout_of ( dst_mir_ty) ;
273+ if layout. is_zst ( ) || dst_type. sizeof_in_bits ( & self . symbol_table ) == 0 {
274+ // We ignore assignment for all zero size types
275+ Stmt :: skip ( loc)
276+ } else {
277+ unwrap_or_return_codegen_unimplemented_stmt ! ( self , self . codegen_place( place) )
278+ . goto_expr
279+ . deinit ( loc)
280+ }
281+ }
282+
280283 /// A special case handler to codegen `return ();`
281284 fn codegen_ret_unit ( & mut self ) -> Stmt {
282285 let is_file_local = false ;
0 commit comments