@@ -132,7 +132,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
132
132
}
133
133
& AggregateKind :: Closure ( def_id, _) | & AggregateKind :: Generator ( def_id, _, _) => {
134
134
let UnsafetyCheckResult { violations, unsafe_blocks } =
135
- self . tcx . unsafety_check_result ( def_id) ;
135
+ self . tcx . unsafety_check_result ( def_id. expect_local ( ) ) ;
136
136
self . register_violations ( & violations, & unsafe_blocks) ;
137
137
}
138
138
} ,
@@ -485,7 +485,7 @@ fn check_unused_unsafe(
485
485
intravisit:: Visitor :: visit_body ( & mut visitor, body) ;
486
486
}
487
487
488
- fn unsafety_check_result ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> UnsafetyCheckResult {
488
+ fn unsafety_check_result ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> UnsafetyCheckResult {
489
489
debug ! ( "unsafety_violations({:?})" , def_id) ;
490
490
491
491
// 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
494
494
495
495
let param_env = tcx. param_env ( def_id) ;
496
496
497
- let id = tcx. hir ( ) . as_local_hir_id ( def_id. expect_local ( ) ) ;
497
+ let id = tcx. hir ( ) . as_local_hir_id ( def_id) ;
498
498
let ( const_context, min_const_fn) = match tcx. hir ( ) . body_owner_kind ( id) {
499
499
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
+ }
501
503
hir:: BodyOwnerKind :: Const | hir:: BodyOwnerKind :: Static ( _) => ( true , false ) ,
502
504
} ;
503
505
let mut checker = UnsafetyChecker :: new ( const_context, min_const_fn, body, tcx, param_env) ;
504
506
checker. visit_body ( & body) ;
505
507
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 ) ;
512
509
UnsafetyCheckResult {
513
510
violations : checker. violations . into ( ) ,
514
511
unsafe_blocks : checker. inherited_blocks . into ( ) ,
@@ -600,7 +597,8 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
600
597
return ;
601
598
}
602
599
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 ( ) ) ;
604
602
605
603
for & UnsafetyViolation { source_info, description, details, kind } in violations. iter ( ) {
606
604
// Report an error.
0 commit comments