diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-20 11:04:07 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-24 11:36:32 +0100 |
| commit | b853252bcdb2ded2b049d833c51a993fe0ed40f8 (patch) | |
| tree | 44e122e2186d0c84d1dc7ade0bfd4698321ed59f /src/librustc/mir/interpret/pointer.rs | |
| parent | 360f9888bc143f6d7b2c09f723e255121bf49f8d (diff) | |
| download | rust-b853252bcdb2ded2b049d833c51a993fe0ed40f8.tar.gz rust-b853252bcdb2ded2b049d833c51a993fe0ed40f8.zip | |
Rebase fallout
Diffstat (limited to 'src/librustc/mir/interpret/pointer.rs')
| -rw-r--r-- | src/librustc/mir/interpret/pointer.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/librustc/mir/interpret/pointer.rs b/src/librustc/mir/interpret/pointer.rs index 969f2c0e837..a046825f088 100644 --- a/src/librustc/mir/interpret/pointer.rs +++ b/src/librustc/mir/interpret/pointer.rs @@ -2,7 +2,7 @@ use mir; use ty::layout::{self, HasDataLayout, Size}; use super::{ - AllocId, EvalResult, + AllocId, EvalResult, InboundsCheck, }; //////////////////////////////////////////////////////////////////////////////// @@ -148,4 +148,21 @@ impl<'tcx, Tag> Pointer<Tag> { pub fn erase_tag(self) -> Pointer { Pointer { alloc_id: self.alloc_id, offset: self.offset, tag: () } } + + #[inline(always)] + pub fn check_in_alloc( + self, + allocation_size: Size, + check: InboundsCheck, + ) -> EvalResult<'tcx, ()> { + if self.offset > allocation_size { + err!(PointerOutOfBounds { + ptr: self.erase_tag(), + check, + allocation_size, + }) + } else { + Ok(()) + } + } } |
