|
3 | 3 | use either::Either; |
4 | 4 | use rustc_data_structures::captures::Captures; |
5 | 5 | use rustc_data_structures::fx::FxIndexSet; |
6 | | -use rustc_errors::{ |
7 | | - codes::*, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan, |
8 | | -}; |
| 6 | +use rustc_errors::{codes::*, struct_span_code_err, Applicability, DiagnosticBuilder, MultiSpan}; |
9 | 7 | use rustc_hir as hir; |
10 | 8 | use rustc_hir::def::{DefKind, Res}; |
11 | 9 | use rustc_hir::intravisit::{walk_block, walk_expr, Visitor}; |
@@ -633,7 +631,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { |
633 | 631 |
|
634 | 632 | fn suggest_assign_value( |
635 | 633 | &self, |
636 | | - err: &mut Diagnostic, |
| 634 | + err: &mut DiagnosticBuilder<'_>, |
637 | 635 | moved_place: PlaceRef<'tcx>, |
638 | 636 | sugg_span: Span, |
639 | 637 | ) { |
@@ -672,7 +670,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { |
672 | 670 |
|
673 | 671 | fn suggest_borrow_fn_like( |
674 | 672 | &self, |
675 | | - err: &mut Diagnostic, |
| 673 | + err: &mut DiagnosticBuilder<'_>, |
676 | 674 | ty: Ty<'tcx>, |
677 | 675 | move_sites: &[MoveSite], |
678 | 676 | value_name: &str, |
@@ -740,7 +738,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { |
740 | 738 |
|
741 | 739 | fn suggest_cloning( |
742 | 740 | &self, |
743 | | - err: &mut Diagnostic, |
| 741 | + err: &mut DiagnosticBuilder<'_>, |
744 | 742 | ty: Ty<'tcx>, |
745 | 743 | expr: &hir::Expr<'_>, |
746 | 744 | span: Span, |
@@ -776,7 +774,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { |
776 | 774 | } |
777 | 775 | } |
778 | 776 |
|
779 | | - fn suggest_adding_copy_bounds(&self, err: &mut Diagnostic, ty: Ty<'tcx>, span: Span) { |
| 777 | + fn suggest_adding_copy_bounds( |
| 778 | + &self, |
| 779 | + err: &mut DiagnosticBuilder<'_>, |
| 780 | + ty: Ty<'tcx>, |
| 781 | + span: Span, |
| 782 | + ) { |
780 | 783 | let tcx = self.infcx.tcx; |
781 | 784 | let generics = tcx.generics_of(self.mir_def_id()); |
782 | 785 |
|
@@ -1210,7 +1213,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { |
1210 | 1213 | #[instrument(level = "debug", skip(self, err))] |
1211 | 1214 | fn suggest_using_local_if_applicable( |
1212 | 1215 | &self, |
1213 | | - err: &mut Diagnostic, |
| 1216 | + err: &mut DiagnosticBuilder<'_>, |
1214 | 1217 | location: Location, |
1215 | 1218 | issued_borrow: &BorrowData<'tcx>, |
1216 | 1219 | explanation: BorrowExplanation<'tcx>, |
@@ -1306,7 +1309,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { |
1306 | 1309 |
|
1307 | 1310 | fn suggest_slice_method_if_applicable( |
1308 | 1311 | &self, |
1309 | | - err: &mut Diagnostic, |
| 1312 | + err: &mut DiagnosticBuilder<'_>, |
1310 | 1313 | place: Place<'tcx>, |
1311 | 1314 | borrowed_place: Place<'tcx>, |
1312 | 1315 | ) { |
@@ -1415,7 +1418,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { |
1415 | 1418 | /// ``` |
1416 | 1419 | pub(crate) fn explain_iterator_advancement_in_for_loop_if_applicable( |
1417 | 1420 | &self, |
1418 | | - err: &mut Diagnostic, |
| 1421 | + err: &mut DiagnosticBuilder<'_>, |
1419 | 1422 | span: Span, |
1420 | 1423 | issued_spans: &UseSpans<'tcx>, |
1421 | 1424 | ) { |
@@ -1602,7 +1605,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { |
1602 | 1605 | /// ``` |
1603 | 1606 | fn suggest_using_closure_argument_instead_of_capture( |
1604 | 1607 | &self, |
1605 | | - err: &mut Diagnostic, |
| 1608 | + err: &mut DiagnosticBuilder<'_>, |
1606 | 1609 | borrowed_place: Place<'tcx>, |
1607 | 1610 | issued_spans: &UseSpans<'tcx>, |
1608 | 1611 | ) { |
@@ -1737,7 +1740,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { |
1737 | 1740 |
|
1738 | 1741 | fn suggest_binding_for_closure_capture_self( |
1739 | 1742 | &self, |
1740 | | - err: &mut Diagnostic, |
| 1743 | + err: &mut DiagnosticBuilder<'_>, |
1741 | 1744 | issued_spans: &UseSpans<'tcx>, |
1742 | 1745 | ) { |
1743 | 1746 | let UseSpans::ClosureUse { capture_kind_span, .. } = issued_spans else { return }; |
@@ -2984,7 +2987,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { |
2984 | 2987 | self.buffer_error(err); |
2985 | 2988 | } |
2986 | 2989 |
|
2987 | | - fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut Diagnostic) { |
| 2990 | + fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut DiagnosticBuilder<'_>) { |
2988 | 2991 | let tcx = self.infcx.tcx; |
2989 | 2992 | if let ( |
2990 | 2993 | Some(Terminator { |
@@ -3520,7 +3523,11 @@ enum AnnotatedBorrowFnSignature<'tcx> { |
3520 | 3523 | impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { |
3521 | 3524 | /// Annotate the provided diagnostic with information about borrow from the fn signature that |
3522 | 3525 | /// helps explain. |
3523 | | - pub(crate) fn emit(&self, cx: &mut MirBorrowckCtxt<'_, 'tcx>, diag: &mut Diagnostic) -> String { |
| 3526 | + pub(crate) fn emit( |
| 3527 | + &self, |
| 3528 | + cx: &mut MirBorrowckCtxt<'_, 'tcx>, |
| 3529 | + diag: &mut DiagnosticBuilder<'_>, |
| 3530 | + ) -> String { |
3524 | 3531 | match self { |
3525 | 3532 | &AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => { |
3526 | 3533 | diag.span_label( |
|
0 commit comments