29
29
None
30
30
}
31
31
32
- /// When enumerating the child fragments of a path, don't recurse into
33
- /// paths (1.) past arrays, slices, and pointers, nor (2.) into a type
34
- /// that implements `Drop`.
35
- ///
36
- /// Places behind references or arrays are not tracked by elaboration
37
- /// and are always assumed to be initialized when accessible. As
38
- /// references and indexes can be reseated, trying to track them can
39
- /// only lead to trouble.
40
- ///
41
- /// Places behind ADT's with a Drop impl are not tracked by
42
- /// elaboration since they can never have a drop-flag state that
43
- /// differs from that of the parent with the Drop impl.
44
- ///
45
- /// In both cases, the contents can only be accessed if and only if
46
- /// their parents are initialized. This implies for example that there
47
- /// is no need to maintain separate drop flags to track such state.
48
- //
49
- // FIXME: we have to do something for moving slice patterns.
50
- fn place_contents_drop_state_cannot_differ < ' tcx > (
51
- tcx : TyCtxt < ' tcx > ,
52
- body : & Body < ' tcx > ,
53
- place : mir:: Place < ' tcx > ,
54
- ) -> bool {
55
- let ty = place. ty ( body, tcx) . ty ;
56
- match ty. kind ( ) {
57
- ty:: Array ( ..) => {
58
- debug ! (
59
- "place_contents_drop_state_cannot_differ place: {:?} ty: {:?} => false" ,
60
- place, ty
61
- ) ;
62
- false
63
- }
64
- ty:: Slice ( ..) | ty:: Ref ( ..) | ty:: RawPtr ( ..) => {
65
- debug ! (
66
- "place_contents_drop_state_cannot_differ place: {:?} ty: {:?} refd => true" ,
67
- place, ty
68
- ) ;
69
- true
70
- }
71
- ty:: Adt ( def, _) if ( def. has_dtor ( tcx) && !def. is_box ( ) ) || def. is_union ( ) => {
72
- debug ! (
73
- "place_contents_drop_state_cannot_differ place: {:?} ty: {:?} Drop => true" ,
74
- place, ty
75
- ) ;
76
- true
77
- }
78
- _ => false ,
79
- }
80
- }
81
-
82
32
pub fn on_lookup_result_bits < ' tcx , F > (
83
33
tcx : TyCtxt < ' tcx > ,
84
34
body : & Body < ' tcx > ,
@@ -105,13 +55,58 @@ pub fn on_all_children_bits<'tcx, F>(
105
55
) where
106
56
F : FnMut ( MovePathIndex ) ,
107
57
{
58
+ #[ inline]
108
59
fn is_terminal_path < ' tcx > (
109
60
tcx : TyCtxt < ' tcx > ,
110
61
body : & Body < ' tcx > ,
111
62
move_data : & MoveData < ' tcx > ,
112
63
path : MovePathIndex ,
113
64
) -> bool {
114
- place_contents_drop_state_cannot_differ ( tcx, body, move_data. move_paths [ path] . place )
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
+ }
115
110
}
116
111
117
112
fn on_all_children_bits < ' tcx , F > (
0 commit comments