|
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 |
|
@@ -1207,7 +1210,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
1207 | 1210 | #[instrument(level = "debug", skip(self, err))]
|
1208 | 1211 | fn suggest_using_local_if_applicable(
|
1209 | 1212 | &self,
|
1210 |
| - err: &mut Diagnostic, |
| 1213 | + err: &mut DiagnosticBuilder<'_>, |
1211 | 1214 | location: Location,
|
1212 | 1215 | issued_borrow: &BorrowData<'tcx>,
|
1213 | 1216 | explanation: BorrowExplanation<'tcx>,
|
@@ -1303,7 +1306,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
1303 | 1306 |
|
1304 | 1307 | fn suggest_slice_method_if_applicable(
|
1305 | 1308 | &self,
|
1306 |
| - err: &mut Diagnostic, |
| 1309 | + err: &mut DiagnosticBuilder<'_>, |
1307 | 1310 | place: Place<'tcx>,
|
1308 | 1311 | borrowed_place: Place<'tcx>,
|
1309 | 1312 | ) {
|
@@ -1412,7 +1415,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
1412 | 1415 | /// ```
|
1413 | 1416 | pub(crate) fn explain_iterator_advancement_in_for_loop_if_applicable(
|
1414 | 1417 | &self,
|
1415 |
| - err: &mut Diagnostic, |
| 1418 | + err: &mut DiagnosticBuilder<'_>, |
1416 | 1419 | span: Span,
|
1417 | 1420 | issued_spans: &UseSpans<'tcx>,
|
1418 | 1421 | ) {
|
@@ -1599,7 +1602,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
1599 | 1602 | /// ```
|
1600 | 1603 | fn suggest_using_closure_argument_instead_of_capture(
|
1601 | 1604 | &self,
|
1602 |
| - err: &mut Diagnostic, |
| 1605 | + err: &mut DiagnosticBuilder<'_>, |
1603 | 1606 | borrowed_place: Place<'tcx>,
|
1604 | 1607 | issued_spans: &UseSpans<'tcx>,
|
1605 | 1608 | ) {
|
@@ -1734,7 +1737,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
1734 | 1737 |
|
1735 | 1738 | fn suggest_binding_for_closure_capture_self(
|
1736 | 1739 | &self,
|
1737 |
| - err: &mut Diagnostic, |
| 1740 | + err: &mut DiagnosticBuilder<'_>, |
1738 | 1741 | issued_spans: &UseSpans<'tcx>,
|
1739 | 1742 | ) {
|
1740 | 1743 | let UseSpans::ClosureUse { capture_kind_span, .. } = issued_spans else { return };
|
@@ -2977,7 +2980,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
2977 | 2980 | self.buffer_error(err);
|
2978 | 2981 | }
|
2979 | 2982 |
|
2980 |
| - fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut Diagnostic) { |
| 2983 | + fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut DiagnosticBuilder<'_>) { |
2981 | 2984 | let tcx = self.infcx.tcx;
|
2982 | 2985 | if let (
|
2983 | 2986 | Some(Terminator {
|
@@ -3513,7 +3516,11 @@ enum AnnotatedBorrowFnSignature<'tcx> {
|
3513 | 3516 | impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
|
3514 | 3517 | /// Annotate the provided diagnostic with information about borrow from the fn signature that
|
3515 | 3518 | /// helps explain.
|
3516 |
| - pub(crate) fn emit(&self, cx: &mut MirBorrowckCtxt<'_, 'tcx>, diag: &mut Diagnostic) -> String { |
| 3519 | + pub(crate) fn emit( |
| 3520 | + &self, |
| 3521 | + cx: &mut MirBorrowckCtxt<'_, 'tcx>, |
| 3522 | + diag: &mut DiagnosticBuilder<'_>, |
| 3523 | + ) -> String { |
3517 | 3524 | match self {
|
3518 | 3525 | &AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => {
|
3519 | 3526 | diag.span_label(
|
|
0 commit comments