@@ -14,7 +14,7 @@ use rustc_span::{DUMMY_SP, Span};
1414use rustc_trait_selection:: traits:: { ObligationCause , ObligationCtxt } ;
1515use tracing:: debug;
1616
17- use crate :: { FnCtxt , TypeckRootCtxt , errors} ;
17+ use crate :: { FnCtxt , errors} ;
1818
1919#[ derive( Copy , Clone ) ]
2020pub ( crate ) enum DivergingFallbackBehavior {
@@ -419,7 +419,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
419419 root_vid : ty:: TyVid ,
420420 ) {
421421 let unsafe_infer_vars = unsafe_infer_vars. get_or_init ( || {
422- let unsafe_infer_vars = compute_unsafe_infer_vars ( self . root_ctxt , self . body_id ) ;
422+ let unsafe_infer_vars = compute_unsafe_infer_vars ( self , self . body_id ) ;
423423 debug ! ( ?unsafe_infer_vars) ;
424424 unsafe_infer_vars
425425 } ) ;
@@ -569,27 +569,26 @@ pub(crate) enum UnsafeUseReason {
569569///
570570/// `compute_unsafe_infer_vars` will return `{ id(?X) -> (hir_id, span, Call) }`
571571fn compute_unsafe_infer_vars < ' a , ' tcx > (
572- root_ctxt : & ' a TypeckRootCtxt < ' tcx > ,
572+ fcx : & ' a FnCtxt < ' a , ' tcx > ,
573573 body_id : LocalDefId ,
574574) -> UnordMap < ty:: TyVid , ( HirId , Span , UnsafeUseReason ) > {
575- let body =
576- root_ctxt. tcx . hir ( ) . maybe_body_owned_by ( body_id) . expect ( "body id must have an owner" ) ;
575+ let body = fcx. tcx . hir ( ) . maybe_body_owned_by ( body_id) . expect ( "body id must have an owner" ) ;
577576 let mut res = UnordMap :: default ( ) ;
578577
579578 struct UnsafeInferVarsVisitor < ' a , ' tcx > {
580- root_ctxt : & ' a TypeckRootCtxt < ' tcx > ,
579+ fcx : & ' a FnCtxt < ' a , ' tcx > ,
581580 res : & ' a mut UnordMap < ty:: TyVid , ( HirId , Span , UnsafeUseReason ) > ,
582581 }
583582
584583 impl Visitor < ' _ > for UnsafeInferVarsVisitor < ' _ , ' _ > {
585584 fn visit_expr ( & mut self , ex : & ' _ hir:: Expr < ' _ > ) {
586- let typeck_results = self . root_ctxt . typeck_results . borrow ( ) ;
585+ let typeck_results = self . fcx . typeck_results . borrow ( ) ;
587586
588587 match ex. kind {
589588 hir:: ExprKind :: MethodCall ( ..) => {
590589 if let Some ( def_id) = typeck_results. type_dependent_def_id ( ex. hir_id )
591- && let method_ty = self . root_ctxt . tcx . type_of ( def_id) . instantiate_identity ( )
592- && let sig = method_ty. fn_sig ( self . root_ctxt . tcx )
590+ && let method_ty = self . fcx . tcx . type_of ( def_id) . instantiate_identity ( )
591+ && let sig = method_ty. fn_sig ( self . fcx . tcx )
593592 && let hir:: Safety :: Unsafe = sig. safety ( )
594593 {
595594 let mut collector = InferVarCollector {
@@ -609,7 +608,7 @@ fn compute_unsafe_infer_vars<'a, 'tcx>(
609608 let func_ty = typeck_results. expr_ty ( func) ;
610609
611610 if func_ty. is_fn ( )
612- && let sig = func_ty. fn_sig ( self . root_ctxt . tcx )
611+ && let sig = func_ty. fn_sig ( self . fcx . tcx )
613612 && let hir:: Safety :: Unsafe = sig. safety ( )
614613 {
615614 let mut collector = InferVarCollector {
@@ -640,7 +639,7 @@ fn compute_unsafe_infer_vars<'a, 'tcx>(
640639 // If this path refers to an unsafe function, collect inference variables which may affect it.
641640 // `is_fn` excludes closures, but those can't be unsafe.
642641 if ty. is_fn ( )
643- && let sig = ty. fn_sig ( self . root_ctxt . tcx )
642+ && let sig = ty. fn_sig ( self . fcx . tcx )
644643 && let hir:: Safety :: Unsafe = sig. safety ( )
645644 {
646645 let mut collector = InferVarCollector {
@@ -698,7 +697,7 @@ fn compute_unsafe_infer_vars<'a, 'tcx>(
698697 }
699698 }
700699
701- UnsafeInferVarsVisitor { root_ctxt , res : & mut res } . visit_expr ( & body. value ) ;
700+ UnsafeInferVarsVisitor { fcx , res : & mut res } . visit_expr ( & body. value ) ;
702701
703702 debug ! ( ?res, "collected the following unsafe vars for {body_id:?}" ) ;
704703
0 commit comments