@@ -367,7 +367,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
367367 let bytes = self . get_bytes_with_undef_and_ptr ( cx, ptr, size) ?;
368368 // Undef check happens *after* we established that the alignment is correct.
369369 // We must not return `Ok()` for unaligned pointers!
370- if self . check_defined ( ptr, size) . is_err ( ) {
370+ if self . is_defined ( ptr, size) . is_err ( ) {
371371 // This inflates undefined bytes to the entire scalar, even if only a few
372372 // bytes are undefined.
373373 return Ok ( ScalarMaybeUndef :: Undef ) ;
@@ -552,13 +552,19 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
552552}
553553
554554/// Undefined bytes.
555- impl < ' tcx , Tag , Extra > Allocation < Tag , Extra > {
555+ impl < ' tcx , Tag : Copy , Extra > Allocation < Tag , Extra > {
556+ /// Checks whether the given range is entirely defined.
557+ ///
558+ /// Returns `Ok(())` if it's defined. Otherwise returns the index of the byte
559+ /// at which the first undefined access begins.
560+ fn is_defined ( & self , ptr : Pointer < Tag > , size : Size ) -> Result < ( ) , Size > {
561+ self . undef_mask . is_range_defined ( ptr. offset , ptr. offset + size) // `Size` addition
562+ }
563+
556564 /// Checks that a range of bytes is defined. If not, returns the `ReadUndefBytes`
557565 /// error which will report the first byte which is undefined.
558- #[ inline]
559566 fn check_defined ( & self , ptr : Pointer < Tag > , size : Size ) -> InterpResult < ' tcx > {
560- self . undef_mask
561- . is_range_defined ( ptr. offset , ptr. offset + size) // `Size` addition
567+ self . is_defined ( ptr, size)
562568 . or_else ( |idx| throw_ub ! ( InvalidUndefBytes ( Some ( Pointer :: new( ptr. alloc_id, idx) ) ) ) )
563569 }
564570
0 commit comments