diff options
| author | Andreas Molzer <andreas.molzer@gmx.de> | 2019-08-29 18:02:51 +0200 |
|---|---|---|
| committer | Andreas Molzer <andreas.molzer@gmx.de> | 2019-08-29 20:02:21 +0200 |
| commit | 6fe31fefd80cd1c4300b03b1e55c63de12134eed (patch) | |
| tree | 7ea605c60c737fe86b115f3c698d3dd07f2c9fee | |
| parent | 85d6b7b9d3d946b35826298e3d04381f96427433 (diff) | |
| download | rust-6fe31fefd80cd1c4300b03b1e55c63de12134eed.tar.gz rust-6fe31fefd80cd1c4300b03b1e55c63de12134eed.zip | |
Make allocation relocation field private
| -rw-r--r-- | src/librustc/mir/interpret/allocation.rs | 13 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/intern.rs | 4 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/memory.rs | 4 | ||||
| -rw-r--r-- | src/librustc_mir/monomorphize/collector.rs | 4 | ||||
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 2 |
5 files changed, 16 insertions, 11 deletions
diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index dcfa2e5cb46..75319a67831 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -35,7 +35,7 @@ pub struct Allocation<Tag=(),Extra=()> { /// Only the first byte of a pointer is inserted into the map; i.e., /// every entry in this map applies to `pointer_size` consecutive bytes starting /// at the given offset. - pub relocations: Relocations<Tag>, + relocations: Relocations<Tag>, /// Denotes which part of this allocation is initialized. undef_mask: UndefMask, /// The size of the allocation. Currently, must always equal `bytes.len()`. @@ -148,6 +148,11 @@ impl<Tag, Extra> Allocation<Tag, Extra> { pub fn undef_mask(&self) -> &UndefMask { &self.undef_mask } + + /// Returns the relocation list. + pub fn relocations(&self) -> &Relocations<Tag> { + &self.relocations + } } impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx Allocation {} @@ -459,7 +464,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> { /// Relocations impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> { /// Returns all relocations overlapping with the given ptr-offset pair. - pub fn relocations( + pub fn get_relocations( &self, cx: &impl HasDataLayout, ptr: Pointer<Tag>, @@ -480,7 +485,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> { ptr: Pointer<Tag>, size: Size, ) -> InterpResult<'tcx> { - if self.relocations(cx, ptr, size).is_empty() { + if self.get_relocations(cx, ptr, size).is_empty() { Ok(()) } else { throw_unsup!(ReadPointerAsBytes) @@ -502,7 +507,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> { // Find the start and end of the given range and its outermost relocations. let (first, last) = { // Find all relocations overlapping the given range. - let relocations = self.relocations(cx, ptr, size); + let relocations = self.get_relocations(cx, ptr, size); if relocations.is_empty() { return Ok(()); } diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs index 32ba70a81c9..4cbbc0ffe17 100644 --- a/src/librustc_mir/interpret/intern.rs +++ b/src/librustc_mir/interpret/intern.rs @@ -94,7 +94,7 @@ impl<'rt, 'mir, 'tcx> InternVisitor<'rt, 'mir, 'tcx> { alloc.mutability = mutability; // link the alloc id to the actual allocation let alloc = tcx.intern_const_alloc(alloc); - self.leftover_relocations.extend(alloc.relocations.iter().map(|&(_, ((), reloc))| reloc)); + self.leftover_relocations.extend(alloc.relocations().iter().map(|&(_, ((), reloc))| reloc)); tcx.alloc_map.lock().set_alloc_id_memory(ptr.alloc_id, alloc); Ok(None) } @@ -316,7 +316,7 @@ pub fn intern_const_alloc_recursive( // So we hand-roll the interning logic here again let alloc = tcx.intern_const_alloc(alloc); tcx.alloc_map.lock().set_alloc_id_memory(alloc_id, alloc); - for &(_, ((), reloc)) in alloc.relocations.iter() { + for &(_, ((), reloc)) in alloc.relocations().iter() { if leftover_relocations.insert(reloc) { todo.push(reloc); } diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 7f7729ae5e0..26b3f0be8c2 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -647,7 +647,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { for i in 0..alloc.size.bytes() { let i = Size::from_bytes(i); - if let Some(&(_, target_id)) = alloc.relocations.get(&i) { + if let Some(&(_, target_id)) = alloc.relocations().get(&i) { if allocs_seen.insert(target_id) { allocs_to_print.push_back(target_id); } @@ -809,7 +809,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { // (`get_bytes_with_undef_and_ptr` below checks that there are no // relocations overlapping the edges; those would not be handled correctly). let relocations = { - let relocations = self.get(src.alloc_id)?.relocations(self, src, size); + let relocations = self.get(src.alloc_id)?.get_relocations(self, src, size); if relocations.is_empty() { // nothing to copy, ignore even the `length` loop Vec::new() diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 12d763bb791..a9403502f64 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -1202,7 +1202,7 @@ fn collect_miri<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut Vec<Mon } Some(GlobalAlloc::Memory(alloc)) => { trace!("collecting {:?} with {:#?}", alloc_id, alloc); - for &((), inner) in alloc.relocations.values() { + for &((), inner) in alloc.relocations().values() { collect_miri(tcx, inner, output); } }, @@ -1268,7 +1268,7 @@ fn collect_const<'tcx>( collect_miri(tcx, ptr.alloc_id, output), ConstValue::Slice { data: alloc, start: _, end: _ } | ConstValue::ByRef { alloc, .. } => { - for &((), id) in alloc.relocations.values() { + for &((), id) in alloc.relocations().values() { collect_miri(tcx, id, output); } } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 14fc0d6347e..e68104c6df8 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1570,7 +1570,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: DefId, span: Span) } else { bug!("Matching on non-ByRef static") }; - if alloc.relocations.len() != 0 { + if alloc.relocations().len() != 0 { let msg = "statics with a custom `#[link_section]` must be a \ simple list of bytes on the wasm target with no \ extra levels of indirection such as references"; |
