Skip to content

Commit 0793f51

Browse files
committed
rename Pointer::from_addr_invalid to match strict provenance API
1 parent d0b60c2 commit 0793f51

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

compiler/rustc_const_eval/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
574574
if addr != 0 {
575575
diag.arg(
576576
"pointer",
577-
Pointer::<Option<CtfeProvenance>>::from_addr_invalid(addr).to_string(),
577+
Pointer::<Option<CtfeProvenance>>::without_provenance(addr).to_string(),
578578
);
579579
}
580580

compiler/rustc_const_eval/src/interpret/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ pub macro compile_time_machine(<$tcx: lifetime>) {
747747
// Allow these casts, but make the pointer not dereferenceable.
748748
// (I.e., they behave like transmutation.)
749749
// This is correct because no pointers can ever be exposed in compile-time evaluation.
750-
interp_ok(Pointer::from_addr_invalid(addr))
750+
interp_ok(Pointer::without_provenance(addr))
751751
}
752752

753753
#[inline(always)]

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'tcx, Prov: Provenance> MPlaceTy<'tcx, Prov> {
118118
pub fn fake_alloc_zst(layout: TyAndLayout<'tcx>) -> Self {
119119
assert!(layout.is_zst());
120120
let align = layout.align.abi;
121-
let ptr = Pointer::from_addr_invalid(align.bytes()); // no provenance, absolute address
121+
let ptr = Pointer::without_provenance(align.bytes()); // no provenance, absolute address
122122
MPlaceTy { mplace: MemPlace { ptr, meta: MemPlaceMeta::None, misaligned: None }, layout }
123123
}
124124

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
518518
Ub(DanglingIntPointer { addr: i, .. }) => DanglingPtrNoProvenance {
519519
ptr_kind,
520520
// FIXME this says "null pointer" when null but we need translate
521-
pointer: format!("{}", Pointer::<Option<AllocId>>::from_addr_invalid(i))
521+
pointer: format!("{}", Pointer::<Option<AllocId>>::without_provenance(i))
522522
},
523523
Ub(PointerOutOfBounds { .. }) => DanglingPtrOutOfBounds {
524524
ptr_kind

compiler/rustc_middle/src/mir/interpret/pointer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ impl<Prov> Pointer<Option<Prov>> {
318318
/// Creates a pointer to the given address, with invalid provenance (i.e., cannot be used for
319319
/// any memory access).
320320
#[inline(always)]
321-
pub fn from_addr_invalid(addr: u64) -> Self {
321+
pub fn without_provenance(addr: u64) -> Self {
322322
Pointer { provenance: None, offset: Size::from_bytes(addr) }
323323
}
324324

325325
#[inline(always)]
326326
pub fn null() -> Self {
327-
Pointer::from_addr_invalid(0)
327+
Pointer::without_provenance(0)
328328
}
329329
}
330330

compiler/rustc_middle/src/mir/interpret/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl<'tcx, Prov: Provenance> Scalar<Prov> {
276276
Right(ptr) => interp_ok(ptr.into()),
277277
Left(bits) => {
278278
let addr = u64::try_from(bits).unwrap();
279-
interp_ok(Pointer::from_addr_invalid(addr))
279+
interp_ok(Pointer::without_provenance(addr))
280280
}
281281
}
282282
}

src/tools/miri/src/shims/unix/mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
4949
&& matches!(&*this.tcx.sess.target.os, "macos" | "solaris" | "illumos")
5050
&& (flags & map_fixed) != 0
5151
{
52-
return interp_ok(Scalar::from_maybe_pointer(Pointer::from_addr_invalid(addr), this));
52+
return interp_ok(Scalar::from_maybe_pointer(Pointer::without_provenance(addr), this));
5353
}
5454

5555
let prot_read = this.eval_libc_i32("PROT_READ");

0 commit comments

Comments
 (0)