File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/librustc_mir/interpret Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -880,9 +880,16 @@ where
880880 layout : TyLayout < ' tcx > ,
881881 kind : MemoryKind < M :: MemoryKinds > ,
882882 ) -> EvalResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > {
883- assert ! ( !layout. is_unsized( ) , "cannot alloc memory for unsized type" ) ;
884- let ptr = self . memory . allocate ( layout. size , layout. align , kind) ?;
885- Ok ( MPlaceTy :: from_aligned_ptr ( ptr, layout) )
883+ if layout. is_unsized ( ) {
884+ assert ! ( self . tcx. features( ) . unsized_locals, "cannot alloc memory for unsized type" ) ;
885+ // allocate a fat pointer slot instead
886+ let fat = self . tcx . mk_mut_ptr ( layout. ty ) ;
887+ let fat = self . layout_of ( fat) ?;
888+ self . allocate ( fat, kind)
889+ } else {
890+ let ptr = self . memory . allocate ( layout. size , layout. align , kind) ?;
891+ Ok ( MPlaceTy :: from_aligned_ptr ( ptr, layout) )
892+ }
886893 }
887894
888895 pub fn write_discriminant_index (
You can’t perform that action at this time.
0 commit comments