@@ -132,7 +132,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
132132 }
133133 & AggregateKind :: Closure ( def_id, _) | & AggregateKind :: Generator ( def_id, _, _) => {
134134 let UnsafetyCheckResult { violations, unsafe_blocks } =
135- self . tcx . unsafety_check_result ( def_id) ;
135+ self . tcx . unsafety_check_result ( def_id. expect_local ( ) ) ;
136136 self . register_violations ( & violations, & unsafe_blocks) ;
137137 }
138138 } ,
@@ -485,7 +485,7 @@ fn check_unused_unsafe(
485485 intravisit:: Visitor :: visit_body ( & mut visitor, body) ;
486486}
487487
488- fn unsafety_check_result ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> UnsafetyCheckResult {
488+ fn unsafety_check_result ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> UnsafetyCheckResult {
489489 debug ! ( "unsafety_violations({:?})" , def_id) ;
490490
491491 // N.B., this borrow is valid because all the consumers of
@@ -494,21 +494,18 @@ fn unsafety_check_result(tcx: TyCtxt<'_>, def_id: DefId) -> UnsafetyCheckResult
494494
495495 let param_env = tcx. param_env ( def_id) ;
496496
497- let id = tcx. hir ( ) . as_local_hir_id ( def_id. expect_local ( ) ) ;
497+ let id = tcx. hir ( ) . as_local_hir_id ( def_id) ;
498498 let ( const_context, min_const_fn) = match tcx. hir ( ) . body_owner_kind ( id) {
499499 hir:: BodyOwnerKind :: Closure => ( false , false ) ,
500- hir:: BodyOwnerKind :: Fn => ( is_const_fn ( tcx, def_id) , is_min_const_fn ( tcx, def_id) ) ,
500+ hir:: BodyOwnerKind :: Fn => {
501+ ( is_const_fn ( tcx, def_id. to_def_id ( ) ) , is_min_const_fn ( tcx, def_id. to_def_id ( ) ) )
502+ }
501503 hir:: BodyOwnerKind :: Const | hir:: BodyOwnerKind :: Static ( _) => ( true , false ) ,
502504 } ;
503505 let mut checker = UnsafetyChecker :: new ( const_context, min_const_fn, body, tcx, param_env) ;
504506 checker. visit_body ( & body) ;
505507
506- check_unused_unsafe (
507- tcx,
508- def_id. expect_local ( ) ,
509- & checker. used_unsafe ,
510- & mut checker. inherited_blocks ,
511- ) ;
508+ check_unused_unsafe ( tcx, def_id, & checker. used_unsafe , & mut checker. inherited_blocks ) ;
512509 UnsafetyCheckResult {
513510 violations : checker. violations . into ( ) ,
514511 unsafe_blocks : checker. inherited_blocks . into ( ) ,
@@ -600,7 +597,8 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
600597 return ;
601598 }
602599
603- let UnsafetyCheckResult { violations, unsafe_blocks } = tcx. unsafety_check_result ( def_id) ;
600+ let UnsafetyCheckResult { violations, unsafe_blocks } =
601+ tcx. unsafety_check_result ( def_id. expect_local ( ) ) ;
604602
605603 for & UnsafetyViolation { source_info, description, details, kind } in violations. iter ( ) {
606604 // Report an error.
0 commit comments