Skip to content

Commit 84a343d

Browse files
committed
tweak some function names
1 parent f0ec783 commit 84a343d

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

compiler/rustc_const_eval/src/const_eval/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
364364

365365
// If an allocation is created in an another const,
366366
// we don't deallocate it.
367-
let (alloc_id, _, _) = ecx.ptr_get_alloc(ptr)?;
367+
let (alloc_id, _, _) = ecx.ptr_get_alloc_id(ptr)?;
368368
let is_allocated_in_another_const = matches!(
369369
ecx.tcx.get_global_alloc(alloc_id),
370370
Some(interpret::GlobalAlloc::Memory(_))

compiler/rustc_const_eval/src/interpret/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
318318
// exception from the exception.)
319319
// This is the dual to the special exception for offset-by-0
320320
// in the inbounds pointer offset operation (see `ptr_offset_inbounds` below).
321-
match (self.ptr_try_get_alloc(a), self.ptr_try_get_alloc(b)) {
321+
match (self.ptr_try_get_alloc_id(a), self.ptr_try_get_alloc_id(b)) {
322322
(Err(a), Err(b)) if a == b && a != 0 => {
323323
// Both are the same non-null integer.
324324
self.write_scalar(Scalar::from_machine_isize(0, self), dest)?;

compiler/rustc_const_eval/src/interpret/memory.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
200200
kind: MemoryKind<M::MemoryKind>,
201201
) -> InterpResult<'static, Pointer<M::PointerTag>> {
202202
let alloc = Allocation::uninit(size, align, M::PANIC_ON_ALLOC_FAIL)?;
203-
Ok(self.allocate_with_ptr(alloc, kind))
203+
Ok(self.allocate_raw_ptr(alloc, kind))
204204
}
205205

206206
pub fn allocate_bytes_ptr(
@@ -211,10 +211,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
211211
mutability: Mutability,
212212
) -> Pointer<M::PointerTag> {
213213
let alloc = Allocation::from_bytes(bytes, align, mutability);
214-
self.allocate_with_ptr(alloc, kind)
214+
self.allocate_raw_ptr(alloc, kind)
215215
}
216216

217-
pub fn allocate_with_ptr(
217+
pub fn allocate_raw_ptr(
218218
&mut self,
219219
alloc: Allocation,
220220
kind: MemoryKind<M::MemoryKind>,
@@ -238,7 +238,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
238238
new_align: Align,
239239
kind: MemoryKind<M::MemoryKind>,
240240
) -> InterpResult<'tcx, Pointer<M::PointerTag>> {
241-
let (alloc_id, offset, ptr) = self.ptr_get_alloc(ptr)?;
241+
let (alloc_id, offset, ptr) = self.ptr_get_alloc_id(ptr)?;
242242
if offset.bytes() != 0 {
243243
throw_ub_format!(
244244
"reallocating {:?} which does not point to the beginning of an object",
@@ -274,7 +274,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
274274
old_size_and_align: Option<(Size, Align)>,
275275
kind: MemoryKind<M::MemoryKind>,
276276
) -> InterpResult<'tcx> {
277-
let (alloc_id, offset, ptr) = self.ptr_get_alloc(ptr)?;
277+
let (alloc_id, offset, ptr) = self.ptr_get_alloc_id(ptr)?;
278278
trace!("deallocating: {}", alloc_id);
279279

280280
if offset.bytes() != 0 {
@@ -419,7 +419,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
419419
}
420420
}
421421

422-
Ok(match self.ptr_try_get_alloc(ptr) {
422+
Ok(match self.ptr_try_get_alloc_id(ptr) {
423423
Err(addr) => {
424424
// We couldn't get a proper allocation. This is only okay if the access size is 0,
425425
// and the address is not null.
@@ -731,7 +731,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
731731
ptr: Pointer<Option<M::PointerTag>>,
732732
) -> InterpResult<'tcx, FnVal<'tcx, M::ExtraFnVal>> {
733733
trace!("get_fn({:?})", ptr);
734-
let (alloc_id, offset, _ptr) = self.ptr_get_alloc(ptr)?;
734+
let (alloc_id, offset, _ptr) = self.ptr_get_alloc_id(ptr)?;
735735
if offset.bytes() != 0 {
736736
throw_ub!(InvalidFunctionPointer(Pointer::new(alloc_id, offset)))
737737
}
@@ -1125,7 +1125,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
11251125
Err(_) => {
11261126
// Can only happen during CTFE.
11271127
let ptr = self.scalar_to_ptr(scalar);
1128-
match self.ptr_try_get_alloc(ptr) {
1128+
match self.ptr_try_get_alloc_id(ptr) {
11291129
Ok((alloc_id, offset, _)) => {
11301130
let (size, _align) = self
11311131
.get_alloc_size_and_align(alloc_id, AllocCheck::MaybeDead)
@@ -1142,7 +1142,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
11421142

11431143
/// Turning a "maybe pointer" into a proper pointer (and some information
11441144
/// about where it points), or an absolute address.
1145-
pub fn ptr_try_get_alloc(
1145+
pub fn ptr_try_get_alloc_id(
11461146
&self,
11471147
ptr: Pointer<Option<M::PointerTag>>,
11481148
) -> Result<(AllocId, Size, Pointer<M::PointerTag>), u64> {
@@ -1157,11 +1157,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
11571157

11581158
/// Turning a "maybe pointer" into a proper pointer (and some information about where it points).
11591159
#[inline(always)]
1160-
pub fn ptr_get_alloc(
1160+
pub fn ptr_get_alloc_id(
11611161
&self,
11621162
ptr: Pointer<Option<M::PointerTag>>,
11631163
) -> InterpResult<'tcx, (AllocId, Size, Pointer<M::PointerTag>)> {
1164-
self.ptr_try_get_alloc(ptr).map_err(|offset| {
1164+
self.ptr_try_get_alloc_id(ptr).map_err(|offset| {
11651165
err_ub!(DanglingIntPointer(offset, CheckInAllocMsg::InboundsTest)).into()
11661166
})
11671167
}

compiler/rustc_const_eval/src/interpret/validity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
432432
if let Some(ref mut ref_tracking) = self.ref_tracking {
433433
// Proceed recursively even for ZST, no reason to skip them!
434434
// `!` is a ZST and we want to validate it.
435-
if let Ok((alloc_id, _offset, _ptr)) = self.ecx.ptr_try_get_alloc(place.ptr) {
435+
if let Ok((alloc_id, _offset, _ptr)) = self.ecx.ptr_try_get_alloc_id(place.ptr) {
436436
// Special handling for pointers to statics (irrespective of their type).
437437
let alloc_kind = self.ecx.tcx.get_global_alloc(alloc_id);
438438
if let Some(GlobalAlloc::Static(did)) = alloc_kind {

0 commit comments

Comments
 (0)