@@ -180,11 +180,14 @@ fn do_mir_borrowck<'a, 'tcx>(
180180 let location_table = & LocationTable :: new ( & body) ;
181181
182182 let mut errors_buffer = Vec :: new ( ) ;
183- let ( move_data, move_errors) : ( MoveData < ' tcx > , Option < Vec < ( Place < ' tcx > , MoveError < ' tcx > ) > > ) =
183+ let ( move_data, move_errors) : ( MoveData < ' tcx > , Vec < ( Place < ' tcx > , MoveError < ' tcx > ) > ) =
184184 match MoveData :: gather_moves ( & body, tcx, param_env) {
185- Ok ( move_data) => ( move_data, None ) ,
186- Err ( ( move_data, move_errors) ) => ( move_data, Some ( move_errors) ) ,
185+ Ok ( move_data) => ( move_data, Vec :: new ( ) ) ,
186+ Err ( ( move_data, move_errors) ) => ( move_data, move_errors) ,
187187 } ;
188+ let promoted_errors = promoted
189+ . iter_enumerated ( )
190+ . map ( |( idx, body) | ( idx, MoveData :: gather_moves ( & body, tcx, param_env) ) ) ;
188191
189192 let mdpe = MoveDataParamEnv { move_data, param_env } ;
190193
@@ -264,6 +267,41 @@ fn do_mir_borrowck<'a, 'tcx>(
264267 _ => true ,
265268 } ;
266269
270+ for ( idx, move_data_results) in promoted_errors {
271+ let promoted_body = & promoted[ idx] ;
272+ let dominators = promoted_body. dominators ( ) ;
273+
274+ if let Err ( ( move_data, move_errors) ) = move_data_results {
275+ let mut promoted_mbcx = MirBorrowckCtxt {
276+ infcx,
277+ body : promoted_body,
278+ mir_def_id : def_id. to_def_id ( ) ,
279+ move_data : & move_data,
280+ location_table : & LocationTable :: new ( promoted_body) ,
281+ movable_generator,
282+ locals_are_invalidated_at_exit,
283+ access_place_error_reported : Default :: default ( ) ,
284+ reservation_error_reported : Default :: default ( ) ,
285+ reservation_warnings : Default :: default ( ) ,
286+ move_error_reported : BTreeMap :: new ( ) ,
287+ uninitialized_error_reported : Default :: default ( ) ,
288+ errors_buffer,
289+ regioncx : regioncx. clone ( ) ,
290+ used_mut : Default :: default ( ) ,
291+ used_mut_upvars : SmallVec :: new ( ) ,
292+ borrow_set : borrow_set. clone ( ) ,
293+ dominators,
294+ upvars : Vec :: new ( ) ,
295+ local_names : IndexVec :: from_elem ( None , & promoted_body. local_decls ) ,
296+ region_names : RefCell :: default ( ) ,
297+ next_region_name : RefCell :: new ( 1 ) ,
298+ polonius_output : None ,
299+ } ;
300+ promoted_mbcx. report_move_errors ( move_errors) ;
301+ errors_buffer = promoted_mbcx. errors_buffer ;
302+ } ;
303+ }
304+
267305 let dominators = body. dominators ( ) ;
268306
269307 let mut mbcx = MirBorrowckCtxt {
@@ -301,9 +339,7 @@ fn do_mir_borrowck<'a, 'tcx>(
301339 borrows : flow_borrows,
302340 } ;
303341
304- if let Some ( errors) = move_errors {
305- mbcx. report_move_errors ( errors) ;
306- }
342+ mbcx. report_move_errors ( move_errors) ;
307343
308344 dataflow:: visit_results (
309345 & body,
0 commit comments