about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-09-30 17:44:00 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-10-21 10:26:28 +0000
commita8e56d0b0bab2b6ad1151d97ebb6e246a173829f (patch)
tree1972f49f4e482d1db1ad2b5a20b59758ad098ad7
parent249624b5043013d18c00f0401ca431c1a6baa8cd (diff)
downloadrust-a8e56d0b0bab2b6ad1151d97ebb6e246a173829f.tar.gz
rust-a8e56d0b0bab2b6ad1151d97ebb6e246a173829f.zip
Remove is_terminal_path.
That information is redundant. Is the path is terminal, `first_child` will
already be `None`.
-rw-r--r--compiler/rustc_mir_dataflow/src/drop_flag_effects.rs60
1 files changed, 1 insertions, 59 deletions
diff --git a/compiler/rustc_mir_dataflow/src/drop_flag_effects.rs b/compiler/rustc_mir_dataflow/src/drop_flag_effects.rs
index 0d466bbe56e..0f589a702b5 100644
--- a/compiler/rustc_mir_dataflow/src/drop_flag_effects.rs
+++ b/compiler/rustc_mir_dataflow/src/drop_flag_effects.rs
@@ -1,6 +1,6 @@
 use crate::elaborate_drops::DropFlagState;
 use rustc_middle::mir::{self, Body, Location, Terminator, TerminatorKind};
-use rustc_middle::ty::{self, TyCtxt};
+use rustc_middle::ty::TyCtxt;
 use rustc_target::abi::VariantIdx;
 
 use super::indexes::MovePathIndex;
@@ -55,60 +55,6 @@ pub fn on_all_children_bits<'tcx, F>(
 ) where
     F: FnMut(MovePathIndex),
 {
-    #[inline]
-    fn is_terminal_path<'tcx>(
-        tcx: TyCtxt<'tcx>,
-        body: &Body<'tcx>,
-        move_data: &MoveData<'tcx>,
-        path: MovePathIndex,
-    ) -> bool {
-        let place = move_data.move_paths[path].place;
-
-        // When enumerating the child fragments of a path, don't recurse into
-        // paths (1.) past arrays, slices, and pointers, nor (2.) into a type
-        // that implements `Drop`.
-        //
-        // Places behind references or arrays are not tracked by elaboration
-        // and are always assumed to be initialized when accessible. As
-        // references and indexes can be reseated, trying to track them can
-        // only lead to trouble.
-        //
-        // Places behind ADT's with a Drop impl are not tracked by
-        // elaboration since they can never have a drop-flag state that
-        // differs from that of the parent with the Drop impl.
-        //
-        // In both cases, the contents can only be accessed if and only if
-        // their parents are initialized. This implies for example that there
-        // is no need to maintain separate drop flags to track such state.
-        //
-        // FIXME: we have to do something for moving slice patterns.
-        let ty = place.ty(body, tcx).ty;
-        match ty.kind() {
-            ty::Adt(def, _) if (def.has_dtor(tcx) && !def.is_box()) || def.is_union() => {
-                debug!(
-                    "place_contents_drop_state_cannot_differ place: {:?} ty: {:?} Drop => true",
-                    place, ty
-                );
-                true
-            }
-            ty::Array(..) => {
-                debug!(
-                    "place_contents_drop_state_cannot_differ place: {:?} ty: {:?} => false",
-                    place, ty
-                );
-                false
-            }
-            ty::Slice(..) | ty::Ref(..) | ty::RawPtr(..) => {
-                debug!(
-                    "place_contents_drop_state_cannot_differ place: {:?} ty: {:?} refd => true",
-                    place, ty
-                );
-                true
-            }
-            _ => false,
-        }
-    }
-
     fn on_all_children_bits<'tcx, F>(
         tcx: TyCtxt<'tcx>,
         body: &Body<'tcx>,
@@ -120,10 +66,6 @@ pub fn on_all_children_bits<'tcx, F>(
     {
         each_child(move_path_index);
 
-        if is_terminal_path(tcx, body, move_data, move_path_index) {
-            return;
-        }
-
         let mut next_child_index = move_data.move_paths[move_path_index].first_child;
         while let Some(child_index) = next_child_index {
             on_all_children_bits(tcx, body, move_data, child_index, each_child);