mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
remove retag_box_to_raw, it is no longer needed
This commit is contained in:
parent
c96fa5e143
commit
bcf8015177
@ -658,10 +658,6 @@ pub fn check_intrinsic_type(
|
||||
sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)),
|
||||
sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)),
|
||||
|
||||
sym::retag_box_to_raw => {
|
||||
(2, 0, vec![Ty::new_mut_ptr(tcx, param(0))], Ty::new_mut_ptr(tcx, param(0)))
|
||||
}
|
||||
|
||||
other => {
|
||||
tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other });
|
||||
return;
|
||||
|
@ -1463,7 +1463,6 @@ symbols! {
|
||||
residual,
|
||||
result,
|
||||
resume,
|
||||
retag_box_to_raw,
|
||||
return_position_impl_trait_in_trait,
|
||||
return_type_notation,
|
||||
rhs,
|
||||
|
@ -2709,19 +2709,6 @@ pub unsafe fn vtable_size(_ptr: *const ()) -> usize {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
/// Retag a box pointer as part of casting it to a raw pointer. This is the `Box` equivalent of
|
||||
/// `(x: &mut T) as *mut T`. The input pointer must be the pointer of a `Box` (passed as raw pointer
|
||||
/// to avoid all questions around move semantics and custom allocators), and `A` must be the `Box`'s
|
||||
/// allocator.
|
||||
#[unstable(feature = "core_intrinsics", issue = "none")]
|
||||
#[rustc_nounwind]
|
||||
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
|
||||
#[cfg_attr(bootstrap, inline)]
|
||||
pub unsafe fn retag_box_to_raw<T: ?Sized, A>(ptr: *mut T) -> *mut T {
|
||||
// Miri needs to adjust the provenance, but for regular codegen this is not needed
|
||||
ptr
|
||||
}
|
||||
|
||||
// Some functions are defined here because they accidentally got made
|
||||
// available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>.
|
||||
// (`transmute` also falls into this category, but it cannot be wrapped due to the
|
||||
|
@ -5,7 +5,7 @@ use std::num::NonZero;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_middle::{mir::RetagKind, ty::Ty};
|
||||
use rustc_middle::mir::RetagKind;
|
||||
use rustc_target::abi::Size;
|
||||
|
||||
use crate::*;
|
||||
@ -291,19 +291,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn retag_box_to_raw(
|
||||
&mut self,
|
||||
val: &ImmTy<'tcx, Provenance>,
|
||||
alloc_ty: Ty<'tcx>,
|
||||
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
|
||||
let this = self.eval_context_mut();
|
||||
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
|
||||
match method {
|
||||
BorrowTrackerMethod::StackedBorrows => this.sb_retag_box_to_raw(val, alloc_ty),
|
||||
BorrowTrackerMethod::TreeBorrows => this.tb_retag_box_to_raw(val, alloc_ty),
|
||||
}
|
||||
}
|
||||
|
||||
fn retag_place_contents(
|
||||
&mut self,
|
||||
kind: RetagKind,
|
||||
|
@ -865,24 +865,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
this.sb_retag_reference(val, new_perm, RetagInfo { cause, in_field: false })
|
||||
}
|
||||
|
||||
fn sb_retag_box_to_raw(
|
||||
&mut self,
|
||||
val: &ImmTy<'tcx, Provenance>,
|
||||
alloc_ty: Ty<'tcx>,
|
||||
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
|
||||
let this = self.eval_context_mut();
|
||||
let is_global_alloc = alloc_ty.ty_adt_def().is_some_and(|adt| {
|
||||
let global_alloc = this.tcx.require_lang_item(rustc_hir::LangItem::GlobalAlloc, None);
|
||||
adt.did() == global_alloc
|
||||
});
|
||||
if is_global_alloc {
|
||||
// Retag this as-if it was a mutable reference.
|
||||
this.sb_retag_ptr_value(RetagKind::Raw, val)
|
||||
} else {
|
||||
Ok(val.clone())
|
||||
}
|
||||
}
|
||||
|
||||
fn sb_retag_place_contents(
|
||||
&mut self,
|
||||
kind: RetagKind,
|
||||
|
@ -392,15 +392,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn tb_retag_box_to_raw(
|
||||
&mut self,
|
||||
val: &ImmTy<'tcx, Provenance>,
|
||||
_alloc_ty: Ty<'tcx>,
|
||||
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
|
||||
// Casts to raw pointers are NOPs in Tree Borrows.
|
||||
Ok(val.clone())
|
||||
}
|
||||
|
||||
/// Retag all pointers that are stored in this place.
|
||||
fn tb_retag_place_contents(
|
||||
&mut self,
|
||||
|
@ -140,18 +140,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
|
||||
this.write_pointer(Pointer::new(ptr.provenance, masked_addr), dest)?;
|
||||
}
|
||||
"retag_box_to_raw" => {
|
||||
let [ptr] = check_arg_count(args)?;
|
||||
let alloc_ty = generic_args[1].expect_ty();
|
||||
|
||||
let val = this.read_immediate(ptr)?;
|
||||
let new_val = if this.machine.borrow_tracker.is_some() {
|
||||
this.retag_box_to_raw(&val, alloc_ty)?
|
||||
} else {
|
||||
val
|
||||
};
|
||||
this.write_immediate(*new_val, dest)?;
|
||||
}
|
||||
|
||||
// We want to return either `true` or `false` at random, or else something like
|
||||
// ```
|
||||
|
Loading…
Reference in New Issue
Block a user