@@ -198,7 +198,6 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
198
198
align : Align ,
199
199
check_defined_and_ptr : bool ,
200
200
) -> EvalResult < ' tcx , & [ u8 ] > {
201
- assert_ne ! ( size. bytes( ) , 0 , "0-sized accesses should never even get a `Pointer`" ) ;
202
201
self . check_align ( ptr. into ( ) , align) ?;
203
202
self . check_bounds ( cx, ptr, size, true ) ?;
204
203
@@ -251,7 +250,6 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
251
250
size : Size ,
252
251
align : Align ,
253
252
) -> EvalResult < ' tcx , & mut [ u8 ] > {
254
- assert_ne ! ( size. bytes( ) , 0 , "0-sized accesses should never even get a `Pointer`" ) ;
255
253
self . check_align ( ptr. into ( ) , align) ?;
256
254
self . check_bounds ( cx, ptr, size, true ) ?;
257
255
@@ -294,13 +292,8 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
294
292
size : Size ,
295
293
allow_ptr_and_undef : bool ,
296
294
) -> 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
298
296
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
304
297
self . get_bytes_with_undef_and_ptr ( cx, ptr, size, align) ?;
305
298
// Check undef and ptr
306
299
if !allow_ptr_and_undef {
@@ -316,12 +309,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
316
309
ptr : Pointer < Tag > ,
317
310
size : Size ,
318
311
) -> EvalResult < ' tcx , & [ u8 ] > {
319
- // Empty accesses don't need to be valid pointers, but they should still be non-NULL
320
312
let align = Align :: from_bytes ( 1 , 1 ) . unwrap ( ) ;
321
- if size. bytes ( ) == 0 {
322
- self . check_align ( ptr, align) ?;
323
- return Ok ( & [ ] ) ;
324
- }
325
313
self . get_bytes ( cx, ptr, size, align)
326
314
}
327
315
@@ -331,12 +319,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
331
319
ptr : Pointer < Tag > ,
332
320
src : & [ u8 ] ,
333
321
) -> EvalResult < ' tcx > {
334
- // Empty accesses don't need to be valid pointers, but they should still be non-NULL
335
322
let align = Align :: from_bytes ( 1 , 1 ) . unwrap ( ) ;
336
- if src. is_empty ( ) {
337
- self . check_align ( ptr, align) ?;
338
- return Ok ( ( ) ) ;
339
- }
340
323
let bytes = self . get_bytes_mut ( cx, ptr, Size :: from_bytes ( src. len ( ) as u64 ) , align) ?;
341
324
bytes. clone_from_slice ( src) ;
342
325
Ok ( ( ) )
@@ -349,12 +332,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
349
332
val : u8 ,
350
333
count : Size
351
334
) -> EvalResult < ' tcx > {
352
- // Empty accesses don't need to be valid pointers, but they should still be non-NULL
353
335
let align = Align :: from_bytes ( 1 , 1 ) . unwrap ( ) ;
354
- if count. bytes ( ) == 0 {
355
- self . check_align ( ptr, align) ?;
356
- return Ok ( ( ) ) ;
357
- }
358
336
let bytes = self . get_bytes_mut ( cx, ptr, count, align) ?;
359
337
for b in bytes {
360
338
* b = val;
@@ -589,9 +567,6 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
589
567
size : Size ,
590
568
new_state : bool ,
591
569
) -> EvalResult < ' tcx > {
592
- if size. bytes ( ) == 0 {
593
- return Ok ( ( ) ) ;
594
- }
595
570
self . undef_mask . set_range (
596
571
ptr. offset ,
597
572
ptr. offset + size,
0 commit comments