@@ -328,9 +328,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
328
328
}
329
329
}
330
330
331
+ #[ instrument( level = "debug" , skip( self ) ) ]
331
332
fn visit_const_operand ( & mut self , constant : & ConstOperand < ' tcx > , location : Location ) {
332
- debug ! ( ?constant, ?location, "visit_const_operand" ) ;
333
-
334
333
self . super_const_operand ( constant, location) ;
335
334
let ty = constant. const_ . ty ( ) ;
336
335
@@ -339,14 +338,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
339
338
self . typeck . constraints . liveness_constraints . add_location ( live_region_vid, location) ;
340
339
} ) ;
341
340
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 ( ) ;
350
342
if let Some ( annotation_index) = constant. user_ty {
351
343
if let Err ( terr) = self . typeck . relate_type_and_user_type (
352
344
constant. const_ . ty ( ) ,
@@ -491,9 +483,28 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
491
483
}
492
484
}
493
485
486
+ #[ instrument( level = "debug" , skip( self ) ) ]
494
487
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 recurse 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
+ }
497
508
}
498
509
}
499
510
@@ -2582,7 +2593,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2582
2593
ConstraintCategory :: Boring , // same as above.
2583
2594
self . constraints ,
2584
2595
)
2585
- . apply_closure_requirements ( closure_requirements, def_id. to_def_id ( ) , args) ;
2596
+ . apply_closure_requirements ( closure_requirements, def_id, args) ;
2586
2597
}
2587
2598
2588
2599
// Now equate closure args to regions inherited from `typeck_root_def_id`. Fixes #98589.
0 commit comments