@@ -124,3 +124,56 @@ pub fn handle_ref_assignment<'tcx>(
124
124
memory. link_place_to_same_condvar ( * place, * rhs) ;
125
125
}
126
126
}
127
+
128
+ /// Handles MIR assignments of the form: `_X = { copy_data: move _Y }`.
129
+ /// If the right-hand side contains a synchronization variable, link it to the left-hand side.
130
+ pub fn handle_aggregate_assignment < ' tcx > (
131
+ place : & rustc_middle:: mir:: Place < ' tcx > ,
132
+ operands : & Vec < rustc_middle:: mir:: Operand < ' tcx > > ,
133
+ memory : & mut Memory < ' tcx > ,
134
+ caller_function_def_id : rustc_hir:: def_id:: DefId ,
135
+ tcx : rustc_middle:: ty:: TyCtxt < ' tcx > ,
136
+ ) {
137
+ for operand in operands {
138
+ // Extract the place to be assignment
139
+ let rhs = match operand {
140
+ rustc_middle:: mir:: Operand :: Copy ( place) | rustc_middle:: mir:: Operand :: Move ( place) => {
141
+ place
142
+ }
143
+ // Nothing to do if we found a constant as one of the operands.
144
+ rustc_middle:: mir:: Operand :: Constant ( _) => continue ,
145
+ } ;
146
+
147
+ if is_place_with_concrete_type ( rhs, "std::sync::Mutex<T>" , caller_function_def_id, tcx)
148
+ || is_place_with_concrete_type (
149
+ rhs,
150
+ "std::sync::Arc<std::sync::Mutex<T>>" ,
151
+ caller_function_def_id,
152
+ tcx,
153
+ )
154
+ {
155
+ memory. link_place_to_same_mutex ( * place, * rhs) ;
156
+ } else if is_place_with_concrete_type (
157
+ rhs,
158
+ "std::sync::MutexGuard<'a, T>" ,
159
+ caller_function_def_id,
160
+ tcx,
161
+ ) {
162
+ memory. link_place_to_same_lock_guard ( * place, * rhs) ;
163
+ } else if is_place_with_concrete_type (
164
+ rhs,
165
+ "std::thread::JoinHandle<T>" ,
166
+ caller_function_def_id,
167
+ tcx,
168
+ ) {
169
+ memory. link_place_to_same_join_handle ( * place, * rhs) ;
170
+ } else if is_place_with_concrete_type (
171
+ rhs,
172
+ "std::sync::Condvar" ,
173
+ caller_function_def_id,
174
+ tcx,
175
+ ) {
176
+ memory. link_place_to_same_condvar ( * place, * rhs) ;
177
+ }
178
+ }
179
+ }
0 commit comments