Skip to content

Commit b78c118

Browse files
authored
Rollup merge of #97626 - RalfJung:expose, r=tmiasko
rename PointerAddress → PointerExposeAddress `PointerAddress` sounds a bit too much like `ptr.addr()`, but this corresponds to `ptr.expose_addr()`. r? `@tmiasko`
2 parents a96e71c + 4dc5d45 commit b78c118

File tree

12 files changed

+23
-18
lines changed

12 files changed

+23
-18
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
21472147
}
21482148
}
21492149

2150-
CastKind::PointerAddress => {
2150+
CastKind::PointerExposeAddress => {
21512151
let ty_from = op.ty(body, tcx);
21522152
let cast_ty_from = CastTy::from_ty(ty_from);
21532153
let cast_ty_to = CastTy::from_ty(*ty);

compiler/rustc_codegen_cranelift/src/base.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,11 @@ fn codegen_stmt<'tcx>(
607607
let operand = codegen_operand(fx, operand);
608608
lval.write_cvalue(fx, operand.cast_pointer_to(to_layout));
609609
}
610-
Rvalue::Cast(CastKind::Misc | CastKind::PointerAddress, ref operand, to_ty) => {
610+
Rvalue::Cast(
611+
CastKind::Misc | CastKind::PointerExposeAddress,
612+
ref operand,
613+
to_ty,
614+
) => {
611615
let operand = codegen_operand(fx, operand);
612616
let from_ty = operand.layout().ty;
613617
let to_ty = fx.monomorphize(to_ty);

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
181181
let cast = bx.cx().layout_of(self.monomorphize(mir_cast_ty));
182182

183183
let val = match *kind {
184-
mir::CastKind::PointerAddress => {
184+
mir::CastKind::PointerExposeAddress => {
185185
assert!(bx.cx().is_backend_immediate(cast));
186186
let llptr = operand.immediate();
187187
let llcast_ty = bx.cx().immediate_backend_type(cast);

compiler/rustc_const_eval/src/interpret/cast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
3131
self.unsize_into(src, cast_ty, dest)?;
3232
}
3333

34-
PointerAddress => {
34+
PointerExposeAddress => {
3535
let src = self.read_immediate(src)?;
36-
let res = self.pointer_address_cast(&src, cast_ty)?;
36+
let res = self.pointer_expose_address_cast(&src, cast_ty)?;
3737
self.write_immediate(res, dest)?;
3838
}
3939

@@ -184,7 +184,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
184184
Ok(self.cast_from_int_like(scalar, src.layout, cast_ty)?.into())
185185
}
186186

187-
pub fn pointer_address_cast(
187+
pub fn pointer_expose_address_cast(
188188
&mut self,
189189
src: &ImmTy<'tcx, M::PointerTag>,
190190
cast_ty: Ty<'tcx>,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
542542
// in the type of any local, which also excludes casts).
543543
}
544544

545-
Rvalue::Cast(CastKind::PointerAddress, _, _) => {
545+
Rvalue::Cast(CastKind::PointerExposeAddress, _, _) => {
546546
self.check_op(ops::RawPtrToIntCast);
547547
}
548548

compiler/rustc_const_eval/src/transform/promote_consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl<'tcx> Validator<'_, 'tcx> {
502502
Rvalue::ThreadLocalRef(_) => return Err(Unpromotable),
503503

504504
// ptr-to-int casts are not possible in consts and thus not promotable
505-
Rvalue::Cast(CastKind::PointerAddress, _, _) => return Err(Unpromotable),
505+
Rvalue::Cast(CastKind::PointerExposeAddress, _, _) => return Err(Unpromotable),
506506

507507
// int-to-ptr casts are fine, they just use the integer value at pointer type.
508508
Rvalue::Cast(_, operand, _) => {

compiler/rustc_middle/src/mir/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2607,16 +2607,17 @@ static_assert_size!(Rvalue<'_>, 40);
26072607
impl<'tcx> Rvalue<'tcx> {
26082608
#[inline]
26092609
pub fn is_pointer_int_cast(&self) -> bool {
2610-
matches!(self, Rvalue::Cast(CastKind::PointerAddress, _, _))
2610+
matches!(self, Rvalue::Cast(CastKind::PointerExposeAddress, _, _))
26112611
}
26122612
}
26132613

26142614
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
26152615
pub enum CastKind {
26162616
Misc,
2617-
/// A pointer to address cast. A cast between a pointer and an integer type,
2618-
/// or between a function pointer and an integer type.
2619-
PointerAddress,
2617+
/// An exposing pointer to address cast. A cast between a pointer and an integer type, or
2618+
/// between a function pointer and an integer type.
2619+
/// See the docs on `expose_addr` for more details.
2620+
PointerExposeAddress,
26202621
Pointer(PointerCast),
26212622
}
26222623

compiler/rustc_mir_build/src/build/expr/as_rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
194194
let cast_ty = CastTy::from_ty(expr.ty);
195195
let cast_kind = match (from_ty, cast_ty) {
196196
(Some(CastTy::Ptr(_) | CastTy::FnPtr), Some(CastTy::Int(_))) => {
197-
CastKind::PointerAddress
197+
CastKind::PointerExposeAddress
198198
}
199199
(_, _) => CastKind::Misc,
200200
};

src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// + span: $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
2222
// + literal: Const { ty: &i32, val: Unevaluated(FOO, [], None) }
2323
_2 = &raw const (*_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
24-
_1 = move _2 as usize (PointerAddress); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:39
24+
_1 = move _2 as usize (PointerExposeAddress); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:39
2525
StorageDead(_2); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:38: 7:39
2626
StorageDead(_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:39: 7:40
2727
StorageLive(_4); // scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12

src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// mir::Constant
1818
// + span: $DIR/reify_fn_ptr.rs:4:13: 4:17
1919
// + literal: Const { ty: fn() {main}, val: Value(Scalar(<ZST>)) }
20-
_2 = move _3 as usize (PointerAddress); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26
20+
_2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26
2121
StorageDead(_3); // scope 0 at $DIR/reify_fn_ptr.rs:4:25: 4:26
2222
_1 = move _2 as *const fn() (Misc); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41
2323
StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:4:40: 4:41

src/test/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
StorageLive(_2); // scope 0 at $DIR/provenance_soundness.rs:8:9: 8:11
2020
StorageLive(_3); // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:15
2121
_3 = _1; // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:15
22-
_2 = move _3 as usize (PointerAddress); // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:24
22+
_2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:24
2323
StorageDead(_3); // scope 0 at $DIR/provenance_soundness.rs:8:23: 8:24
2424
StorageLive(_4); // scope 1 at $DIR/provenance_soundness.rs:9:9: 9:11
2525
StorageLive(_5); // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:15
2626
_5 = _1; // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:15
27-
_4 = move _5 as isize (PointerAddress); // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:24
27+
_4 = move _5 as isize (PointerExposeAddress); // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:24
2828
StorageDead(_5); // scope 1 at $DIR/provenance_soundness.rs:9:23: 9:24
2929
_0 = const (); // scope 0 at $DIR/provenance_soundness.rs:7:32: 10:2
3030
StorageDead(_4); // scope 1 at $DIR/provenance_soundness.rs:10:1: 10:2

src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn check_rvalue<'tcx>(
125125
Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
126126
check_place(tcx, *place, span, body)
127127
},
128-
Rvalue::Cast(CastKind::PointerAddress, _, _) => {
128+
Rvalue::Cast(CastKind::PointerExposeAddress, _, _) => {
129129
Err((span, "casting pointers to ints is unstable in const fn".into()))
130130
},
131131
Rvalue::Cast(CastKind::Misc, operand, _) => {

0 commit comments

Comments
 (0)