@@ -628,6 +628,23 @@ impl<'tcx> GotocCtx<'tcx> {
628
628
. assign ( self . codegen_rvalue ( r) , Location :: none ( ) )
629
629
}
630
630
}
631
+ StatementKind :: Deinit ( place) => {
632
+ // From rustc doc: "This writes `uninit` bytes to the entire place."
633
+ // Thus, we assign nondet() value to the entire place.
634
+ let dst_mir_ty = self . place_ty ( place) ;
635
+ let dst_type = self . codegen_ty ( dst_mir_ty) ;
636
+ let layout = self . layout_of ( dst_mir_ty) ;
637
+ if layout. is_zst ( ) || self . ignore_var_ty ( dst_mir_ty) {
638
+ // We ignore assignment for all zero size types
639
+ // Ignore generators too for now:
640
+ // https://github.com/model-checking/kani/issues/416
641
+ Stmt :: skip ( Location :: none ( ) )
642
+ } else {
643
+ unwrap_or_return_codegen_unimplemented_stmt ! ( self , self . codegen_place( place) )
644
+ . goto_expr
645
+ . assign ( dst_type. nondet ( ) , Location :: none ( ) )
646
+ }
647
+ }
631
648
StatementKind :: SetDiscriminant { place, variant_index } => {
632
649
// this requires place points to an enum type.
633
650
let pt = self . place_ty ( place) ;
@@ -740,7 +757,6 @@ impl<'tcx> GotocCtx<'tcx> {
740
757
| StatementKind :: AscribeUserType ( _, _)
741
758
| StatementKind :: Nop
742
759
| StatementKind :: Coverage { .. } => Stmt :: skip ( Location :: none ( ) ) ,
743
- StatementKind :: Deinit ( _) => todo ! ( "Unimplemented statement. See: " ) ,
744
760
}
745
761
. with_location ( self . codegen_span ( & stmt. source_info . span ) )
746
762
}
0 commit comments