diff options
| author | bors <bors@rust-lang.org> | 2022-12-22 17:48:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-22 17:48:43 +0000 |
| commit | cca80b9a81d495f543cdc122fa330c7f68fff3a8 (patch) | |
| tree | fd3758d2b90812aa48579864bd465db68ded874c /compiler/rustc_const_eval/src/interpret | |
| parent | e5e4eef02d443eae5089a330e59a69a4f350db81 (diff) | |
| parent | 0229281d03d92eec1b167377fec1e9978af1f704 (diff) | |
| download | rust-cca80b9a81d495f543cdc122fa330c7f68fff3a8.tar.gz rust-cca80b9a81d495f543cdc122fa330c7f68fff3a8.zip | |
Auto merge of #103957 - JakobDegen:drop-retag, r=RalfJung
Retag as FnEntry on `drop_in_place` This commit changes the mir drop shim to always retag its argument as if it were a `&mut`. cc rust-lang/unsafe-code-guidelines#373
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/terminator.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index 0e7ffcdffc9..550c7a44c41 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -119,11 +119,20 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } Drop { place, target, unwind } => { + let frame = self.frame(); + let ty = place.ty(&frame.body.local_decls, *self.tcx).ty; + let ty = self.subst_from_frame_and_normalize_erasing_regions(frame, ty)?; + let instance = Instance::resolve_drop_in_place(*self.tcx, ty); + if let ty::InstanceDef::DropGlue(_, None) = instance.def { + // This is the branch we enter if and only if the dropped type has no drop glue + // whatsoever. This can happen as a result of monomorphizing a drop of a + // generic. In order to make sure that generic and non-generic code behaves + // roughly the same (and in keeping with Mir semantics) we do nothing here. + self.go_to_block(target); + return Ok(()); + } let place = self.eval_place(place)?; - let ty = place.layout.ty; trace!("TerminatorKind::drop: {:?}, type {}", place, ty); - - let instance = Instance::resolve_drop_in_place(*self.tcx, ty); self.drop_in_place(&place, instance, target, unwind)?; } |
