@@ -229,7 +229,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
229
229
seen_spans.insert(move_span);
230
230
}
231
231
232
- use_spans.var_path_only_subdiag(&mut err, desired_action);
232
+ use_spans.var_path_only_subdiag(self.dcx(), &mut err, desired_action);
233
233
234
234
if !is_loop_move {
235
235
err.span_label(
@@ -291,18 +291,24 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
291
291
if needs_note {
292
292
if let Some(local) = place.as_local() {
293
293
let span = self.body.local_decls[local].source_info.span;
294
- err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
295
- is_partial_move,
296
- ty,
297
- place: ¬e_msg,
298
- span,
299
- });
294
+ err.subdiagnostic(
295
+ self.dcx(),
296
+ crate::session_diagnostics::TypeNoCopy::Label {
297
+ is_partial_move,
298
+ ty,
299
+ place: ¬e_msg,
300
+ span,
301
+ },
302
+ );
300
303
} else {
301
- err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Note {
302
- is_partial_move,
303
- ty,
304
- place: ¬e_msg,
305
- });
304
+ err.subdiagnostic(
305
+ self.dcx(),
306
+ crate::session_diagnostics::TypeNoCopy::Note {
307
+ is_partial_move,
308
+ ty,
309
+ place: ¬e_msg,
310
+ },
311
+ );
306
312
};
307
313
}
308
314
@@ -557,7 +563,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
557
563
E0381,
558
564
"{used} binding {desc}{isnt_initialized}"
559
565
);
560
- use_spans.var_path_only_subdiag(&mut err, desired_action);
566
+ use_spans.var_path_only_subdiag(self.dcx(), &mut err, desired_action);
561
567
562
568
if let InitializationRequiringAction::PartialAssignment
563
569
| InitializationRequiringAction::Assignment = desired_action
@@ -848,9 +854,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
848
854
&value_msg,
849
855
);
850
856
851
- borrow_spans.var_path_only_subdiag(&mut err, crate::InitializationRequiringAction::Borrow);
857
+ borrow_spans.var_path_only_subdiag(
858
+ self.dcx(),
859
+ &mut err,
860
+ crate::InitializationRequiringAction::Borrow,
861
+ );
852
862
853
- move_spans.var_subdiag(None , &mut err, None, |kind, var_span| {
863
+ move_spans.var_subdiag(self.dcx() , &mut err, None, |kind, var_span| {
854
864
use crate::session_diagnostics::CaptureVarCause::*;
855
865
match kind {
856
866
hir::ClosureKind::Coroutine(_) => MoveUseInCoroutine { var_span },
@@ -895,7 +905,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
895
905
borrow_span,
896
906
&self.describe_any_place(borrow.borrowed_place.as_ref()),
897
907
);
898
- borrow_spans.var_subdiag(None , &mut err, Some(borrow.kind), |kind, var_span| {
908
+ borrow_spans.var_subdiag(self.dcx() , &mut err, Some(borrow.kind), |kind, var_span| {
899
909
use crate::session_diagnostics::CaptureVarCause::*;
900
910
let place = &borrow.borrowed_place;
901
911
let desc_place = self.describe_any_place(place.as_ref());
@@ -1043,7 +1053,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1043
1053
"mutably borrow",
1044
1054
);
1045
1055
borrow_spans.var_subdiag(
1046
- None ,
1056
+ self.dcx() ,
1047
1057
&mut err,
1048
1058
Some(BorrowKind::Mut { kind: MutBorrowKind::ClosureCapture }),
1049
1059
|kind, var_span| {
@@ -1131,22 +1141,31 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1131
1141
};
1132
1142
1133
1143
if issued_spans == borrow_spans {
1134
- borrow_spans.var_subdiag(None, &mut err, Some(gen_borrow_kind), |kind, var_span| {
1135
- use crate::session_diagnostics::CaptureVarCause::*;
1136
- match kind {
1137
- hir::ClosureKind::Coroutine(_) => BorrowUsePlaceCoroutine {
1138
- place: desc_place,
1139
- var_span,
1140
- is_single_var: false,
1141
- },
1142
- hir::ClosureKind::Closure | hir::ClosureKind::CoroutineClosure(_) => {
1143
- BorrowUsePlaceClosure { place: desc_place, var_span, is_single_var: false }
1144
+ borrow_spans.var_subdiag(
1145
+ self.dcx(),
1146
+ &mut err,
1147
+ Some(gen_borrow_kind),
1148
+ |kind, var_span| {
1149
+ use crate::session_diagnostics::CaptureVarCause::*;
1150
+ match kind {
1151
+ hir::ClosureKind::Coroutine(_) => BorrowUsePlaceCoroutine {
1152
+ place: desc_place,
1153
+ var_span,
1154
+ is_single_var: false,
1155
+ },
1156
+ hir::ClosureKind::Closure | hir::ClosureKind::CoroutineClosure(_) => {
1157
+ BorrowUsePlaceClosure {
1158
+ place: desc_place,
1159
+ var_span,
1160
+ is_single_var: false,
1161
+ }
1162
+ }
1144
1163
}
1145
- }
1146
- } );
1164
+ },
1165
+ );
1147
1166
} else {
1148
1167
issued_spans.var_subdiag(
1149
- Some( self.dcx() ),
1168
+ self.dcx(),
1150
1169
&mut err,
1151
1170
Some(issued_borrow.kind),
1152
1171
|kind, var_span| {
@@ -1165,7 +1184,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1165
1184
);
1166
1185
1167
1186
borrow_spans.var_subdiag(
1168
- Some( self.dcx() ),
1187
+ self.dcx(),
1169
1188
&mut err,
1170
1189
Some(gen_borrow_kind),
1171
1190
|kind, var_span| {
@@ -2217,7 +2236,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2217
2236
err.span_label(borrow_span, "borrowed value does not live long enough");
2218
2237
err.span_label(drop_span, format!("`{name}` dropped here while still borrowed"));
2219
2238
2220
- borrow_spans.args_subdiag(&mut err, |args_span| {
2239
+ borrow_spans.args_subdiag(self.dcx(), &mut err, |args_span| {
2221
2240
crate::session_diagnostics::CaptureArgLabel::Capture {
2222
2241
is_within: borrow_spans.for_coroutine(),
2223
2242
args_span,
@@ -2476,7 +2495,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2476
2495
None,
2477
2496
);
2478
2497
2479
- borrow_spans.args_subdiag(&mut err, |args_span| {
2498
+ borrow_spans.args_subdiag(self.dcx(), &mut err, |args_span| {
2480
2499
crate::session_diagnostics::CaptureArgLabel::Capture {
2481
2500
is_within: borrow_spans.for_coroutine(),
2482
2501
args_span,
@@ -2935,7 +2954,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2935
2954
"assign",
2936
2955
);
2937
2956
2938
- loan_spans.var_subdiag(None , &mut err, Some(loan.kind), |kind, var_span| {
2957
+ loan_spans.var_subdiag(self.dcx() , &mut err, Some(loan.kind), |kind, var_span| {
2939
2958
use crate::session_diagnostics::CaptureVarCause::*;
2940
2959
match kind {
2941
2960
hir::ClosureKind::Coroutine(_) => BorrowUseInCoroutine { var_span },
@@ -2953,7 +2972,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2953
2972
2954
2973
let mut err = self.cannot_assign_to_borrowed(span, loan_span, &descr_place);
2955
2974
2956
- loan_spans.var_subdiag(None , &mut err, Some(loan.kind), |kind, var_span| {
2975
+ loan_spans.var_subdiag(self.dcx() , &mut err, Some(loan.kind), |kind, var_span| {
2957
2976
use crate::session_diagnostics::CaptureVarCause::*;
2958
2977
match kind {
2959
2978
hir::ClosureKind::Coroutine(_) => BorrowUseInCoroutine { var_span },
0 commit comments