From 35709be02d43b40e7f720408f8a88bf6e9d5501d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 12 Aug 2024 10:57:57 +0200 Subject: [PATCH] rename AddressOf -> RawBorrow inside the compiler --- compiler/rustc_borrowck/src/def_use.rs | 4 ++-- compiler/rustc_borrowck/src/lib.rs | 2 +- .../src/polonius/loan_invalidations.rs | 2 +- compiler/rustc_borrowck/src/type_check/mod.rs | 6 +++--- .../rustc_codegen_cranelift/src/analyze.rs | 2 +- compiler/rustc_codegen_cranelift/src/base.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/analyze.rs | 4 ++-- compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 6 +++--- .../rustc_const_eval/src/check_consts/check.rs | 10 +++++----- .../src/check_consts/qualifs.rs | 2 +- .../src/check_consts/resolver.rs | 4 ++-- .../rustc_const_eval/src/interpret/step.rs | 2 +- compiler/rustc_hir_typeck/src/cast.rs | 2 +- compiler/rustc_middle/src/mir/pretty.rs | 2 +- compiler/rustc_middle/src/mir/statement.rs | 2 +- compiler/rustc_middle/src/mir/syntax.rs | 8 ++++---- compiler/rustc_middle/src/mir/tcx.rs | 2 +- compiler/rustc_middle/src/mir/visit.rs | 18 +++++++++--------- compiler/rustc_middle/src/thir.rs | 2 +- compiler/rustc_middle/src/thir/visit.rs | 2 +- .../src/build/custom/parse/instruction.rs | 4 ++-- .../rustc_mir_build/src/build/expr/as_place.rs | 2 +- .../src/build/expr/as_rvalue.rs | 2 +- .../rustc_mir_build/src/build/expr/category.rs | 2 +- .../rustc_mir_build/src/build/expr/into.rs | 4 ++-- compiler/rustc_mir_build/src/check_unsafety.rs | 4 ++-- compiler/rustc_mir_build/src/thir/cx/expr.rs | 4 ++-- .../src/thir/pattern/check_match.rs | 2 +- compiler/rustc_mir_build/src/thir/print.rs | 4 ++-- .../rustc_mir_dataflow/src/elaborate_drops.rs | 2 +- .../src/impls/borrowed_locals.rs | 2 +- .../src/impls/initialized.rs | 2 +- .../rustc_mir_dataflow/src/impls/liveness.rs | 4 ++-- .../src/move_paths/builder.rs | 2 +- .../rustc_mir_dataflow/src/value_analysis.rs | 2 +- compiler/rustc_mir_transform/src/add_retag.rs | 4 ++-- .../rustc_mir_transform/src/check_alignment.rs | 2 +- .../src/deduce_param_attrs.rs | 2 +- compiler/rustc_mir_transform/src/dest_prop.rs | 2 +- compiler/rustc_mir_transform/src/gvn.rs | 4 ++-- .../rustc_mir_transform/src/instsimplify.rs | 2 +- .../src/known_panics_lint.rs | 10 +++++----- .../rustc_mir_transform/src/large_enums.rs | 4 ++-- .../rustc_mir_transform/src/promote_consts.rs | 2 +- compiler/rustc_mir_transform/src/ref_prop.rs | 2 +- .../src/shim/async_destructor_ctor.rs | 4 ++-- compiler/rustc_mir_transform/src/ssa.rs | 8 ++++---- compiler/rustc_mir_transform/src/validate.rs | 2 +- .../rustc_smir/src/rustc_smir/convert/mir.rs | 2 +- compiler/rustc_ty_utils/src/consts.rs | 6 +++--- .../clippy_utils/src/qualify_min_const_fn.rs | 2 +- 51 files changed, 92 insertions(+), 92 deletions(-) diff --git a/compiler/rustc_borrowck/src/def_use.rs b/compiler/rustc_borrowck/src/def_use.rs index 1f0b0981c8f29..e07d7dd309ae2 100644 --- a/compiler/rustc_borrowck/src/def_use.rs +++ b/compiler/rustc_borrowck/src/def_use.rs @@ -55,8 +55,8 @@ pub fn categorize(context: PlaceContext) -> Option { PlaceContext::NonMutatingUse(NonMutatingUseContext::PlaceMention) | PlaceContext::NonUse(NonUseContext::AscribeUserTy(_)) | - PlaceContext::MutatingUse(MutatingUseContext::AddressOf) | - PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) | + PlaceContext::MutatingUse(MutatingUseContext::RawBorrow) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) | PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) | PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) | PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) | diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 30dd45d847c9b..a529df76bcbc7 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -1242,7 +1242,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> { ); } - &Rvalue::AddressOf(mutability, place) => { + &Rvalue::RawPtr(mutability, place) => { let access_kind = match mutability { Mutability::Mut => ( Deep, diff --git a/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs index f090da031a04b..a57041cd04c52 100644 --- a/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs +++ b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs @@ -269,7 +269,7 @@ impl<'cx, 'tcx> LoanInvalidationsGenerator<'cx, 'tcx> { self.access_place(location, place, access_kind, LocalMutationIsAllowed::No); } - &Rvalue::AddressOf(mutability, place) => { + &Rvalue::RawPtr(mutability, place) => { let access_kind = match mutability { Mutability::Mut => ( Deep, diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index a2669da1b04e8..6983cda6ddf3b 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -756,7 +756,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { PlaceContext::MutatingUse(_) => ty::Invariant, PlaceContext::NonUse(StorageDead | StorageLive | VarDebugInfo) => ty::Invariant, PlaceContext::NonMutatingUse( - Inspect | Copy | Move | PlaceMention | SharedBorrow | FakeBorrow | AddressOf + Inspect | Copy | Move | PlaceMention | SharedBorrow | FakeBorrow | RawBorrow | Projection, ) => ty::Covariant, PlaceContext::NonUse(AscribeUserTy(variance)) => variance, @@ -2468,7 +2468,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { self.check_operand(right, location); } - Rvalue::AddressOf(..) + Rvalue::RawPtr(..) | Rvalue::ThreadLocalRef(..) | Rvalue::Len(..) | Rvalue::Discriminant(..) @@ -2485,7 +2485,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | Rvalue::ThreadLocalRef(_) | Rvalue::Repeat(..) | Rvalue::Ref(..) - | Rvalue::AddressOf(..) + | Rvalue::RawPtr(..) | Rvalue::Len(..) | Rvalue::Cast(..) | Rvalue::ShallowInitBox(..) diff --git a/compiler/rustc_codegen_cranelift/src/analyze.rs b/compiler/rustc_codegen_cranelift/src/analyze.rs index c5762638a6b13..72380f50385a1 100644 --- a/compiler/rustc_codegen_cranelift/src/analyze.rs +++ b/compiler/rustc_codegen_cranelift/src/analyze.rs @@ -25,7 +25,7 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, '_>) -> IndexVec { for stmt in bb.statements.iter() { match &stmt.kind { Assign(place_and_rval) => match &place_and_rval.1 { - Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { + Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => { flag_map[place.local] = SsaKind::NotSsa; } _ => {} diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 9bc7b57c53745..f1d885bf1bce8 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -595,7 +595,7 @@ fn codegen_stmt<'tcx>( let val = cplace.to_cvalue(fx); lval.write_cvalue(fx, val) } - Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { + Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => { let place = codegen_place(fx, place); let ref_ = place.place_ref(fx, lval.layout()); lval.write_cvalue(fx, ref_); diff --git a/compiler/rustc_codegen_ssa/src/mir/analyze.rs b/compiler/rustc_codegen_ssa/src/mir/analyze.rs index 6794365c9beef..c8cf341628c32 100644 --- a/compiler/rustc_codegen_ssa/src/mir/analyze.rs +++ b/compiler/rustc_codegen_ssa/src/mir/analyze.rs @@ -220,14 +220,14 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> | MutatingUseContext::SetDiscriminant | MutatingUseContext::AsmOutput | MutatingUseContext::Borrow - | MutatingUseContext::AddressOf + | MutatingUseContext::RawBorrow | MutatingUseContext::Projection, ) | PlaceContext::NonMutatingUse( NonMutatingUseContext::Inspect | NonMutatingUseContext::SharedBorrow | NonMutatingUseContext::FakeBorrow - | NonMutatingUseContext::AddressOf + | NonMutatingUseContext::RawBorrow | NonMutatingUseContext::Projection, ) => { self.locals[local] = LocalKind::Memory; diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index 3c2c29ac7f7d2..d94c6f8ddcec3 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -584,7 +584,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { mir::Rvalue::CopyForDeref(place) => { self.codegen_operand(bx, &mir::Operand::Copy(place)) } - mir::Rvalue::AddressOf(mutability, place) => { + mir::Rvalue::RawPtr(mutability, place) => { let mk_ptr = move |tcx: TyCtxt<'tcx>, ty: Ty<'tcx>| Ty::new_ptr(tcx, ty, mutability); self.codegen_place_to_pointer(bx, place, mk_ptr) @@ -813,7 +813,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { cg_value.len(bx.cx()) } - /// Codegen an `Rvalue::AddressOf` or `Rvalue::Ref` + /// Codegen an `Rvalue::RawPtr` or `Rvalue::Ref` fn codegen_place_to_pointer( &mut self, bx: &mut Bx, @@ -1085,7 +1085,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } mir::Rvalue::Ref(..) | mir::Rvalue::CopyForDeref(..) | - mir::Rvalue::AddressOf(..) | + mir::Rvalue::RawPtr(..) | mir::Rvalue::Len(..) | mir::Rvalue::Cast(..) | // (*) mir::Rvalue::ShallowInitBox(..) | // (*) diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index 32a9247bcc70a..86a5afa65ba87 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -431,13 +431,13 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { return; } } - Rvalue::AddressOf(mutbl, place) => { + Rvalue::RawPtr(mutbl, place) => { if let Some(reborrowed_place_ref) = place_as_reborrow(self.tcx, self.body, place) { let ctx = match mutbl { Mutability::Not => { - PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) + PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) } - Mutability::Mut => PlaceContext::MutatingUse(MutatingUseContext::AddressOf), + Mutability::Mut => PlaceContext::MutatingUse(MutatingUseContext::RawBorrow), }; self.visit_local(reborrowed_place_ref.local, ctx, location); self.visit_projection(reborrowed_place_ref, ctx, location); @@ -472,7 +472,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { } Rvalue::Ref(_, BorrowKind::Mut { .. }, place) - | Rvalue::AddressOf(Mutability::Mut, place) => { + | Rvalue::RawPtr(Mutability::Mut, place) => { // Inside mutable statics, we allow arbitrary mutable references. // We've allowed `static mut FOO = &mut [elements];` for a long time (the exact // reasons why are lost to history), and there is no reason to restrict that to @@ -493,7 +493,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { } Rvalue::Ref(_, BorrowKind::Shared | BorrowKind::Fake(_), place) - | Rvalue::AddressOf(Mutability::Not, place) => { + | Rvalue::RawPtr(Mutability::Not, place) => { let borrowed_place_has_mut_interior = qualifs::in_place::( self.ccx, &mut |local| self.qualifs.has_mut_interior(self.ccx, local, location), diff --git a/compiler/rustc_const_eval/src/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/check_consts/qualifs.rs index c0f2d113c7e31..c566dc7fa844d 100644 --- a/compiler/rustc_const_eval/src/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/check_consts/qualifs.rs @@ -291,7 +291,7 @@ where in_operand::(cx, in_local, lhs) || in_operand::(cx, in_local, rhs) } - Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { + Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => { // Special-case reborrows to be more like a copy of the reference. if let Some((place_base, ProjectionElem::Deref)) = place.as_ref().last_projection() { let base_ty = place_base.ty(cx.body, cx.tcx).ty; diff --git a/compiler/rustc_const_eval/src/check_consts/resolver.rs b/compiler/rustc_const_eval/src/check_consts/resolver.rs index ea3a5264357c9..681184f7fbcde 100644 --- a/compiler/rustc_const_eval/src/check_consts/resolver.rs +++ b/compiler/rustc_const_eval/src/check_consts/resolver.rs @@ -96,7 +96,7 @@ where } fn address_of_allows_mutation(&self) -> bool { - // Exact set of permissions granted by AddressOf is undecided. Conservatively assume that + // Exact set of permissions granted by RawPtr is undecided. Conservatively assume that // it might allow mutation until resolution of #56604. true } @@ -170,7 +170,7 @@ where self.super_rvalue(rvalue, location); match rvalue { - mir::Rvalue::AddressOf(_mt, borrowed_place) => { + mir::Rvalue::RawPtr(_mt, borrowed_place) => { if !borrowed_place.is_indirect() && self.address_of_allows_mutation() { let place_ty = borrowed_place.ty(self.ccx.body, self.ccx.tcx).ty; if Q::in_any_value_of_ty(self.ccx, place_ty) { diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index aaee6f6d247f8..70cfba1922c6e 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -234,7 +234,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { self.write_immediate(*val, &dest)?; } - AddressOf(_, place) => { + RawPtr(_, place) => { // Figure out whether this is an addr_of of an already raw place. let place_base_raw = if place.is_indirect_first_projection() { let ty = self.frame().body.local_decls[place.local].ty; diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 7cd97166ed1e9..03a76d44cc987 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -967,7 +967,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { // need to special-case obtaining a raw pointer // from a region pointer to a vector. - // Coerce to a raw pointer so that we generate AddressOf in MIR. + // Coerce to a raw pointer so that we generate RawPtr in MIR. let array_ptr_type = Ty::new_ptr(fcx.tcx, m_expr.ty, m_expr.mutbl); fcx.coerce(self.expr, self.expr_ty, array_ptr_type, AllowTwoPhase::No, None) .unwrap_or_else(|_| { diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 5dd0e69cf1fe6..212eda666ca05 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1038,7 +1038,7 @@ impl<'tcx> Debug for Rvalue<'tcx> { CopyForDeref(ref place) => write!(fmt, "deref_copy {place:#?}"), - AddressOf(mutability, ref place) => { + RawPtr(mutability, ref place) => { write!(fmt, "&raw {mut_str} {place:?}", mut_str = mutability.ptr_str()) } diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index 3009ca8d8097a..bc7dfa6205e71 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -423,7 +423,7 @@ impl<'tcx> Rvalue<'tcx> { | Rvalue::Repeat(_, _) | Rvalue::Ref(_, _, _) | Rvalue::ThreadLocalRef(_) - | Rvalue::AddressOf(_, _) + | Rvalue::RawPtr(_, _) | Rvalue::Len(_) | Rvalue::Cast( CastKind::IntToInt diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 1119ff6ff3d60..51b4154ddab78 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -1293,14 +1293,14 @@ pub enum Rvalue<'tcx> { /// nature of this operation? ThreadLocalRef(DefId), - /// Creates a pointer with the indicated mutability to the place. + /// Creates a raw pointer with the indicated mutability to the place. /// - /// This is generated by pointer casts like `&v as *const _` or raw address of expressions like - /// `&raw v` or `addr_of!(v)`. + /// This is generated by pointer casts like `&v as *const _` or raw borrow expressions like + /// `&raw const v`. /// /// Like with references, the semantics of this operation are heavily dependent on the aliasing /// model. - AddressOf(Mutability, Place<'tcx>), + RawPtr(Mutability, Place<'tcx>), /// Yields the length of the place, as a `usize`. /// diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index 1075344dc00f3..8d57d0d865469 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -170,7 +170,7 @@ impl<'tcx> Rvalue<'tcx> { let place_ty = place.ty(local_decls, tcx).ty; Ty::new_ref(tcx, reg, place_ty, bk.to_mutbl_lossy()) } - Rvalue::AddressOf(mutability, ref place) => { + Rvalue::RawPtr(mutability, ref place) => { let place_ty = place.ty(local_decls, tcx).ty; Ty::new_ptr(tcx, place_ty, mutability) } diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 3921176873c81..bfb129495ce83 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -682,13 +682,13 @@ macro_rules! make_mir_visitor { ); } - Rvalue::AddressOf(m, path) => { + Rvalue::RawPtr(m, path) => { let ctx = match m { Mutability::Mut => PlaceContext::MutatingUse( - MutatingUseContext::AddressOf + MutatingUseContext::RawBorrow ), Mutability::Not => PlaceContext::NonMutatingUse( - NonMutatingUseContext::AddressOf + NonMutatingUseContext::RawBorrow ), }; self.visit_place(path, ctx, location); @@ -1299,8 +1299,8 @@ pub enum NonMutatingUseContext { /// FIXME: do we need to distinguish shallow and deep fake borrows? In fact, do we need to /// distinguish fake and normal deep borrows? FakeBorrow, - /// AddressOf for *const pointer. - AddressOf, + /// `&raw const`. + RawBorrow, /// PlaceMention statement. /// /// This statement is executed as a check that the `Place` is live without reading from it, @@ -1333,8 +1333,8 @@ pub enum MutatingUseContext { Drop, /// Mutable borrow. Borrow, - /// AddressOf for *mut pointer. - AddressOf, + /// `&raw mut`. + RawBorrow, /// Used as base for another place, e.g., `x` in `x.y`. Could potentially mutate the place. /// For example, the projection `x.y` is marked as a mutation in these cases: /// ```ignore (illustrative) @@ -1386,8 +1386,8 @@ impl PlaceContext { pub fn is_address_of(&self) -> bool { matches!( self, - PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) - | PlaceContext::MutatingUse(MutatingUseContext::AddressOf) + PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) + | PlaceContext::MutatingUse(MutatingUseContext::RawBorrow) ) } diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index f2ea32275f9b1..aca1390935ef1 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -407,7 +407,7 @@ pub enum ExprKind<'tcx> { arg: ExprId, }, /// A `&raw [const|mut] $place_expr` raw borrow resulting in type `*[const|mut] T`. - AddressOf { + RawBorrow { mutability: hir::Mutability, arg: ExprId, }, diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs index f198881043739..e246ecebbec0b 100644 --- a/compiler/rustc_middle/src/thir/visit.rs +++ b/compiler/rustc_middle/src/thir/visit.rs @@ -92,7 +92,7 @@ pub fn walk_expr<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>( } VarRef { id: _ } | UpvarRef { closure_def_id: _, var_hir_id: _ } => {} Borrow { arg, borrow_kind: _ } => visitor.visit_expr(&visitor.thir()[arg]), - AddressOf { arg, mutability: _ } => visitor.visit_expr(&visitor.thir()[arg]), + RawBorrow { arg, mutability: _ } => visitor.visit_expr(&visitor.thir()[arg]), Break { value, label: _ } => { if let Some(value) = value { visitor.visit_expr(&visitor.thir()[value]) diff --git a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs index 56896d945e5f3..0b13ceb574d04 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs +++ b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs @@ -244,8 +244,8 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> { ExprKind::Borrow { borrow_kind, arg } => Ok( Rvalue::Ref(self.tcx.lifetimes.re_erased, *borrow_kind, self.parse_place(*arg)?) ), - ExprKind::AddressOf { mutability, arg } => Ok( - Rvalue::AddressOf(*mutability, self.parse_place(*arg)?) + ExprKind::RawBorrow { mutability, arg } => Ok( + Rvalue::RawPtr(*mutability, self.parse_place(*arg)?) ), ExprKind::Binary { op, lhs, rhs } => Ok( Rvalue::BinaryOp(*op, Box::new((self.parse_operand(*lhs)?, self.parse_operand(*rhs)?))) diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index b80d9de70c8da..07784982631f8 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -542,7 +542,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | ExprKind::PointerCoercion { .. } | ExprKind::Repeat { .. } | ExprKind::Borrow { .. } - | ExprKind::AddressOf { .. } + | ExprKind::RawBorrow { .. } | ExprKind::Match { .. } | ExprKind::If { .. } | ExprKind::Loop { .. } diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 379d2140c09c5..0c9571da3cf7f 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -512,7 +512,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | ExprKind::NeverToAny { .. } | ExprKind::Use { .. } | ExprKind::Borrow { .. } - | ExprKind::AddressOf { .. } + | ExprKind::RawBorrow { .. } | ExprKind::Adt { .. } | ExprKind::Loop { .. } | ExprKind::LogicalOp { .. } diff --git a/compiler/rustc_mir_build/src/build/expr/category.rs b/compiler/rustc_mir_build/src/build/expr/category.rs index e07ba6b6e9383..e0349e3e3f668 100644 --- a/compiler/rustc_mir_build/src/build/expr/category.rs +++ b/compiler/rustc_mir_build/src/build/expr/category.rs @@ -51,7 +51,7 @@ impl Category { | ExprKind::Use { .. } | ExprKind::Adt { .. } | ExprKind::Borrow { .. } - | ExprKind::AddressOf { .. } + | ExprKind::RawBorrow { .. } | ExprKind::Yield { .. } | ExprKind::Call { .. } | ExprKind::InlineAsm { .. } => Some(Category::Rvalue(RvalueFunc::Into)), diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index 01b32b8e05e49..1c805ed20cc36 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -303,12 +303,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { this.cfg.push_assign(block, source_info, destination, borrow); block.unit() } - ExprKind::AddressOf { mutability, arg } => { + ExprKind::RawBorrow { mutability, arg } => { let place = match mutability { hir::Mutability::Not => this.as_read_only_place(block, arg), hir::Mutability::Mut => this.as_place(block, arg), }; - let address_of = Rvalue::AddressOf(mutability, unpack!(block = place)); + let address_of = Rvalue::RawPtr(mutability, unpack!(block = place)); this.cfg.push_assign(block, source_info, destination, address_of); block.unit() } diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 9b85ad0ad0891..e4e5844d2ef8e 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -397,7 +397,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { | ExprKind::Scope { .. } | ExprKind::Cast { .. } => {} - ExprKind::AddressOf { .. } + ExprKind::RawBorrow { .. } | ExprKind::Adt { .. } | ExprKind::Array { .. } | ExprKind::Binary { .. } @@ -498,7 +498,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { } } } - ExprKind::AddressOf { arg, .. } => { + ExprKind::RawBorrow { arg, .. } => { if let ExprKind::Scope { value: arg, .. } = self.thir[arg].kind // THIR desugars UNSAFE_STATIC into *UNSAFE_STATIC_REF, where // UNSAFE_STATIC_REF holds the addr of the UNSAFE_STATIC, so: take two steps diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index d4de5fac96eb0..2cbaed2cc6258 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -143,7 +143,7 @@ impl<'tcx> Cx<'tcx> { arg: self.thir.exprs.push(expr), }, Adjust::Borrow(AutoBorrow::RawPtr(mutability)) => { - ExprKind::AddressOf { mutability, arg: self.thir.exprs.push(expr) } + ExprKind::RawBorrow { mutability, arg: self.thir.exprs.push(expr) } } Adjust::DynStar => ExprKind::Cast { source: self.thir.exprs.push(expr) }, }; @@ -396,7 +396,7 @@ impl<'tcx> Cx<'tcx> { } hir::ExprKind::AddrOf(hir::BorrowKind::Raw, mutability, arg) => { - ExprKind::AddressOf { mutability, arg: self.mirror_expr(arg) } + ExprKind::RawBorrow { mutability, arg: self.mirror_expr(arg) } } hir::ExprKind::Block(blk, _) => ExprKind::Block { block: self.mirror_block(blk) }, diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 85b9dacb1293c..bc1acd51c6911 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -325,7 +325,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> { Assign { .. } | AssignOp { .. } | InlineAsm { .. } | Let { .. } => true, // These evaluate to a value. - AddressOf { .. } + RawBorrow { .. } | Adt { .. } | Array { .. } | Binary { .. } diff --git a/compiler/rustc_mir_build/src/thir/print.rs b/compiler/rustc_mir_build/src/thir/print.rs index 2d4b39e7b08f3..ce7774f594882 100644 --- a/compiler/rustc_mir_build/src/thir/print.rs +++ b/compiler/rustc_mir_build/src/thir/print.rs @@ -379,8 +379,8 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> { self.print_expr(*arg, depth_lvl + 2); print_indented!(self, ")", depth_lvl); } - AddressOf { mutability, arg } => { - print_indented!(self, "AddressOf {", depth_lvl); + RawBorrow { mutability, arg } => { + print_indented!(self, "RawBorrow {", depth_lvl); print_indented!(self, format!("mutability: {:?}", mutability), depth_lvl + 1); print_indented!(self, "arg:", depth_lvl + 1); self.print_expr(*arg, depth_lvl + 2); diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs index 2ec3b53bc9814..d7e738b8829e0 100644 --- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs +++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs @@ -703,7 +703,7 @@ where statements: vec![ self.assign( ptr, - Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)), + Rvalue::RawPtr(Mutability::Mut, tcx.mk_place_index(self.place, cur)), ), self.assign( cur.into(), diff --git a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs index 885fdd0d58bea..e8e78fb8a89ee 100644 --- a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs +++ b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs @@ -94,7 +94,7 @@ where match rvalue { // We ignore fake borrows as these get removed after analysis and shouldn't effect // the layout of generators. - Rvalue::AddressOf(_, borrowed_place) + Rvalue::RawPtr(_, borrowed_place) | Rvalue::Ref(_, BorrowKind::Mut { .. } | BorrowKind::Shared, borrowed_place) => { if !borrowed_place.is_indirect() { self.trans.gen_(borrowed_place.local); diff --git a/compiler/rustc_mir_dataflow/src/impls/initialized.rs b/compiler/rustc_mir_dataflow/src/impls/initialized.rs index 7822fb17f7298..ddfd0739358d1 100644 --- a/compiler/rustc_mir_dataflow/src/impls/initialized.rs +++ b/compiler/rustc_mir_dataflow/src/impls/initialized.rs @@ -351,7 +351,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> { && let Some((_, rvalue)) = statement.kind.as_assign() && let mir::Rvalue::Ref(_, mir::BorrowKind::Mut { .. }, place) // FIXME: Does `&raw const foo` allow mutation? See #90413. - | mir::Rvalue::AddressOf(_, place) = rvalue + | mir::Rvalue::RawPtr(_, place) = rvalue && let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref()) { on_all_children_bits(self.move_data(), mpi, |child| { diff --git a/compiler/rustc_mir_dataflow/src/impls/liveness.rs b/compiler/rustc_mir_dataflow/src/impls/liveness.rs index 48bdb1316012f..24a4b32ceb7c4 100644 --- a/compiler/rustc_mir_dataflow/src/impls/liveness.rs +++ b/compiler/rustc_mir_dataflow/src/impls/liveness.rs @@ -189,13 +189,13 @@ impl DefUse { // All other contexts are uses... PlaceContext::MutatingUse( - MutatingUseContext::AddressOf + MutatingUseContext::RawBorrow | MutatingUseContext::Borrow | MutatingUseContext::Drop | MutatingUseContext::Retag, ) | PlaceContext::NonMutatingUse( - NonMutatingUseContext::AddressOf + NonMutatingUseContext::RawBorrow | NonMutatingUseContext::Copy | NonMutatingUseContext::Inspect | NonMutatingUseContext::Move diff --git a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs index 86091379f5a92..14390723ba4b6 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs @@ -432,7 +432,7 @@ impl<'b, 'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> Gatherer<'b, 'a, 'tcx, F> { } Rvalue::CopyForDeref(..) => unreachable!(), Rvalue::Ref(..) - | Rvalue::AddressOf(..) + | Rvalue::RawPtr(..) | Rvalue::Discriminant(..) | Rvalue::Len(..) | Rvalue::NullaryOp( diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 139fd592f69a3..2b20a35b61e29 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -177,7 +177,7 @@ pub trait ValueAnalysis<'tcx> { match rvalue { Rvalue::Use(operand) => self.handle_operand(operand, state), Rvalue::CopyForDeref(place) => self.handle_operand(&Operand::Copy(*place), state), - Rvalue::Ref(..) | Rvalue::AddressOf(..) => { + Rvalue::Ref(..) | Rvalue::RawPtr(..) => { // We don't track such places. ValueOrPlace::TOP } diff --git a/compiler/rustc_mir_transform/src/add_retag.rs b/compiler/rustc_mir_transform/src/add_retag.rs index 16977a63c598e..12a68790374e5 100644 --- a/compiler/rustc_mir_transform/src/add_retag.rs +++ b/compiler/rustc_mir_transform/src/add_retag.rs @@ -131,9 +131,9 @@ impl<'tcx> MirPass<'tcx> for AddRetag { // Ptr-creating operations already do their own internal retagging, no // need to also add a retag statement. // *Except* if we are deref'ing a Box, because those get desugared to directly working - // with the inner raw pointer! That's relevant for `AddressOf` as Miri otherwise makes it + // with the inner raw pointer! That's relevant for `RawPtr` as Miri otherwise makes it // a NOP when the original pointer is already raw. - Rvalue::AddressOf(_mutbl, place) => { + Rvalue::RawPtr(_mutbl, place) => { // Using `is_box_global` here is a bit sketchy: if this code is // generic over the allocator, we'll not add a retag! This is a hack // to make Stacked Borrows compatible with custom allocator code. diff --git a/compiler/rustc_mir_transform/src/check_alignment.rs b/compiler/rustc_mir_transform/src/check_alignment.rs index a1dbd7dc50ec7..5dfdcfc8b9446 100644 --- a/compiler/rustc_mir_transform/src/check_alignment.rs +++ b/compiler/rustc_mir_transform/src/check_alignment.rs @@ -71,7 +71,7 @@ struct PointerFinder<'tcx, 'a> { impl<'tcx, 'a> Visitor<'tcx> for PointerFinder<'tcx, 'a> { fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) { // We want to only check reads and writes to Places, so we specifically exclude - // Borrows and AddressOf. + // Borrow and RawBorrow. match context { PlaceContext::MutatingUse( MutatingUseContext::Store diff --git a/compiler/rustc_mir_transform/src/deduce_param_attrs.rs b/compiler/rustc_mir_transform/src/deduce_param_attrs.rs index 370e930b74098..71af099199ea9 100644 --- a/compiler/rustc_mir_transform/src/deduce_param_attrs.rs +++ b/compiler/rustc_mir_transform/src/deduce_param_attrs.rs @@ -40,7 +40,7 @@ impl<'tcx> Visitor<'tcx> for DeduceReadOnly { // This is a mutation, so mark it as such. true } - PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) => { + PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) => { // Whether mutating though a `&raw const` is allowed is still undecided, so we // disable any sketchy `readonly` optimizations for now. // But we only need to do this if the pointer would point into the argument. diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs index 054cdbc6bad9f..ed924761892c7 100644 --- a/compiler/rustc_mir_transform/src/dest_prop.rs +++ b/compiler/rustc_mir_transform/src/dest_prop.rs @@ -576,7 +576,7 @@ impl WriteInfo { Rvalue::ThreadLocalRef(_) | Rvalue::NullaryOp(_, _) | Rvalue::Ref(_, _, _) - | Rvalue::AddressOf(_, _) + | Rvalue::RawPtr(_, _) | Rvalue::Len(_) | Rvalue::Discriminant(_) | Rvalue::CopyForDeref(_) => (), diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index e16911d79c378..90e3ba26a438e 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -45,7 +45,7 @@ //! //! # Handling of references //! -//! We handle references by assigning a different "provenance" index to each Ref/AddressOf rvalue. +//! We handle references by assigning a different "provenance" index to each Ref/RawPtr rvalue. //! This ensure that we do not spuriously merge borrows that should not be merged. Meanwhile, we //! consider all the derefs of an immutable reference to a freeze type to give the same value: //! ```ignore (MIR) @@ -832,7 +832,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { self.simplify_place_projection(place, location); return self.new_pointer(*place, AddressKind::Ref(borrow_kind)); } - Rvalue::AddressOf(mutbl, ref mut place) => { + Rvalue::RawPtr(mutbl, ref mut place) => { self.simplify_place_projection(place, location); return self.new_pointer(*place, AddressKind::Address(mutbl)); } diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 1589653968c2e..3ec553d0ba0c5 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -141,7 +141,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> { /// Transform `&(*a)` ==> `a`. fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) { - if let Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) = rvalue { + if let Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) = rvalue { if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() { if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty { return; diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index 7202cc2d0427e..7eed47cf2398e 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -419,8 +419,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { } // Do not try creating references (#67862) - Rvalue::AddressOf(_, place) | Rvalue::Ref(_, _, place) => { - trace!("skipping AddressOf | Ref for {:?}", place); + Rvalue::RawPtr(_, place) | Rvalue::Ref(_, _, place) => { + trace!("skipping RawPtr | Ref for {:?}", place); // This may be creating mutable references or immutable references to cells. // If that happens, the pointed to value could be mutated via that reference. @@ -616,7 +616,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { ImmTy::from_scalar(Scalar::from_target_usize(len, self), layout).into() } - Ref(..) | AddressOf(..) => return None, + Ref(..) | RawPtr(..) => return None, NullaryOp(ref null_op, ty) => { let op_layout = self.use_ecx(|this| this.ecx.layout_of(ty))?; @@ -969,9 +969,9 @@ impl<'tcx> Visitor<'tcx> for CanConstProp { // mutation. | NonMutatingUse(NonMutatingUseContext::SharedBorrow) | NonMutatingUse(NonMutatingUseContext::FakeBorrow) - | NonMutatingUse(NonMutatingUseContext::AddressOf) + | NonMutatingUse(NonMutatingUseContext::RawBorrow) | MutatingUse(MutatingUseContext::Borrow) - | MutatingUse(MutatingUseContext::AddressOf) => { + | MutatingUse(MutatingUseContext::RawBorrow) => { trace!("local {:?} can't be propagated because it's used: {:?}", local, context); self.can_const_prop[local] = ConstPropMode::NoPropagation; } diff --git a/compiler/rustc_mir_transform/src/large_enums.rs b/compiler/rustc_mir_transform/src/large_enums.rs index e407929c9a7fd..cbc3169f2f10a 100644 --- a/compiler/rustc_mir_transform/src/large_enums.rs +++ b/compiler/rustc_mir_transform/src/large_enums.rs @@ -214,7 +214,7 @@ impl EnumSizeOpt { source_info, kind: StatementKind::Assign(Box::new(( dst, - Rvalue::AddressOf(Mutability::Mut, *lhs), + Rvalue::RawPtr(Mutability::Mut, *lhs), ))), }; @@ -238,7 +238,7 @@ impl EnumSizeOpt { source_info, kind: StatementKind::Assign(Box::new(( src, - Rvalue::AddressOf(Mutability::Not, *rhs), + Rvalue::RawPtr(Mutability::Not, *rhs), ))), }; diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index 48a3266ae6f0d..6e84914ef972c 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -551,7 +551,7 @@ impl<'tcx> Validator<'_, 'tcx> { self.validate_operand(rhs)?; } - Rvalue::AddressOf(_, place) => { + Rvalue::RawPtr(_, place) => { // We accept `&raw *`, i.e., raw reborrows -- creating a raw pointer is // no problem, only using it is. if let Some((place_base, ProjectionElem::Deref)) = place.as_ref().last_projection() diff --git a/compiler/rustc_mir_transform/src/ref_prop.rs b/compiler/rustc_mir_transform/src/ref_prop.rs index 76e65099e9028..973a191d786e1 100644 --- a/compiler/rustc_mir_transform/src/ref_prop.rs +++ b/compiler/rustc_mir_transform/src/ref_prop.rs @@ -227,7 +227,7 @@ fn compute_replacement<'tcx>( } } } - Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { + Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => { let mut place = *place; // Try to see through `place` in order to collapse reborrow chains. if place.projection.first() == Some(&PlaceElem::Deref) diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs index ea4f5fca59e67..9c3f903e0eab7 100644 --- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs +++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs @@ -343,7 +343,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> { .tcx .mk_place_elems(&[PlaceElem::Deref, PlaceElem::Field(field, field_ty)]), }; - self.put_temp_rvalue(Rvalue::AddressOf(Mutability::Mut, place)) + self.put_temp_rvalue(Rvalue::RawPtr(Mutability::Mut, place)) } /// If given Self is an enum puts `to_drop: *mut FieldTy` on top of @@ -363,7 +363,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> { PlaceElem::Field(field, field_ty), ]), }; - self.put_temp_rvalue(Rvalue::AddressOf(Mutability::Mut, place)) + self.put_temp_rvalue(Rvalue::RawPtr(Mutability::Mut, place)) } /// If given Self is an enum puts `to_drop: *mut FieldTy` on top of diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs index fb870425f6ef8..76591f526250c 100644 --- a/compiler/rustc_mir_transform/src/ssa.rs +++ b/compiler/rustc_mir_transform/src/ssa.rs @@ -2,9 +2,9 @@ //! 1/ They are only assigned-to once, either as a function parameter, or in an assign statement; //! 2/ This single assignment dominates all uses; //! -//! As we do not track indirect assignments, a local that has its address taken (either by -//! AddressOf or by borrowing) is considered non-SSA. However, it is UB to modify through an -//! immutable borrow of a `Freeze` local. Those can still be considered to be SSA. +//! As we do not track indirect assignments, a local that has its address taken (via a borrow or raw +//! borrow operator) is considered non-SSA. However, it is UB to modify through an immutable borrow +//! of a `Freeze` local. Those can still be considered to be SSA. use rustc_data_structures::graph::dominators::Dominators; use rustc_index::bit_set::BitSet; @@ -262,7 +262,7 @@ impl<'tcx> Visitor<'tcx> for SsaVisitor<'tcx, '_> { PlaceContext::MutatingUse(MutatingUseContext::Projection) | PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) => bug!(), // Anything can happen with raw pointers, so remove them. - PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) + PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) | PlaceContext::MutatingUse(_) => { self.assignments[local] = Set1::Many; } diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 491ae1c0d083f..36908036796c1 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -1345,7 +1345,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } Rvalue::Repeat(_, _) | Rvalue::ThreadLocalRef(_) - | Rvalue::AddressOf(_, _) + | Rvalue::RawPtr(_, _) | Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::UbChecks, _) | Rvalue::Discriminant(_) => {} } diff --git a/compiler/rustc_smir/src/rustc_smir/convert/mir.rs b/compiler/rustc_smir/src/rustc_smir/convert/mir.rs index da705e6f9598a..c442ca861d35b 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/mir.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/mir.rs @@ -174,7 +174,7 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> { ThreadLocalRef(def_id) => { stable_mir::mir::Rvalue::ThreadLocalRef(tables.crate_item(*def_id)) } - AddressOf(mutability, place) => { + RawPtr(mutability, place) => { stable_mir::mir::Rvalue::AddressOf(mutability.stable(tables), place.stable(tables)) } Len(place) => stable_mir::mir::Rvalue::Len(place.stable(tables)), diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index 2492688352342..4ded935b801d3 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -192,7 +192,7 @@ fn recurse_build<'tcx>( ExprKind::Borrow { arg, .. } => { let arg_node = &body.exprs[*arg]; - // Skip reborrows for now until we allow Deref/Borrow/AddressOf + // Skip reborrows for now until we allow Deref/Borrow/RawBorrow // expressions. // FIXME(generic_const_exprs): Verify/explain why this is sound if let ExprKind::Deref { arg } = arg_node.kind { @@ -202,7 +202,7 @@ fn recurse_build<'tcx>( } } // FIXME(generic_const_exprs): We may want to support these. - ExprKind::AddressOf { .. } | ExprKind::Deref { .. } => maybe_supported_error( + ExprKind::RawBorrow { .. } | ExprKind::Deref { .. } => maybe_supported_error( GenericConstantTooComplexSub::AddressAndDerefNotSupported(node.span), )?, ExprKind::Repeat { .. } | ExprKind::Array { .. } => { @@ -343,7 +343,7 @@ impl<'a, 'tcx> IsThirPolymorphic<'a, 'tcx> { | thir::ExprKind::VarRef { .. } | thir::ExprKind::UpvarRef { .. } | thir::ExprKind::Borrow { .. } - | thir::ExprKind::AddressOf { .. } + | thir::ExprKind::RawBorrow { .. } | thir::ExprKind::Break { .. } | thir::ExprKind::Continue { .. } | thir::ExprKind::Return { .. } diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 553af913ef9df..95fbf0b2ea20a 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -110,7 +110,7 @@ fn check_rvalue<'tcx>( ) -> McfResult { match rvalue { Rvalue::ThreadLocalRef(_) => Err((span, "cannot access thread local storage in const fn".into())), - Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { + Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => { check_place(tcx, *place, span, body, msrv) }, Rvalue::CopyForDeref(place) => check_place(tcx, *place, span, body, msrv),