remove copyforderef from custom_mir

it did not create DerefTemp locals when used, so it was never actually correct.
This commit is contained in:
beepster4096 2025-08-13 18:02:24 -07:00
parent 1bd490113c
commit 2da55cdb2c
5 changed files with 1 additions and 32 deletions

View file

@ -253,7 +253,6 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
Ok(Rvalue::BinaryOp(BinOp::Offset, Box::new((ptr, offset))))
},
@call(mir_ptr_metadata, args) => Ok(Rvalue::UnaryOp(UnOp::PtrMetadata, self.parse_operand(args[0])?)),
@call(mir_copy_for_deref, args) => Ok(Rvalue::CopyForDeref(self.parse_place(args[0])?)),
ExprKind::Borrow { borrow_kind, arg } => Ok(
Rvalue::Ref(self.tcx.lifetimes.re_erased, *borrow_kind, self.parse_place(*arg)?)
),

View file

@ -1423,7 +1423,6 @@ symbols! {
mir_cast_transmute,
mir_cast_unsize,
mir_checked,
mir_copy_for_deref,
mir_debuginfo,
mir_deinit,
mir_discriminant,

View file

@ -233,7 +233,7 @@
//!
//! - Operands implicitly convert to `Use` rvalues.
//! - `&`, `&mut`, `addr_of!`, and `addr_of_mut!` all work to create their associated rvalue.
//! - [`CopyForDeref`], [`CastTransmute`], [`CastPtrToPtr`], [`CastUnsize`], and [`Discriminant`]
//! - [`CastTransmute`], [`CastPtrToPtr`], [`CastUnsize`], and [`Discriminant`]
//! have associated functions.
//! - Unary and binary operations use their normal Rust syntax - `a * b`, `!c`, etc.
//! - The binary operation `Offset` can be created via [`Offset`].
@ -406,7 +406,6 @@ define!(
"mir_ptr_metadata",
fn PtrMetadata<P: ?Sized>(place: *const P) -> <P as ::core::ptr::Pointee>::Metadata
);
define!("mir_copy_for_deref", fn CopyForDeref<T>(place: T) -> T);
define!("mir_retag", fn Retag<T>(place: T));
define!("mir_move", fn Move<T>(place: T) -> T);
define!("mir_static", fn Static<T>(s: T) -> &'static T);

View file

@ -1,12 +0,0 @@
// MIR for `copy_for_deref` after built
fn copy_for_deref(_1: (&i32, i32)) -> i32 {
let mut _0: i32;
let mut _2: &i32;
bb0: {
_2 = deref_copy (_1.0: &i32);
_0 = copy (*_2);
return;
}
}

View file

@ -79,19 +79,6 @@ fn simple_index(a: [i32; 10], b: &[i32]) -> i32 {
}
}
// EMIT_MIR projections.copy_for_deref.built.after.mir
#[custom_mir(dialect = "runtime", phase = "initial")]
fn copy_for_deref(x: (&i32, i32)) -> i32 {
mir! {
let temp: &i32;
{
temp = CopyForDeref(x.0);
RET = *temp;
Return()
}
}
}
fn main() {
assert_eq!(unions(U { a: 5 }), 5);
assert_eq!(tuples((5, 6)), (5, 6));
@ -103,7 +90,4 @@ fn main() {
assert_eq!(o, Some(10));
assert_eq!(simple_index([0; 10], &[0; 10]), 0);
let one = 1;
assert_eq!(copy_for_deref((&one, one)), 1);
}