Skip to content

Commit bcf8015

Browse files
committed
remove retag_box_to_raw, it is no longer needed
1 parent c96fa5e commit bcf8015

File tree

7 files changed

+1
-71
lines changed

7 files changed

+1
-71
lines changed

compiler/rustc_hir_analysis/src/check/intrinsic.rs

-4
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,6 @@ pub fn check_intrinsic_type(
658658
sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)),
659659
sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)),
660660

661-
sym::retag_box_to_raw => {
662-
(2, 0, vec![Ty::new_mut_ptr(tcx, param(0))], Ty::new_mut_ptr(tcx, param(0)))
663-
}
664-
665661
other => {
666662
tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other });
667663
return;

compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,6 @@ symbols! {
14631463
residual,
14641464
result,
14651465
resume,
1466-
retag_box_to_raw,
14671466
return_position_impl_trait_in_trait,
14681467
return_type_notation,
14691468
rhs,

library/core/src/intrinsics.rs

-13
Original file line numberDiff line numberDiff line change
@@ -2709,19 +2709,6 @@ pub unsafe fn vtable_size(_ptr: *const ()) -> usize {
27092709
unreachable!()
27102710
}
27112711

2712-
/// Retag a box pointer as part of casting it to a raw pointer. This is the `Box` equivalent of
2713-
/// `(x: &mut T) as *mut T`. The input pointer must be the pointer of a `Box` (passed as raw pointer
2714-
/// to avoid all questions around move semantics and custom allocators), and `A` must be the `Box`'s
2715-
/// allocator.
2716-
#[unstable(feature = "core_intrinsics", issue = "none")]
2717-
#[rustc_nounwind]
2718-
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2719-
#[cfg_attr(bootstrap, inline)]
2720-
pub unsafe fn retag_box_to_raw<T: ?Sized, A>(ptr: *mut T) -> *mut T {
2721-
// Miri needs to adjust the provenance, but for regular codegen this is not needed
2722-
ptr
2723-
}
2724-
27252712
// Some functions are defined here because they accidentally got made
27262713
// available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>.
27272714
// (`transmute` also falls into this category, but it cannot be wrapped due to the

src/tools/miri/src/borrow_tracker/mod.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::num::NonZero;
55
use smallvec::SmallVec;
66

77
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
8-
use rustc_middle::{mir::RetagKind, ty::Ty};
8+
use rustc_middle::mir::RetagKind;
99
use rustc_target::abi::Size;
1010

1111
use crate::*;
@@ -291,19 +291,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
291291
}
292292
}
293293

294-
fn retag_box_to_raw(
295-
&mut self,
296-
val: &ImmTy<'tcx, Provenance>,
297-
alloc_ty: Ty<'tcx>,
298-
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
299-
let this = self.eval_context_mut();
300-
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
301-
match method {
302-
BorrowTrackerMethod::StackedBorrows => this.sb_retag_box_to_raw(val, alloc_ty),
303-
BorrowTrackerMethod::TreeBorrows => this.tb_retag_box_to_raw(val, alloc_ty),
304-
}
305-
}
306-
307294
fn retag_place_contents(
308295
&mut self,
309296
kind: RetagKind,

src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs

-18
Original file line numberDiff line numberDiff line change
@@ -865,24 +865,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
865865
this.sb_retag_reference(val, new_perm, RetagInfo { cause, in_field: false })
866866
}
867867

868-
fn sb_retag_box_to_raw(
869-
&mut self,
870-
val: &ImmTy<'tcx, Provenance>,
871-
alloc_ty: Ty<'tcx>,
872-
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
873-
let this = self.eval_context_mut();
874-
let is_global_alloc = alloc_ty.ty_adt_def().is_some_and(|adt| {
875-
let global_alloc = this.tcx.require_lang_item(rustc_hir::LangItem::GlobalAlloc, None);
876-
adt.did() == global_alloc
877-
});
878-
if is_global_alloc {
879-
// Retag this as-if it was a mutable reference.
880-
this.sb_retag_ptr_value(RetagKind::Raw, val)
881-
} else {
882-
Ok(val.clone())
883-
}
884-
}
885-
886868
fn sb_retag_place_contents(
887869
&mut self,
888870
kind: RetagKind,

src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs

-9
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
392392
}
393393
}
394394

395-
fn tb_retag_box_to_raw(
396-
&mut self,
397-
val: &ImmTy<'tcx, Provenance>,
398-
_alloc_ty: Ty<'tcx>,
399-
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
400-
// Casts to raw pointers are NOPs in Tree Borrows.
401-
Ok(val.clone())
402-
}
403-
404395
/// Retag all pointers that are stored in this place.
405396
fn tb_retag_place_contents(
406397
&mut self,

src/tools/miri/src/shims/intrinsics/mod.rs

-12
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
140140

141141
this.write_pointer(Pointer::new(ptr.provenance, masked_addr), dest)?;
142142
}
143-
"retag_box_to_raw" => {
144-
let [ptr] = check_arg_count(args)?;
145-
let alloc_ty = generic_args[1].expect_ty();
146-
147-
let val = this.read_immediate(ptr)?;
148-
let new_val = if this.machine.borrow_tracker.is_some() {
149-
this.retag_box_to_raw(&val, alloc_ty)?
150-
} else {
151-
val
152-
};
153-
this.write_immediate(*new_val, dest)?;
154-
}
155143

156144
// We want to return either `true` or `false` at random, or else something like
157145
// ```

0 commit comments

Comments
 (0)