@@ -166,7 +166,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
166
166
"For closure={:?}, capture_information={:#?}" ,
167
167
closure_def_id, delegate. capture_information
168
168
) ;
169
- self . log_closure_capture_info ( closure_def_id, & delegate. capture_information , span) ;
169
+ self . log_capture_analysis_first_pass ( closure_def_id, & delegate. capture_information , span) ;
170
170
171
171
if let Some ( closure_substs) = infer_kind {
172
172
// Unify the (as yet unbound) type variable in the closure
@@ -499,20 +499,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
499
499
self . tcx . has_attr ( closure_def_id, sym:: rustc_capture_analysis)
500
500
}
501
501
502
- fn log_closure_capture_info (
502
+ fn log_capture_analysis_first_pass (
503
503
& self ,
504
504
closure_def_id : rustc_hir:: def_id:: DefId ,
505
505
capture_information : & FxIndexMap < Place < ' tcx > , ty:: CaptureInfo < ' tcx > > ,
506
506
closure_span : Span ,
507
507
) {
508
508
if self . should_log_capture_analysis ( closure_def_id) {
509
+ let mut diag =
510
+ self . tcx . sess . struct_span_err ( closure_span, "First Pass analysis includes:" ) ;
509
511
for ( place, capture_info) in capture_information {
510
512
let capture_str = construct_capture_info_string ( self . tcx , place, capture_info) ;
511
513
let output_str = format ! ( "Capturing {}" , capture_str) ;
512
514
513
515
let span = capture_info. expr_id . map_or ( closure_span, |e| self . tcx . hir ( ) . span ( e) ) ;
514
- self . tcx . sess . span_err ( span, & output_str) ;
516
+ diag . span_note ( span, & output_str) ;
515
517
}
518
+ diag. emit ( ) ;
516
519
}
517
520
}
518
521
@@ -521,6 +524,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
521
524
if let Some ( min_captures) =
522
525
self . typeck_results . borrow ( ) . closure_min_captures . get ( & closure_def_id)
523
526
{
527
+ let mut diag =
528
+ self . tcx . sess . struct_span_err ( closure_span, "Min Capture analysis includes:" ) ;
529
+
524
530
for ( _, min_captures_for_var) in min_captures {
525
531
for capture in min_captures_for_var {
526
532
let place = & capture. place ;
@@ -532,9 +538,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
532
538
533
539
let span =
534
540
capture_info. expr_id . map_or ( closure_span, |e| self . tcx . hir ( ) . span ( e) ) ;
535
- self . tcx . sess . span_err ( span, & output_str) ;
541
+ diag . span_note ( span, & output_str) ;
536
542
}
537
543
}
544
+ diag. emit ( ) ;
538
545
}
539
546
}
540
547
}
0 commit comments