@@ -198,7 +198,6 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
198198 align : Align ,
199199 check_defined_and_ptr : bool ,
200200 ) -> EvalResult < ' tcx , & [ u8 ] > {
201- assert_ne ! ( size. bytes( ) , 0 , "0-sized accesses should never even get a `Pointer`" ) ;
202201 self . check_align ( ptr. into ( ) , align) ?;
203202 self . check_bounds ( cx, ptr, size, true ) ?;
204203
@@ -251,7 +250,6 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
251250 size : Size ,
252251 align : Align ,
253252 ) -> EvalResult < ' tcx , & mut [ u8 ] > {
254- assert_ne ! ( size. bytes( ) , 0 , "0-sized accesses should never even get a `Pointer`" ) ;
255253 self . check_align ( ptr. into ( ) , align) ?;
256254 self . check_bounds ( cx, ptr, size, true ) ?;
257255
@@ -294,13 +292,8 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
294292 size : Size ,
295293 allow_ptr_and_undef : bool ,
296294 ) -> EvalResult < ' tcx > {
297- // Empty accesses don't need to be valid pointers, but they should still be non-NULL
295+ // Check bounds and relocations on the edges
298296 let align = Align :: from_bytes ( 1 , 1 ) . unwrap ( ) ;
299- if size. bytes ( ) == 0 {
300- self . check_align ( ptr, align) ?;
301- return Ok ( ( ) ) ;
302- }
303- // Check bounds, align and relocations on the edges
304297 self . get_bytes_with_undef_and_ptr ( cx, ptr, size, align) ?;
305298 // Check undef and ptr
306299 if !allow_ptr_and_undef {
@@ -316,12 +309,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
316309 ptr : Pointer < Tag > ,
317310 size : Size ,
318311 ) -> EvalResult < ' tcx , & [ u8 ] > {
319- // Empty accesses don't need to be valid pointers, but they should still be non-NULL
320312 let align = Align :: from_bytes ( 1 , 1 ) . unwrap ( ) ;
321- if size. bytes ( ) == 0 {
322- self . check_align ( ptr, align) ?;
323- return Ok ( & [ ] ) ;
324- }
325313 self . get_bytes ( cx, ptr, size, align)
326314 }
327315
@@ -331,12 +319,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
331319 ptr : Pointer < Tag > ,
332320 src : & [ u8 ] ,
333321 ) -> EvalResult < ' tcx > {
334- // Empty accesses don't need to be valid pointers, but they should still be non-NULL
335322 let align = Align :: from_bytes ( 1 , 1 ) . unwrap ( ) ;
336- if src. is_empty ( ) {
337- self . check_align ( ptr, align) ?;
338- return Ok ( ( ) ) ;
339- }
340323 let bytes = self . get_bytes_mut ( cx, ptr, Size :: from_bytes ( src. len ( ) as u64 ) , align) ?;
341324 bytes. clone_from_slice ( src) ;
342325 Ok ( ( ) )
@@ -349,12 +332,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
349332 val : u8 ,
350333 count : Size
351334 ) -> EvalResult < ' tcx > {
352- // Empty accesses don't need to be valid pointers, but they should still be non-NULL
353335 let align = Align :: from_bytes ( 1 , 1 ) . unwrap ( ) ;
354- if count. bytes ( ) == 0 {
355- self . check_align ( ptr, align) ?;
356- return Ok ( ( ) ) ;
357- }
358336 let bytes = self . get_bytes_mut ( cx, ptr, count, align) ?;
359337 for b in bytes {
360338 * b = val;
@@ -589,9 +567,6 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
589567 size : Size ,
590568 new_state : bool ,
591569 ) -> EvalResult < ' tcx > {
592- if size. bytes ( ) == 0 {
593- return Ok ( ( ) ) ;
594- }
595570 self . undef_mask . set_range (
596571 ptr. offset ,
597572 ptr. offset + size,
0 commit comments