Skip to content

Commit 054c76d

Browse files
committed
Revert most of the custom place computation, it was unnecessary.
1 parent 82f1e34 commit 054c76d

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

compiler/rustc_const_eval/src/interpret/terminator.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
538538
// pointer or `dyn Trait` type, but it could be wrapped in newtypes. So recursively
539539
// unwrap those newtypes until we are there.
540540
let mut receiver = args[0].clone();
541-
let receiver = loop {
541+
let receiver_place = loop {
542542
match receiver.layout.ty.kind() {
543-
ty::Dynamic(..) | ty::Ref(..) | ty::RawPtr(..) => break receiver,
543+
ty::Ref(..) | ty::RawPtr(..) => break self.deref_operand(&receiver)?,
544+
ty::Dynamic(.., ty::Dyn) => break receiver.assert_mem_place(), // no immediate unsized values
545+
ty::Dynamic(.., ty::DynStar) => {
546+
// Not clear how to handle this, so far we assume the receiver is always a pointer.
547+
span_bug!(
548+
self.cur_span(),
549+
"by-value calls on a `dyn*`... are those a thing?"
550+
);
551+
}
544552
_ => {
545553
// Not there yet, search for the only non-ZST field.
546554
let mut non_zst_field = None;
@@ -568,19 +576,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
568576
};
569577

570578
// Obtain the underlying trait we are working on, and the adjusted receiver argument.
571-
let recv_ty = receiver.layout.ty;
572-
let receiver_place = match recv_ty.kind() {
573-
ty::Ref(..) | ty::RawPtr(..) => self.deref_operand(&receiver)?,
574-
ty::Dynamic(_, _, ty::Dyn) => receiver.assert_mem_place(), // unsized (`dyn`) cannot be immediate
575-
ty::Dynamic(_, _, ty::DynStar) => {
576-
// Not clear how to handle this, so far we assume the receiver is always a pointer.
577-
span_bug!(
578-
self.cur_span(),
579-
"by-value calls on a `dyn*`... are those a thing?"
580-
);
581-
}
582-
_ => bug!(),
583-
};
584579
let (vptr, dyn_ty, adjusted_receiver) = if let ty::Dynamic(data, _, ty::DynStar) =
585580
receiver_place.layout.ty.kind()
586581
{

0 commit comments

Comments
 (0)