@@ -372,7 +372,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
372372 let bytes = self . get_bytes_with_undef_and_ptr ( cx, ptr, size) ?;
373373 // Undef check happens *after* we established that the alignment is correct.
374374 // We must not return `Ok()` for unaligned pointers!
375- if self . check_defined ( ptr, size) . is_err ( ) {
375+ if self . is_defined ( ptr, size) . is_err ( ) {
376376 // This inflates undefined bytes to the entire scalar, even if only a few
377377 // bytes are undefined.
378378 return Ok ( ScalarMaybeUndef :: Undef ) ;
@@ -557,13 +557,19 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
557557}
558558
559559/// Undefined bytes.
560- impl < ' tcx , Tag , Extra > Allocation < Tag , Extra > {
560+ impl < ' tcx , Tag : Copy , Extra > Allocation < Tag , Extra > {
561+ /// Checks whether the given range is entirely defined.
562+ ///
563+ /// Returns `Ok(())` if it's defined. Otherwise returns the index of the byte
564+ /// at which the first undefined access begins.
565+ fn is_defined ( & self , ptr : Pointer < Tag > , size : Size ) -> Result < ( ) , Size > {
566+ self . undef_mask . is_range_defined ( ptr. offset , ptr. offset + size)
567+ }
568+
561569 /// Checks that a range of bytes is defined. If not, returns the `ReadUndefBytes`
562570 /// error which will report the first byte which is undefined.
563- #[ inline]
564571 fn check_defined ( & self , ptr : Pointer < Tag > , size : Size ) -> InterpResult < ' tcx > {
565- self . undef_mask
566- . is_range_defined ( ptr. offset , ptr. offset + size)
572+ self . is_defined ( ptr, size)
567573 . or_else ( |idx| throw_ub ! ( InvalidUndefBytes ( Some ( Pointer :: new( ptr. alloc_id, idx) ) ) ) )
568574 }
569575
0 commit comments