@@ -228,7 +228,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
228
228
seen_spans. insert ( move_span) ;
229
229
}
230
230
231
- use_spans. var_path_only_subdiag ( self . dcx ( ) , & mut err, desired_action) ;
231
+ use_spans. var_path_only_subdiag ( & mut err, desired_action) ;
232
232
233
233
if !is_loop_move {
234
234
err. span_label (
@@ -303,24 +303,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
303
303
if needs_note {
304
304
if let Some ( local) = place. as_local ( ) {
305
305
let span = self . body . local_decls [ local] . source_info . span ;
306
- err. subdiagnostic (
307
- self . dcx ( ) ,
308
- crate :: session_diagnostics:: TypeNoCopy :: Label {
309
- is_partial_move,
310
- ty,
311
- place : & note_msg,
312
- span,
313
- } ,
314
- ) ;
306
+ err. subdiagnostic ( crate :: session_diagnostics:: TypeNoCopy :: Label {
307
+ is_partial_move,
308
+ ty,
309
+ place : & note_msg,
310
+ span,
311
+ } ) ;
315
312
} else {
316
- err. subdiagnostic (
317
- self . dcx ( ) ,
318
- crate :: session_diagnostics:: TypeNoCopy :: Note {
319
- is_partial_move,
320
- ty,
321
- place : & note_msg,
322
- } ,
323
- ) ;
313
+ err. subdiagnostic ( crate :: session_diagnostics:: TypeNoCopy :: Note {
314
+ is_partial_move,
315
+ ty,
316
+ place : & note_msg,
317
+ } ) ;
324
318
} ;
325
319
}
326
320
@@ -597,7 +591,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
597
591
E0381 ,
598
592
"{used} binding {desc}{isnt_initialized}"
599
593
) ;
600
- use_spans. var_path_only_subdiag ( self . dcx ( ) , & mut err, desired_action) ;
594
+ use_spans. var_path_only_subdiag ( & mut err, desired_action) ;
601
595
602
596
if let InitializationRequiringAction :: PartialAssignment
603
597
| InitializationRequiringAction :: Assignment = desired_action
@@ -996,7 +990,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
996
990
& self ,
997
991
err : & mut Diag < ' _ > ,
998
992
ty : Ty < ' tcx > ,
999
- expr : & ' cx hir:: Expr < ' cx > ,
993
+ expr : & hir:: Expr < ' _ > ,
1000
994
) {
1001
995
let typeck_results = self . infcx . tcx . typeck ( self . mir_def_id ( ) ) ;
1002
996
let hir:: ExprKind :: Struct ( struct_qpath, fields, Some ( base) ) = expr. kind else { return } ;
@@ -1084,8 +1078,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1084
1078
& self ,
1085
1079
err : & mut Diag < ' _ > ,
1086
1080
ty : Ty < ' tcx > ,
1087
- mut expr : & ' cx hir:: Expr < ' cx > ,
1088
- mut other_expr : Option < & ' cx hir:: Expr < ' cx > > ,
1081
+ mut expr : & ' tcx hir:: Expr < ' tcx > ,
1082
+ mut other_expr : Option < & ' tcx hir:: Expr < ' tcx > > ,
1089
1083
use_spans : Option < UseSpans < ' tcx > > ,
1090
1084
) {
1091
1085
if let hir:: ExprKind :: Struct ( _, _, Some ( _) ) = expr. kind {
@@ -1410,13 +1404,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1410
1404
& value_msg,
1411
1405
) ;
1412
1406
1413
- borrow_spans. var_path_only_subdiag (
1414
- self . dcx ( ) ,
1415
- & mut err,
1416
- crate :: InitializationRequiringAction :: Borrow ,
1417
- ) ;
1407
+ borrow_spans. var_path_only_subdiag ( & mut err, crate :: InitializationRequiringAction :: Borrow ) ;
1418
1408
1419
- move_spans. var_subdiag ( self . dcx ( ) , & mut err, None , |kind, var_span| {
1409
+ move_spans. var_subdiag ( & mut err, None , |kind, var_span| {
1420
1410
use crate :: session_diagnostics:: CaptureVarCause :: * ;
1421
1411
match kind {
1422
1412
hir:: ClosureKind :: Coroutine ( _) => MoveUseInCoroutine { var_span } ,
@@ -1468,7 +1458,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1468
1458
borrow_span,
1469
1459
& self . describe_any_place ( borrow. borrowed_place . as_ref ( ) ) ,
1470
1460
) ;
1471
- borrow_spans. var_subdiag ( self . dcx ( ) , & mut err, Some ( borrow. kind ) , |kind, var_span| {
1461
+ borrow_spans. var_subdiag ( & mut err, Some ( borrow. kind ) , |kind, var_span| {
1472
1462
use crate :: session_diagnostics:: CaptureVarCause :: * ;
1473
1463
let place = & borrow. borrowed_place ;
1474
1464
let desc_place = self . describe_any_place ( place. as_ref ( ) ) ;
@@ -1633,7 +1623,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1633
1623
"mutably borrow" ,
1634
1624
) ;
1635
1625
borrow_spans. var_subdiag (
1636
- self . dcx ( ) ,
1637
1626
& mut err,
1638
1627
Some ( BorrowKind :: Mut { kind : MutBorrowKind :: ClosureCapture } ) ,
1639
1628
|kind, var_span| {
@@ -1730,64 +1719,45 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1730
1719
} ;
1731
1720
1732
1721
if issued_spans == borrow_spans {
1733
- borrow_spans. var_subdiag (
1734
- self . dcx ( ) ,
1735
- & mut err,
1736
- Some ( gen_borrow_kind) ,
1737
- |kind, var_span| {
1738
- use crate :: session_diagnostics:: CaptureVarCause :: * ;
1739
- match kind {
1740
- hir:: ClosureKind :: Coroutine ( _) => BorrowUsePlaceCoroutine {
1741
- place : desc_place,
1742
- var_span,
1743
- is_single_var : false ,
1744
- } ,
1745
- hir:: ClosureKind :: Closure | hir:: ClosureKind :: CoroutineClosure ( _) => {
1746
- BorrowUsePlaceClosure {
1747
- place : desc_place,
1748
- var_span,
1749
- is_single_var : false ,
1750
- }
1751
- }
1722
+ borrow_spans. var_subdiag ( & mut err, Some ( gen_borrow_kind) , |kind, var_span| {
1723
+ use crate :: session_diagnostics:: CaptureVarCause :: * ;
1724
+ match kind {
1725
+ hir:: ClosureKind :: Coroutine ( _) => BorrowUsePlaceCoroutine {
1726
+ place : desc_place,
1727
+ var_span,
1728
+ is_single_var : false ,
1729
+ } ,
1730
+ hir:: ClosureKind :: Closure | hir:: ClosureKind :: CoroutineClosure ( _) => {
1731
+ BorrowUsePlaceClosure { place : desc_place, var_span, is_single_var : false }
1752
1732
}
1753
- } ,
1754
- ) ;
1733
+ }
1734
+ } ) ;
1755
1735
} else {
1756
- issued_spans. var_subdiag (
1757
- self . dcx ( ) ,
1758
- & mut err,
1759
- Some ( issued_borrow. kind ) ,
1760
- |kind, var_span| {
1761
- use crate :: session_diagnostics:: CaptureVarCause :: * ;
1762
- let borrow_place = & issued_borrow. borrowed_place ;
1763
- let borrow_place_desc = self . describe_any_place ( borrow_place. as_ref ( ) ) ;
1764
- match kind {
1765
- hir:: ClosureKind :: Coroutine ( _) => {
1766
- FirstBorrowUsePlaceCoroutine { place : borrow_place_desc, var_span }
1767
- }
1768
- hir:: ClosureKind :: Closure | hir:: ClosureKind :: CoroutineClosure ( _) => {
1769
- FirstBorrowUsePlaceClosure { place : borrow_place_desc, var_span }
1770
- }
1736
+ issued_spans. var_subdiag ( & mut err, Some ( issued_borrow. kind ) , |kind, var_span| {
1737
+ use crate :: session_diagnostics:: CaptureVarCause :: * ;
1738
+ let borrow_place = & issued_borrow. borrowed_place ;
1739
+ let borrow_place_desc = self . describe_any_place ( borrow_place. as_ref ( ) ) ;
1740
+ match kind {
1741
+ hir:: ClosureKind :: Coroutine ( _) => {
1742
+ FirstBorrowUsePlaceCoroutine { place : borrow_place_desc, var_span }
1771
1743
}
1772
- } ,
1773
- ) ;
1744
+ hir:: ClosureKind :: Closure | hir:: ClosureKind :: CoroutineClosure ( _) => {
1745
+ FirstBorrowUsePlaceClosure { place : borrow_place_desc, var_span }
1746
+ }
1747
+ }
1748
+ } ) ;
1774
1749
1775
- borrow_spans. var_subdiag (
1776
- self . dcx ( ) ,
1777
- & mut err,
1778
- Some ( gen_borrow_kind) ,
1779
- |kind, var_span| {
1780
- use crate :: session_diagnostics:: CaptureVarCause :: * ;
1781
- match kind {
1782
- hir:: ClosureKind :: Coroutine ( _) => {
1783
- SecondBorrowUsePlaceCoroutine { place : desc_place, var_span }
1784
- }
1785
- hir:: ClosureKind :: Closure | hir:: ClosureKind :: CoroutineClosure ( _) => {
1786
- SecondBorrowUsePlaceClosure { place : desc_place, var_span }
1787
- }
1750
+ borrow_spans. var_subdiag ( & mut err, Some ( gen_borrow_kind) , |kind, var_span| {
1751
+ use crate :: session_diagnostics:: CaptureVarCause :: * ;
1752
+ match kind {
1753
+ hir:: ClosureKind :: Coroutine ( _) => {
1754
+ SecondBorrowUsePlaceCoroutine { place : desc_place, var_span }
1788
1755
}
1789
- } ,
1790
- ) ;
1756
+ hir:: ClosureKind :: Closure | hir:: ClosureKind :: CoroutineClosure ( _) => {
1757
+ SecondBorrowUsePlaceClosure { place : desc_place, var_span }
1758
+ }
1759
+ }
1760
+ } ) ;
1791
1761
}
1792
1762
1793
1763
if union_type_name != "" {
@@ -2016,7 +1986,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2016
1986
) ;
2017
1987
}
2018
1988
2019
- pub ( crate ) fn find_expr ( & self , span : Span ) -> Option < & hir:: Expr < ' _ > > {
1989
+ pub ( crate ) fn find_expr ( & self , span : Span ) -> Option < & ' tcx hir:: Expr < ' tcx > > {
2020
1990
let tcx = self . infcx . tcx ;
2021
1991
let body_id = tcx. hir_node ( self . mir_hir_id ( ) ) . body_id ( ) ?;
2022
1992
let mut expr_finder = FindExprBySpan :: new ( span, tcx) ;
@@ -2961,7 +2931,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2961
2931
err. span_label ( borrow_span, "borrowed value does not live long enough" ) ;
2962
2932
err. span_label ( drop_span, format ! ( "`{name}` dropped here while still borrowed" ) ) ;
2963
2933
2964
- borrow_spans. args_subdiag ( self . dcx ( ) , & mut err, |args_span| {
2934
+ borrow_spans. args_subdiag ( & mut err, |args_span| {
2965
2935
crate :: session_diagnostics:: CaptureArgLabel :: Capture {
2966
2936
is_within : borrow_spans. for_coroutine ( ) ,
2967
2937
args_span,
@@ -3219,7 +3189,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
3219
3189
None ,
3220
3190
) ;
3221
3191
3222
- borrow_spans. args_subdiag ( self . dcx ( ) , & mut err, |args_span| {
3192
+ borrow_spans. args_subdiag ( & mut err, |args_span| {
3223
3193
crate :: session_diagnostics:: CaptureArgLabel :: Capture {
3224
3194
is_within : borrow_spans. for_coroutine ( ) ,
3225
3195
args_span,
@@ -3680,7 +3650,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
3680
3650
"assign" ,
3681
3651
) ;
3682
3652
3683
- loan_spans. var_subdiag ( self . dcx ( ) , & mut err, Some ( loan. kind ) , |kind, var_span| {
3653
+ loan_spans. var_subdiag ( & mut err, Some ( loan. kind ) , |kind, var_span| {
3684
3654
use crate :: session_diagnostics:: CaptureVarCause :: * ;
3685
3655
match kind {
3686
3656
hir:: ClosureKind :: Coroutine ( _) => BorrowUseInCoroutine { var_span } ,
@@ -3698,7 +3668,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
3698
3668
3699
3669
let mut err = self . cannot_assign_to_borrowed ( span, loan_span, & descr_place) ;
3700
3670
3701
- loan_spans. var_subdiag ( self . dcx ( ) , & mut err, Some ( loan. kind ) , |kind, var_span| {
3671
+ loan_spans. var_subdiag ( & mut err, Some ( loan. kind ) , |kind, var_span| {
3702
3672
use crate :: session_diagnostics:: CaptureVarCause :: * ;
3703
3673
match kind {
3704
3674
hir:: ClosureKind :: Coroutine ( _) => BorrowUseInCoroutine { var_span } ,
0 commit comments