11use crate :: elaborate_drops:: DropFlagState ;
22use rustc_middle:: mir:: { self , Body , Location , Terminator , TerminatorKind } ;
3- use rustc_middle:: ty:: { self , TyCtxt } ;
3+ use rustc_middle:: ty:: TyCtxt ;
44use rustc_target:: abi:: VariantIdx ;
55
66use super :: indexes:: MovePathIndex ;
@@ -55,60 +55,6 @@ pub fn on_all_children_bits<'tcx, F>(
5555) where
5656 F : FnMut ( MovePathIndex ) ,
5757{
58- #[ inline]
59- fn is_terminal_path < ' tcx > (
60- tcx : TyCtxt < ' tcx > ,
61- body : & Body < ' tcx > ,
62- move_data : & MoveData < ' tcx > ,
63- path : MovePathIndex ,
64- ) -> bool {
65- let place = move_data. move_paths [ path] . place ;
66-
67- // When enumerating the child fragments of a path, don't recurse into
68- // paths (1.) past arrays, slices, and pointers, nor (2.) into a type
69- // that implements `Drop`.
70- //
71- // Places behind references or arrays are not tracked by elaboration
72- // and are always assumed to be initialized when accessible. As
73- // references and indexes can be reseated, trying to track them can
74- // only lead to trouble.
75- //
76- // Places behind ADT's with a Drop impl are not tracked by
77- // elaboration since they can never have a drop-flag state that
78- // differs from that of the parent with the Drop impl.
79- //
80- // In both cases, the contents can only be accessed if and only if
81- // their parents are initialized. This implies for example that there
82- // is no need to maintain separate drop flags to track such state.
83- //
84- // FIXME: we have to do something for moving slice patterns.
85- let ty = place. ty ( body, tcx) . ty ;
86- match ty. kind ( ) {
87- ty:: Adt ( def, _) if ( def. has_dtor ( tcx) && !def. is_box ( ) ) || def. is_union ( ) => {
88- debug ! (
89- "place_contents_drop_state_cannot_differ place: {:?} ty: {:?} Drop => true" ,
90- place, ty
91- ) ;
92- true
93- }
94- ty:: Array ( ..) => {
95- debug ! (
96- "place_contents_drop_state_cannot_differ place: {:?} ty: {:?} => false" ,
97- place, ty
98- ) ;
99- false
100- }
101- ty:: Slice ( ..) | ty:: Ref ( ..) | ty:: RawPtr ( ..) => {
102- debug ! (
103- "place_contents_drop_state_cannot_differ place: {:?} ty: {:?} refd => true" ,
104- place, ty
105- ) ;
106- true
107- }
108- _ => false ,
109- }
110- }
111-
11258 fn on_all_children_bits < ' tcx , F > (
11359 tcx : TyCtxt < ' tcx > ,
11460 body : & Body < ' tcx > ,
@@ -120,10 +66,6 @@ pub fn on_all_children_bits<'tcx, F>(
12066 {
12167 each_child ( move_path_index) ;
12268
123- if is_terminal_path ( tcx, body, move_data, move_path_index) {
124- return ;
125- }
126-
12769 let mut next_child_index = move_data. move_paths [ move_path_index] . first_child ;
12870 while let Some ( child_index) = next_child_index {
12971 on_all_children_bits ( tcx, body, move_data, child_index, each_child) ;
0 commit comments