diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-02-20 14:56:44 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-02-20 14:56:44 +0000 |
| commit | 054c76d6580eb84139cb619c3dff8865828a9fbc (patch) | |
| tree | ac0450df0f2de39fb69e4a84ee69d6639fcaf609 /compiler/rustc_const_eval/src/interpret | |
| parent | 82f1e341a365d8e830ea4decdf7842f627d2b435 (diff) | |
| download | rust-054c76d6580eb84139cb619c3dff8865828a9fbc.tar.gz rust-054c76d6580eb84139cb619c3dff8865828a9fbc.zip | |
Revert most of the custom place computation, it was unnecessary.
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/terminator.rs | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index 151497cc0eb..f1bbdcbe39b 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -538,9 +538,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // pointer or `dyn Trait` type, but it could be wrapped in newtypes. So recursively // unwrap those newtypes until we are there. let mut receiver = args[0].clone(); - let receiver = loop { + let receiver_place = loop { match receiver.layout.ty.kind() { - ty::Dynamic(..) | ty::Ref(..) | ty::RawPtr(..) => break receiver, + ty::Ref(..) | ty::RawPtr(..) => break self.deref_operand(&receiver)?, + ty::Dynamic(.., ty::Dyn) => break receiver.assert_mem_place(), // no immediate unsized values + ty::Dynamic(.., ty::DynStar) => { + // Not clear how to handle this, so far we assume the receiver is always a pointer. + span_bug!( + self.cur_span(), + "by-value calls on a `dyn*`... are those a thing?" + ); + } _ => { // Not there yet, search for the only non-ZST field. let mut non_zst_field = None; @@ -568,19 +576,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { }; // Obtain the underlying trait we are working on, and the adjusted receiver argument. - let recv_ty = receiver.layout.ty; - let receiver_place = match recv_ty.kind() { - ty::Ref(..) | ty::RawPtr(..) => self.deref_operand(&receiver)?, - ty::Dynamic(_, _, ty::Dyn) => receiver.assert_mem_place(), // unsized (`dyn`) cannot be immediate - ty::Dynamic(_, _, ty::DynStar) => { - // Not clear how to handle this, so far we assume the receiver is always a pointer. - span_bug!( - self.cur_span(), - "by-value calls on a `dyn*`... are those a thing?" - ); - } - _ => bug!(), - }; let (vptr, dyn_ty, adjusted_receiver) = if let ty::Dynamic(data, _, ty::DynStar) = receiver_place.layout.ty.kind() { |
