@@ -10,7 +10,7 @@ use rustc_data_structures::sorted_map::SortedMap;
1010use rustc_target:: abi:: { Align , HasDataLayout , Size } ;
1111
1212use super :: {
13- read_target_uint, write_target_uint, AllocId , InterpResult , Pointer , Scalar , ScalarMaybeUndef ,
13+ read_target_uint, write_target_uint, AllocId , InterpResult , Pointer , Scalar , ScalarMaybeUninit ,
1414} ;
1515
1616// NOTE: When adding new fields, make sure to adjust the `Snapshot` impl in
@@ -27,7 +27,7 @@ pub struct Allocation<Tag = (), Extra = ()> {
2727 /// at the given offset.
2828 relocations : Relocations < Tag > ,
2929 /// Denotes which part of this allocation is initialized.
30- undef_mask : UndefMask ,
30+ undef_mask : UninitMask ,
3131 /// The size of the allocation. Currently, must always equal `bytes.len()`.
3232 pub size : Size ,
3333 /// The alignment of the allocation to detect unaligned reads.
@@ -94,7 +94,7 @@ impl<Tag> Allocation<Tag> {
9494 Self {
9595 bytes,
9696 relocations : Relocations :: new ( ) ,
97- undef_mask : UndefMask :: new ( size, true ) ,
97+ undef_mask : UninitMask :: new ( size, true ) ,
9898 size,
9999 align,
100100 mutability : Mutability :: Not ,
@@ -110,7 +110,7 @@ impl<Tag> Allocation<Tag> {
110110 Allocation {
111111 bytes : vec ! [ 0 ; size. bytes_usize( ) ] ,
112112 relocations : Relocations :: new ( ) ,
113- undef_mask : UndefMask :: new ( size, false ) ,
113+ undef_mask : UninitMask :: new ( size, false ) ,
114114 size,
115115 align,
116116 mutability : Mutability :: Mut ,
@@ -163,7 +163,7 @@ impl<Tag, Extra> Allocation<Tag, Extra> {
163163 }
164164
165165 /// Returns the undef mask.
166- pub fn undef_mask ( & self ) -> & UndefMask {
166+ pub fn undef_mask ( & self ) -> & UninitMask {
167167 & self . undef_mask
168168 }
169169
@@ -360,15 +360,15 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
360360 cx : & impl HasDataLayout ,
361361 ptr : Pointer < Tag > ,
362362 size : Size ,
363- ) -> InterpResult < ' tcx , ScalarMaybeUndef < Tag > > {
363+ ) -> InterpResult < ' tcx , ScalarMaybeUninit < Tag > > {
364364 // `get_bytes_unchecked` tests relocation edges.
365365 let bytes = self . get_bytes_with_undef_and_ptr ( cx, ptr, size) ?;
366366 // Undef check happens *after* we established that the alignment is correct.
367367 // We must not return `Ok()` for unaligned pointers!
368368 if self . is_defined ( ptr, size) . is_err ( ) {
369369 // This inflates undefined bytes to the entire scalar, even if only a few
370370 // bytes are undefined.
371- return Ok ( ScalarMaybeUndef :: Undef ) ;
371+ return Ok ( ScalarMaybeUninit :: Undef ) ;
372372 }
373373 // Now we do the actual reading.
374374 let bits = read_target_uint ( cx. data_layout ( ) . endian , bytes) . unwrap ( ) ;
@@ -379,11 +379,11 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
379379 } else {
380380 if let Some ( & ( tag, alloc_id) ) = self . relocations . get ( & ptr. offset ) {
381381 let ptr = Pointer :: new_with_tag ( alloc_id, Size :: from_bytes ( bits) , tag) ;
382- return Ok ( ScalarMaybeUndef :: Scalar ( ptr. into ( ) ) ) ;
382+ return Ok ( ScalarMaybeUninit :: Scalar ( ptr. into ( ) ) ) ;
383383 }
384384 }
385385 // We don't. Just return the bits.
386- Ok ( ScalarMaybeUndef :: Scalar ( Scalar :: from_uint ( bits, size) ) )
386+ Ok ( ScalarMaybeUninit :: Scalar ( Scalar :: from_uint ( bits, size) ) )
387387 }
388388
389389 /// Reads a pointer-sized scalar.
@@ -394,7 +394,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
394394 & self ,
395395 cx : & impl HasDataLayout ,
396396 ptr : Pointer < Tag > ,
397- ) -> InterpResult < ' tcx , ScalarMaybeUndef < Tag > > {
397+ ) -> InterpResult < ' tcx , ScalarMaybeUninit < Tag > > {
398398 self . read_scalar ( cx, ptr, cx. data_layout ( ) . pointer_size )
399399 }
400400
@@ -411,12 +411,12 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
411411 & mut self ,
412412 cx : & impl HasDataLayout ,
413413 ptr : Pointer < Tag > ,
414- val : ScalarMaybeUndef < Tag > ,
414+ val : ScalarMaybeUninit < Tag > ,
415415 type_size : Size ,
416416 ) -> InterpResult < ' tcx > {
417417 let val = match val {
418- ScalarMaybeUndef :: Scalar ( scalar) => scalar,
419- ScalarMaybeUndef :: Undef => {
418+ ScalarMaybeUninit :: Scalar ( scalar) => scalar,
419+ ScalarMaybeUninit :: Undef => {
420420 self . mark_definedness ( ptr, type_size, false ) ;
421421 return Ok ( ( ) ) ;
422422 }
@@ -447,7 +447,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
447447 & mut self ,
448448 cx : & impl HasDataLayout ,
449449 ptr : Pointer < Tag > ,
450- val : ScalarMaybeUndef < Tag > ,
450+ val : ScalarMaybeUninit < Tag > ,
451451 ) -> InterpResult < ' tcx > {
452452 let ptr_size = cx. data_layout ( ) . pointer_size ;
453453 self . write_scalar ( cx, ptr, val, ptr_size)
@@ -557,7 +557,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
557557 /// error which will report the first byte which is undefined.
558558 fn check_defined ( & self , ptr : Pointer < Tag > , size : Size ) -> InterpResult < ' tcx > {
559559 self . is_defined ( ptr, size)
560- . or_else ( |idx| throw_ub ! ( InvalidUndefBytes ( Some ( Pointer :: new( ptr. alloc_id, idx) ) ) ) )
560+ . or_else ( |idx| throw_ub ! ( InvalidUninitBytes ( Some ( Pointer :: new( ptr. alloc_id, idx) ) ) ) )
561561 }
562562
563563 pub fn mark_definedness ( & mut self , ptr : Pointer < Tag > , size : Size , new_state : bool ) {
@@ -744,16 +744,16 @@ type Block = u64;
744744/// is defined. If it is `false` the byte is undefined.
745745#[ derive( Clone , Debug , Eq , PartialEq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable ) ]
746746#[ derive( HashStable ) ]
747- pub struct UndefMask {
747+ pub struct UninitMask {
748748 blocks : Vec < Block > ,
749749 len : Size ,
750750}
751751
752- impl UndefMask {
752+ impl UninitMask {
753753 pub const BLOCK_SIZE : u64 = 64 ;
754754
755755 pub fn new ( size : Size , state : bool ) -> Self {
756- let mut m = UndefMask { blocks : vec ! [ ] , len : Size :: ZERO } ;
756+ let mut m = UninitMask { blocks : vec ! [ ] , len : Size :: ZERO } ;
757757 m. grow ( size, state) ;
758758 m
759759 }
@@ -872,7 +872,7 @@ impl UndefMask {
872872#[ inline]
873873fn bit_index ( bits : Size ) -> ( usize , usize ) {
874874 let bits = bits. bytes ( ) ;
875- let a = bits / UndefMask :: BLOCK_SIZE ;
876- let b = bits % UndefMask :: BLOCK_SIZE ;
875+ let a = bits / UninitMask :: BLOCK_SIZE ;
876+ let b = bits % UninitMask :: BLOCK_SIZE ;
877877 ( usize:: try_from ( a) . unwrap ( ) , usize:: try_from ( b) . unwrap ( ) )
878878}
0 commit comments