Skip to content

Commit e9ef8e1

Browse files
authored
Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=Amanieu
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066). The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".) The new name nicely matches `ptr::without_provenance`.
2 parents 0697ee9 + f2cff5e commit e9ef8e1

File tree

51 files changed

+120
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+120
-113
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,7 +2279,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22792279
}
22802280
}
22812281

2282-
CastKind::PointerFromExposedAddress => {
2282+
CastKind::PointerWithExposedProvenance => {
22832283
let ty_from = op.ty(body, tcx);
22842284
let cast_ty_from = CastTy::from_ty(ty_from);
22852285
let cast_ty_to = CastTy::from_ty(*ty);
@@ -2289,7 +2289,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22892289
span_mirbug!(
22902290
self,
22912291
rvalue,
2292-
"Invalid PointerFromExposedAddress cast {:?} -> {:?}",
2292+
"Invalid PointerWithExposedProvenance cast {:?} -> {:?}",
22932293
ty_from,
22942294
ty
22952295
)

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ fn codegen_stmt<'tcx>(
650650
| CastKind::FnPtrToPtr
651651
| CastKind::PtrToPtr
652652
| CastKind::PointerExposeAddress
653-
| CastKind::PointerFromExposedAddress,
653+
| CastKind::PointerWithExposedProvenance,
654654
ref operand,
655655
to_ty,
656656
) => {

compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
965965
});
966966
}
967967

968-
sym::simd_expose_addr | sym::simd_from_exposed_addr | sym::simd_cast_ptr => {
968+
sym::simd_expose_addr | sym::simd_with_exposed_provenance | sym::simd_cast_ptr => {
969969
intrinsic_args!(fx, args => (arg); intrinsic);
970970
ret.write_cvalue_transmute(fx, arg);
971971
}

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
21392139
return Ok(bx.ptrtoint(args[0].immediate(), llret_ty));
21402140
}
21412141

2142-
if name == sym::simd_from_exposed_addr {
2142+
if name == sym::simd_with_exposed_provenance {
21432143
let (out_len, out_elem) = require_simd!(ret_ty, SimdReturn);
21442144
require!(
21452145
in_len == out_len,

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
509509
// Since int2ptr can have arbitrary integer types as input (so we have to do
510510
// sign extension and all that), it is currently best handled in the same code
511511
// path as the other integer-to-X casts.
512-
| mir::CastKind::PointerFromExposedAddress => {
512+
| mir::CastKind::PointerWithExposedProvenance => {
513513
assert!(bx.cx().is_backend_immediate(cast));
514514
let ll_t_out = bx.cx().immediate_backend_type(cast);
515515
if operand.layout.abi.is_uninhabited() {

compiler/rustc_const_eval/src/interpret/cast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
4040
self.write_immediate(*res, dest)?;
4141
}
4242

43-
CastKind::PointerFromExposedAddress => {
43+
CastKind::PointerWithExposedProvenance => {
4444
let src = self.read_immediate(src)?;
45-
let res = self.pointer_from_exposed_address_cast(&src, cast_layout)?;
45+
let res = self.pointer_with_exposed_provenance_cast(&src, cast_layout)?;
4646
self.write_immediate(*res, dest)?;
4747
}
4848

@@ -242,7 +242,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
242242
Ok(ImmTy::from_scalar(self.cast_from_int_like(scalar, src.layout, cast_to.ty)?, cast_to))
243243
}
244244

245-
pub fn pointer_from_exposed_address_cast(
245+
pub fn pointer_with_exposed_provenance_cast(
246246
&self,
247247
src: &ImmTy<'tcx, M::Provenance>,
248248
cast_to: TyAndLayout<'tcx>,

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
547547
Rvalue::Cast(CastKind::PointerExposeAddress, _, _) => {
548548
self.check_op(ops::RawPtrToIntCast);
549549
}
550-
Rvalue::Cast(CastKind::PointerFromExposedAddress, _, _) => {
550+
Rvalue::Cast(CastKind::PointerWithExposedProvenance, _, _) => {
551551
// Since no pointer can ever get exposed (rejected above), this is easy to support.
552552
}
553553

compiler/rustc_const_eval/src/transform/validate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10761076
// FIXME(dyn-star): make sure nothing needs to be done here.
10771077
}
10781078
// FIXME: Add Checks for these
1079-
CastKind::PointerFromExposedAddress
1079+
CastKind::PointerWithExposedProvenance
10801080
| CastKind::PointerExposeAddress
10811081
| CastKind::PointerCoercion(_) => {}
10821082
CastKind::IntToInt | CastKind::IntToFloat => {

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ pub fn check_intrinsic_type(
628628
| sym::simd_as
629629
| sym::simd_cast_ptr
630630
| sym::simd_expose_addr
631-
| sym::simd_from_exposed_addr => (2, 0, vec![param(0)], param(1)),
631+
| sym::simd_with_exposed_provenance => (2, 0, vec![param(0)], param(1)),
632632
sym::simd_bitmask => (2, 0, vec![param(0)], param(1)),
633633
sym::simd_select | sym::simd_select_bitmask => {
634634
(2, 0, vec![param(0), param(1), param(1)], param(1))

compiler/rustc_hir_typeck/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ hir_typeck_invalid_callee = expected function, found {$ty}
8686
hir_typeck_lossy_provenance_int2ptr =
8787
strict provenance disallows casting integer `{$expr_ty}` to pointer `{$cast_ty}`
8888
.suggestion = use `.with_addr()` to adjust a valid pointer in the same allocation, to this address
89-
.help = if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::from_exposed_addr()` instead
89+
.help = if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::with_exposed_provenance()` instead
9090
9191
hir_typeck_lossy_provenance_ptr2int =
9292
under strict provenance it is considered bad style to cast pointer `{$expr_ty}` to integer `{$cast_ty}`

0 commit comments

Comments
 (0)