@@ -571,9 +571,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
571
571
fn get_closure_bound_clause_span ( & self , def_id : DefId ) -> Span {
572
572
let tcx = self . infcx . tcx ;
573
573
let typeck_result = tcx. typeck ( self . mir_def_id ( ) ) ;
574
- let Some ( closure_def_id) = def_id. as_local ( ) else { return DUMMY_SP } ;
575
- let hir:: Node :: Expr ( expr) = tcx. hir_node_by_def_id ( closure_def_id) else { return DUMMY_SP } ;
576
- let hir:: Node :: Expr ( parent) = tcx. parent_hir_node ( expr. hir_id ) else { return DUMMY_SP } ;
574
+ // Check whether the closure is an argument to a call, if so,
575
+ // get the instantiated where-bounds of that call.
576
+ let closure_hir_id = tcx. local_def_id_to_hir_id ( def_id. expect_local ( ) ) ;
577
+ let hir:: Node :: Expr ( parent) = tcx. parent_hir_node ( closure_hir_id) else { return DUMMY_SP } ;
578
+
577
579
let predicates = match parent. kind {
578
580
hir:: ExprKind :: Call ( callee, _) => {
579
581
let Some ( ty) = typeck_result. node_type_opt ( callee. hir_id ) else { return DUMMY_SP } ;
@@ -589,9 +591,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
589
591
}
590
592
_ => return DUMMY_SP ,
591
593
} ;
594
+
595
+ // Check whether one of the where-bounds requires the closure to impl `Fn[Mut]`.
592
596
for ( pred, span) in predicates. predicates . iter ( ) . zip ( predicates. spans . iter ( ) ) {
593
- tracing:: info!( ?pred) ;
594
- tracing:: info!( ?span) ;
595
597
if let Some ( clause) = pred. as_trait_clause ( )
596
598
&& let ty:: Closure ( clause_closure_def_id, _) = clause. self_ty ( ) . skip_binder ( ) . kind ( )
597
599
&& * clause_closure_def_id == def_id
0 commit comments