From 62f8e6225ce9b71d50decbe53529608a33b97d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Fiala?= Date: Thu, 28 Sep 2023 18:39:56 +0200 Subject: [PATCH] Fix `can_deinit` check --- mir-state-analysis/src/utils/repacker.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mir-state-analysis/src/utils/repacker.rs b/mir-state-analysis/src/utils/repacker.rs index b2b5c60b52e..d9300973593 100644 --- a/mir-state-analysis/src/utils/repacker.rs +++ b/mir-state-analysis/src/utils/repacker.rs @@ -355,7 +355,19 @@ impl<'tcx> Place<'tcx> { } pub fn can_deinit(self, repacker: PlaceRepacker<'_, 'tcx>) -> bool { - !self.projects_shared_ref(repacker) + let mut projects_shared_ref = false; + self.projects_ty( + |typ| { + projects_shared_ref = projects_shared_ref || typ.ty + .ref_mutability() + .map(|m| m.is_not()) + .unwrap_or_default(); + projects_shared_ref = projects_shared_ref && !typ.ty.is_unsafe_ptr(); + false + }, + repacker, + ); + !projects_shared_ref } pub fn projects_ty(