@@ -628,6 +628,23 @@ impl<'tcx> GotocCtx<'tcx> {
628628 . assign ( self . codegen_rvalue ( r) , Location :: none ( ) )
629629 }
630630 }
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+ }
631648 StatementKind :: SetDiscriminant { place, variant_index } => {
632649 // this requires place points to an enum type.
633650 let pt = self . place_ty ( place) ;
@@ -740,7 +757,6 @@ impl<'tcx> GotocCtx<'tcx> {
740757 | StatementKind :: AscribeUserType ( _, _)
741758 | StatementKind :: Nop
742759 | StatementKind :: Coverage { .. } => Stmt :: skip ( Location :: none ( ) ) ,
743- StatementKind :: Deinit ( _) => todo ! ( "Unimplemented statement. See: " ) ,
744760 }
745761 . with_location ( self . codegen_span ( & stmt. source_info . span ) )
746762 }
0 commit comments