@@ -328,9 +328,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
328328 }
329329 }
330330
331+ #[ instrument( level = "debug" , skip( self ) ) ]
331332 fn visit_const_operand ( & mut self , constant : & ConstOperand < ' tcx > , location : Location ) {
332- debug ! ( ?constant, ?location, "visit_const_operand" ) ;
333-
334333 self . super_const_operand ( constant, location) ;
335334 let ty = constant. const_ . ty ( ) ;
336335
@@ -339,14 +338,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
339338 self . typeck . constraints . liveness_constraints . add_location ( live_region_vid, location) ;
340339 } ) ;
341340
342- // HACK(compiler-errors): Constants that are gathered into Body.required_consts
343- // have their locations erased...
344- let locations = if location != Location :: START {
345- location. to_locations ( )
346- } else {
347- Locations :: All ( constant. span )
348- } ;
349-
341+ let locations = location. to_locations ( ) ;
350342 if let Some ( annotation_index) = constant. user_ty {
351343 if let Err ( terr) = self . typeck . relate_type_and_user_type (
352344 constant. const_ . ty ( ) ,
@@ -491,9 +483,28 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
491483 }
492484 }
493485
486+ #[ instrument( level = "debug" , skip( self ) ) ]
494487 fn visit_body ( & mut self , body : & Body < ' tcx > ) {
495- // The types of local_decls are checked above which is called in super_body.
496- self . super_body ( body) ;
488+ // We intentionally do not recursive into `body.required_consts` or
489+ // `body.mentioned_items` here as the MIR at this phase should still
490+ // refer to all items and we don't want to check them multiple times.
491+
492+ for ( local, local_decl) in body. local_decls . iter_enumerated ( ) {
493+ self . visit_local_decl ( local, local_decl) ;
494+ }
495+
496+ for ( block, block_data) in body. basic_blocks . iter_enumerated ( ) {
497+ let mut location = Location { block, statement_index : 0 } ;
498+ for stmt in & block_data. statements {
499+ if !stmt. source_info . span . is_dummy ( ) {
500+ self . last_span = stmt. source_info . span ;
501+ }
502+ self . visit_statement ( stmt, location) ;
503+ location. statement_index += 1 ;
504+ }
505+
506+ self . visit_terminator ( block_data. terminator ( ) , location) ;
507+ }
497508 }
498509}
499510
0 commit comments