|
6 | 6 | use either::Either;
|
7 | 7 | use rustc_data_structures::captures::Captures;
|
8 | 8 | use rustc_data_structures::fx::FxIndexSet;
|
9 |
| -use rustc_errors::{ |
10 |
| - codes::*, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan, |
11 |
| -}; |
| 9 | +use rustc_errors::{codes::*, struct_span_code_err, Applicability, DiagnosticBuilder, MultiSpan}; |
12 | 10 | use rustc_hir as hir;
|
13 | 11 | use rustc_hir::def::{DefKind, Res};
|
14 | 12 | use rustc_hir::intravisit::{walk_block, walk_expr, Visitor};
|
@@ -629,7 +627,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
629 | 627 |
|
630 | 628 | fn suggest_assign_value(
|
631 | 629 | &self,
|
632 |
| - err: &mut Diagnostic, |
| 630 | + err: &mut DiagnosticBuilder<'_>, |
633 | 631 | moved_place: PlaceRef<'tcx>,
|
634 | 632 | sugg_span: Span,
|
635 | 633 | ) {
|
@@ -668,7 +666,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
668 | 666 |
|
669 | 667 | fn suggest_borrow_fn_like(
|
670 | 668 | &self,
|
671 |
| - err: &mut Diagnostic, |
| 669 | + err: &mut DiagnosticBuilder<'_>, |
672 | 670 | ty: Ty<'tcx>,
|
673 | 671 | move_sites: &[MoveSite],
|
674 | 672 | value_name: &str,
|
@@ -736,7 +734,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
736 | 734 |
|
737 | 735 | fn suggest_cloning(
|
738 | 736 | &self,
|
739 |
| - err: &mut Diagnostic, |
| 737 | + err: &mut DiagnosticBuilder<'_>, |
740 | 738 | ty: Ty<'tcx>,
|
741 | 739 | expr: &hir::Expr<'_>,
|
742 | 740 | span: Span,
|
@@ -772,7 +770,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
772 | 770 | }
|
773 | 771 | }
|
774 | 772 |
|
775 |
| - fn suggest_adding_copy_bounds(&self, err: &mut Diagnostic, ty: Ty<'tcx>, span: Span) { |
| 773 | + fn suggest_adding_copy_bounds( |
| 774 | + &self, |
| 775 | + err: &mut DiagnosticBuilder<'_>, |
| 776 | + ty: Ty<'tcx>, |
| 777 | + span: Span, |
| 778 | + ) { |
776 | 779 | let tcx = self.infcx.tcx;
|
777 | 780 | let generics = tcx.generics_of(self.mir_def_id());
|
778 | 781 |
|
@@ -1206,7 +1209,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
1206 | 1209 | #[instrument(level = "debug", skip(self, err))]
|
1207 | 1210 | fn suggest_using_local_if_applicable(
|
1208 | 1211 | &self,
|
1209 |
| - err: &mut Diagnostic, |
| 1212 | + err: &mut DiagnosticBuilder<'_>, |
1210 | 1213 | location: Location,
|
1211 | 1214 | issued_borrow: &BorrowData<'tcx>,
|
1212 | 1215 | explanation: BorrowExplanation<'tcx>,
|
@@ -1302,7 +1305,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
1302 | 1305 |
|
1303 | 1306 | fn suggest_slice_method_if_applicable(
|
1304 | 1307 | &self,
|
1305 |
| - err: &mut Diagnostic, |
| 1308 | + err: &mut DiagnosticBuilder<'_>, |
1306 | 1309 | place: Place<'tcx>,
|
1307 | 1310 | borrowed_place: Place<'tcx>,
|
1308 | 1311 | ) {
|
@@ -1411,7 +1414,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
1411 | 1414 | /// ```
|
1412 | 1415 | pub(crate) fn explain_iterator_advancement_in_for_loop_if_applicable(
|
1413 | 1416 | &self,
|
1414 |
| - err: &mut Diagnostic, |
| 1417 | + err: &mut DiagnosticBuilder<'_>, |
1415 | 1418 | span: Span,
|
1416 | 1419 | issued_spans: &UseSpans<'tcx>,
|
1417 | 1420 | ) {
|
@@ -1598,7 +1601,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
1598 | 1601 | /// ```
|
1599 | 1602 | fn suggest_using_closure_argument_instead_of_capture(
|
1600 | 1603 | &self,
|
1601 |
| - err: &mut Diagnostic, |
| 1604 | + err: &mut DiagnosticBuilder<'_>, |
1602 | 1605 | borrowed_place: Place<'tcx>,
|
1603 | 1606 | issued_spans: &UseSpans<'tcx>,
|
1604 | 1607 | ) {
|
@@ -1732,7 +1735,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
1732 | 1735 |
|
1733 | 1736 | fn suggest_binding_for_closure_capture_self(
|
1734 | 1737 | &self,
|
1735 |
| - err: &mut Diagnostic, |
| 1738 | + err: &mut DiagnosticBuilder<'_>, |
1736 | 1739 | issued_spans: &UseSpans<'tcx>,
|
1737 | 1740 | ) {
|
1738 | 1741 | let UseSpans::ClosureUse { capture_kind_span, .. } = issued_spans else { return };
|
@@ -2978,7 +2981,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
2978 | 2981 | self.buffer_error(err);
|
2979 | 2982 | }
|
2980 | 2983 |
|
2981 |
| - fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut Diagnostic) { |
| 2984 | + fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut DiagnosticBuilder<'_>) { |
2982 | 2985 | let tcx = self.infcx.tcx;
|
2983 | 2986 | if let (
|
2984 | 2987 | 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