Skip to content

Commit 064515d

Browse files
committed
Fixup various import errors
1 parent 212cb50 commit 064515d

File tree

1 file changed

+43
-34
lines changed

1 file changed

+43
-34
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@
1313
use super::{
1414
UndefMask,
1515
Relocations,
16+
EvalResult,
17+
Pointer,
18+
AllocId,
19+
Scalar,
20+
ScalarMaybeUndef,
21+
write_target_uint,
22+
read_target_uint,
23+
truncate,
1624
};
1725

18-
use ty::layout::{Size, Align};
26+
use std::ptr;
27+
use ty::layout::{self, Size, Align};
1928
use syntax::ast::Mutability;
2029

2130
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
@@ -85,7 +94,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
8594
/// on that.
8695
fn get_bytes_internal(
8796
&self,
88-
ptr: Pointer<M::PointerTag>,
97+
ptr: Pointer<Tag>,
8998
size: Size,
9099
align: Align,
91100
check_defined_and_ptr: bool,
@@ -114,7 +123,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
114123
#[inline]
115124
fn get_bytes(
116125
&self,
117-
ptr: Pointer<M::PointerTag>,
126+
ptr: Pointer<Tag>,
118127
size: Size,
119128
align: Align
120129
) -> EvalResult<'tcx, &[u8]> {
@@ -126,7 +135,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
126135
#[inline]
127136
fn get_bytes_with_undef_and_ptr(
128137
&self,
129-
ptr: Pointer<M::PointerTag>,
138+
ptr: Pointer<Tag>,
130139
size: Size,
131140
align: Align
132141
) -> EvalResult<'tcx, &[u8]> {
@@ -137,7 +146,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
137146
/// so be sure to actually put data there!
138147
fn get_bytes_mut(
139148
&mut self,
140-
ptr: Pointer<M::PointerTag>,
149+
ptr: Pointer<Tag>,
141150
size: Size,
142151
align: Align,
143152
) -> EvalResult<'tcx, &mut [u8]> {
@@ -162,9 +171,9 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
162171
impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
163172
pub fn copy(
164173
&mut self,
165-
src: Scalar<M::PointerTag>,
174+
src: Scalar<Tag>,
166175
src_align: Align,
167-
dest: Scalar<M::PointerTag>,
176+
dest: Scalar<Tag>,
168177
dest_align: Align,
169178
size: Size,
170179
nonoverlapping: bool,
@@ -174,9 +183,9 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
174183

175184
pub fn copy_repeatedly(
176185
&mut self,
177-
src: Scalar<M::PointerTag>,
186+
src: Scalar<Tag>,
178187
src_align: Align,
179-
dest: Scalar<M::PointerTag>,
188+
dest: Scalar<Tag>,
180189
dest_align: Align,
181190
size: Size,
182191
length: u64,
@@ -257,7 +266,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
257266
Ok(())
258267
}
259268

260-
pub fn read_c_str(&self, ptr: Pointer<M::PointerTag>) -> EvalResult<'tcx, &[u8]> {
269+
pub fn read_c_str(&self, ptr: Pointer<Tag>) -> EvalResult<'tcx, &[u8]> {
261270
let alloc = self.get(ptr.alloc_id)?;
262271
assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes());
263272
let offset = ptr.offset.bytes() as usize;
@@ -274,7 +283,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
274283

275284
pub fn check_bytes(
276285
&self,
277-
ptr: Scalar<M::PointerTag>,
286+
ptr: Scalar<Tag>,
278287
size: Size,
279288
allow_ptr_and_undef: bool,
280289
) -> EvalResult<'tcx> {
@@ -295,7 +304,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
295304
Ok(())
296305
}
297306

298-
pub fn read_bytes(&self, ptr: Scalar<M::PointerTag>, size: Size) -> EvalResult<'tcx, &[u8]> {
307+
pub fn read_bytes(&self, ptr: Scalar<Tag>, size: Size) -> EvalResult<'tcx, &[u8]> {
299308
// Empty accesses don't need to be valid pointers, but they should still be non-NULL
300309
let align = Align::from_bytes(1, 1).unwrap();
301310
if size.bytes() == 0 {
@@ -305,7 +314,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
305314
self.get_bytes(ptr.to_ptr()?, size, align)
306315
}
307316

308-
pub fn write_bytes(&mut self, ptr: Scalar<M::PointerTag>, src: &[u8]) -> EvalResult<'tcx> {
317+
pub fn write_bytes(&mut self, ptr: Scalar<Tag>, src: &[u8]) -> EvalResult<'tcx> {
309318
// Empty accesses don't need to be valid pointers, but they should still be non-NULL
310319
let align = Align::from_bytes(1, 1).unwrap();
311320
if src.is_empty() {
@@ -319,7 +328,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
319328

320329
pub fn write_repeat(
321330
&mut self,
322-
ptr: Scalar<M::PointerTag>,
331+
ptr: Scalar<Tag>,
323332
val: u8,
324333
count: Size
325334
) -> EvalResult<'tcx> {
@@ -339,10 +348,10 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
339348
/// Read a *non-ZST* scalar
340349
pub fn read_scalar(
341350
&self,
342-
ptr: Pointer<M::PointerTag>,
351+
ptr: Pointer<Tag>,
343352
ptr_align: Align,
344353
size: Size
345-
) -> EvalResult<'tcx, ScalarMaybeUndef<M::PointerTag>> {
354+
) -> EvalResult<'tcx, ScalarMaybeUndef<Tag>> {
346355
// get_bytes_unchecked tests alignment and relocation edges
347356
let bytes = self.get_bytes_with_undef_and_ptr(
348357
ptr, size, ptr_align.min(self.int_align(size))
@@ -376,18 +385,18 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
376385

377386
pub fn read_ptr_sized(
378387
&self,
379-
ptr: Pointer<M::PointerTag>,
388+
ptr: Pointer<Tag>,
380389
ptr_align: Align
381-
) -> EvalResult<'tcx, ScalarMaybeUndef<M::PointerTag>> {
390+
) -> EvalResult<'tcx, ScalarMaybeUndef<Tag>> {
382391
self.read_scalar(ptr, ptr_align, self.pointer_size())
383392
}
384393

385394
/// Write a *non-ZST* scalar
386395
pub fn write_scalar(
387396
&mut self,
388-
ptr: Pointer<M::PointerTag>,
397+
ptr: Pointer<Tag>,
389398
ptr_align: Align,
390-
val: ScalarMaybeUndef<M::PointerTag>,
399+
val: ScalarMaybeUndef<Tag>,
391400
type_size: Size,
392401
) -> EvalResult<'tcx> {
393402
let val = match val {
@@ -432,9 +441,9 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
432441

433442
pub fn write_ptr_sized(
434443
&mut self,
435-
ptr: Pointer<M::PointerTag>,
444+
ptr: Pointer<Tag>,
436445
ptr_align: Align,
437-
val: ScalarMaybeUndef<M::PointerTag>
446+
val: ScalarMaybeUndef<Tag>
438447
) -> EvalResult<'tcx> {
439448
let ptr_size = self.pointer_size();
440449
self.write_scalar(ptr.into(), ptr_align, val, ptr_size)
@@ -460,9 +469,9 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
460469
/// Return all relocations overlapping with the given ptr-offset pair.
461470
fn relocations(
462471
&self,
463-
ptr: Pointer<M::PointerTag>,
472+
ptr: Pointer<Tag>,
464473
size: Size,
465-
) -> EvalResult<'tcx, &[(Size, (M::PointerTag, AllocId))]> {
474+
) -> EvalResult<'tcx, &[(Size, (Tag, AllocId))]> {
466475
// We have to go back `pointer_size - 1` bytes, as that one would still overlap with
467476
// the beginning of this range.
468477
let start = ptr.offset.bytes().saturating_sub(self.pointer_size().bytes() - 1);
@@ -472,7 +481,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
472481

473482
/// Check that there ar eno relocations overlapping with the given range.
474483
#[inline(always)]
475-
fn check_relocations(&self, ptr: Pointer<M::PointerTag>, size: Size) -> EvalResult<'tcx> {
484+
fn check_relocations(&self, ptr: Pointer<Tag>, size: Size) -> EvalResult<'tcx> {
476485
if self.relocations(ptr, size)?.len() != 0 {
477486
err!(ReadPointerAsBytes)
478487
} else {
@@ -486,7 +495,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
486495
/// uninitialized. This is a somewhat odd "spooky action at a distance",
487496
/// but it allows strictly more code to run than if we would just error
488497
/// immediately in that case.
489-
fn clear_relocations(&mut self, ptr: Pointer<M::PointerTag>, size: Size) -> EvalResult<'tcx> {
498+
fn clear_relocations(&mut self, ptr: Pointer<Tag>, size: Size) -> EvalResult<'tcx> {
490499
// Find the start and end of the given range and its outermost relocations.
491500
let (first, last) = {
492501
// Find all relocations overlapping the given range.
@@ -521,7 +530,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
521530
/// Error if there are relocations overlapping with the egdes of the
522531
/// given memory range.
523532
#[inline]
524-
fn check_relocation_edges(&self, ptr: Pointer<M::PointerTag>, size: Size) -> EvalResult<'tcx> {
533+
fn check_relocation_edges(&self, ptr: Pointer<Tag>, size: Size) -> EvalResult<'tcx> {
525534
self.check_relocations(ptr, Size::ZERO)?;
526535
self.check_relocations(ptr.offset(size, self)?, Size::ZERO)?;
527536
Ok(())
@@ -533,8 +542,8 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
533542
// FIXME: Add a fast version for the common, nonoverlapping case
534543
fn copy_undef_mask(
535544
&mut self,
536-
src: Pointer<M::PointerTag>,
537-
dest: Pointer<M::PointerTag>,
545+
src: Pointer<Tag>,
546+
dest: Pointer<Tag>,
538547
size: Size,
539548
repeat: u64,
540549
) -> EvalResult<'tcx> {
@@ -561,7 +570,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
561570
/// Checks that a range of bytes is defined. If not, returns the `ReadUndefBytes`
562571
/// error which will report the first byte which is undefined.
563572
#[inline]
564-
fn check_defined(&self, ptr: Pointer<M::PointerTag>, size: Size) -> EvalResult<'tcx> {
573+
fn check_defined(&self, ptr: Pointer<Tag>, size: Size) -> EvalResult<'tcx> {
565574
let alloc = self.get(ptr.alloc_id)?;
566575
alloc.undef_mask.is_range_defined(
567576
ptr.offset,
@@ -571,7 +580,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
571580

572581
pub fn mark_definedness(
573582
&mut self,
574-
ptr: Pointer<M::PointerTag>,
583+
ptr: Pointer<Tag>,
575584
size: Size,
576585
new_state: bool,
577586
) -> EvalResult<'tcx> {
@@ -593,7 +602,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
593602
/// You can pass a scalar, and a `Pointer` does not have to actually still be allocated.
594603
pub fn check_align(
595604
&self,
596-
ptr: Scalar<M::PointerTag>,
605+
ptr: Scalar<Tag>,
597606
required_align: Align
598607
) -> EvalResult<'tcx> {
599608
// Check non-NULL/Undef, extract offset
@@ -648,7 +657,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
648657
/// If you want to check bounds before doing a memory access, be sure to
649658
/// check the pointer one past the end of your access, then everything will
650659
/// work out exactly.
651-
pub fn check_bounds_ptr(&self, ptr: Pointer<M::PointerTag>, access: bool) -> EvalResult<'tcx> {
660+
pub fn check_bounds_ptr(&self, ptr: Pointer<Tag>, access: bool) -> EvalResult<'tcx> {
652661
let alloc = self.get(ptr.alloc_id)?;
653662
let allocation_size = alloc.bytes.len() as u64;
654663
if ptr.offset.bytes() > allocation_size {
@@ -665,7 +674,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
665674
#[inline(always)]
666675
pub fn check_bounds(
667676
&self,
668-
ptr: Pointer<M::PointerTag>,
677+
ptr: Pointer<Tag>,
669678
size: Size,
670679
access: bool
671680
) -> EvalResult<'tcx> {

0 commit comments

Comments
 (0)