@@ -22,7 +22,7 @@ use super::{InitializationRequiringAction, PrefixSet};
2222use super :: error_reporting:: { IncludingDowncast , UseSpans } ;
2323use crate :: dataflow:: drop_flag_effects;
2424use crate :: dataflow:: indexes:: { MovePathIndex , MoveOutIndex } ;
25- use crate :: util:: borrowck_errors:: BorrowckErrors ;
25+ use crate :: util:: borrowck_errors;
2626
2727#[ derive( Debug ) ]
2828struct MoveSite {
@@ -89,7 +89,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
8989 Some ( name) => format ! ( "`{}`" , name) ,
9090 None => "value" . to_owned ( ) ,
9191 } ;
92- let mut err = self . infcx . tcx . cannot_act_on_uninitialized_variable (
92+ let mut err = self . cannot_act_on_uninitialized_variable (
9393 span,
9494 desired_action. as_noun ( ) ,
9595 & self . describe_place_with_options ( moved_place, IncludingDowncast ( true ) )
@@ -119,7 +119,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
119119
120120 let msg = "" ; //FIXME: add "partially " or "collaterally "
121121
122- let mut err = self . infcx . tcx . cannot_act_on_moved_value (
122+ let mut err = self . cannot_act_on_moved_value (
123123 span,
124124 desired_action. as_noun ( ) ,
125125 msg,
@@ -265,7 +265,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
265265 "report_move_out_while_borrowed: location={:?} place={:?} span={:?} borrow={:?}" ,
266266 location, place, span, borrow
267267 ) ;
268- let tcx = self . infcx . tcx ;
269268 let value_msg = match self . describe_place ( place) {
270269 Some ( name) => format ! ( "`{}`" , name) ,
271270 None => "value" . to_owned ( ) ,
@@ -281,7 +280,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
281280 let move_spans = self . move_spans ( place, location) ;
282281 let span = move_spans. args_or_use ( ) ;
283282
284- let mut err = tcx . cannot_move_when_borrowed (
283+ let mut err = self . cannot_move_when_borrowed (
285284 span,
286285 & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
287286 ) ;
@@ -312,8 +311,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
312311 ( place, _span) : ( & Place < ' tcx > , Span ) ,
313312 borrow : & BorrowData < ' tcx > ,
314313 ) -> DiagnosticBuilder < ' cx > {
315- let tcx = self . infcx . tcx ;
316-
317314 let borrow_spans = self . retrieve_borrow_spans ( borrow) ;
318315 let borrow_span = borrow_spans. args_or_use ( ) ;
319316
@@ -322,7 +319,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
322319 let use_spans = self . move_spans ( place, location) ;
323320 let span = use_spans. var_or_use ( ) ;
324321
325- let mut err = tcx . cannot_use_when_mutably_borrowed (
322+ let mut err = self . cannot_use_when_mutably_borrowed (
326323 span,
327324 & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
328325 borrow_span,
@@ -372,7 +369,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
372369 } ;
373370
374371 // FIXME: supply non-"" `opt_via` when appropriate
375- let tcx = self . infcx . tcx ;
376372 let first_borrow_desc;
377373 let mut err = match (
378374 gen_borrow_kind,
@@ -384,7 +380,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
384380 ) {
385381 ( BorrowKind :: Shared , lft, _, BorrowKind :: Mut { .. } , _, rgt) => {
386382 first_borrow_desc = "mutable " ;
387- tcx . cannot_reborrow_already_borrowed (
383+ self . cannot_reborrow_already_borrowed (
388384 span,
389385 & desc_place,
390386 & msg_place,
@@ -398,7 +394,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
398394 }
399395 ( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Shared , rgt, _) => {
400396 first_borrow_desc = "immutable " ;
401- tcx . cannot_reborrow_already_borrowed (
397+ self . cannot_reborrow_already_borrowed (
402398 span,
403399 & desc_place,
404400 & msg_place,
@@ -413,7 +409,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
413409
414410 ( BorrowKind :: Mut { .. } , _, _, BorrowKind :: Mut { .. } , _, _) => {
415411 first_borrow_desc = "first " ;
416- tcx . cannot_mutably_borrow_multiply (
412+ self . cannot_mutably_borrow_multiply (
417413 span,
418414 & desc_place,
419415 & msg_place,
@@ -425,7 +421,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
425421
426422 ( BorrowKind :: Unique , _, _, BorrowKind :: Unique , _, _) => {
427423 first_borrow_desc = "first " ;
428- tcx . cannot_uniquely_borrow_by_two_closures (
424+ self . cannot_uniquely_borrow_by_two_closures (
429425 span,
430426 & desc_place,
431427 issued_span,
@@ -435,7 +431,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
435431
436432 ( BorrowKind :: Mut { .. } , _, _, BorrowKind :: Shallow , _, _)
437433 | ( BorrowKind :: Unique , _, _, BorrowKind :: Shallow , _, _) => {
438- let mut err = tcx . cannot_mutate_in_match_guard (
434+ let mut err = self . cannot_mutate_in_match_guard (
439435 span,
440436 issued_span,
441437 & desc_place,
@@ -453,7 +449,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
453449
454450 ( BorrowKind :: Unique , _, _, _, _, _) => {
455451 first_borrow_desc = "first " ;
456- tcx . cannot_uniquely_borrow_by_one_closure (
452+ self . cannot_uniquely_borrow_by_one_closure (
457453 span,
458454 container_name,
459455 & desc_place,
@@ -467,7 +463,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
467463
468464 ( BorrowKind :: Shared , lft, _, BorrowKind :: Unique , _, _) => {
469465 first_borrow_desc = "first " ;
470- tcx . cannot_reborrow_already_uniquely_borrowed (
466+ self . cannot_reborrow_already_uniquely_borrowed (
471467 span,
472468 container_name,
473469 & desc_place,
@@ -482,7 +478,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
482478
483479 ( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Unique , _, _) => {
484480 first_borrow_desc = "first " ;
485- tcx . cannot_reborrow_already_uniquely_borrowed (
481+ self . cannot_reborrow_already_uniquely_borrowed (
486482 span,
487483 container_name,
488484 & desc_place,
@@ -821,7 +817,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
821817 }
822818 }
823819
824- let mut err = self . infcx . tcx . path_does_not_live_long_enough (
820+ let mut err = self . path_does_not_live_long_enough (
825821 borrow_span,
826822 & format ! ( "`{}`" , name) ,
827823 ) ;
@@ -912,9 +908,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
912908 let borrow_spans = self . retrieve_borrow_spans ( borrow) ;
913909 let borrow_span = borrow_spans. var_or_use ( ) ;
914910
915- let mut err = self . infcx
916- . tcx
917- . cannot_borrow_across_destructor ( borrow_span) ;
911+ let mut err = self . cannot_borrow_across_destructor ( borrow_span) ;
918912
919913 let what_was_dropped = match self . describe_place ( place) {
920914 Some ( name) => format ! ( "`{}`" , name. as_str( ) ) ,
@@ -965,9 +959,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
965959 drop_span, borrow_span
966960 ) ;
967961
968- let mut err = self . infcx
969- . tcx
970- . thread_local_value_does_not_live_long_enough ( borrow_span) ;
962+ let mut err = self . thread_local_value_does_not_live_long_enough ( borrow_span) ;
971963
972964 err. span_label (
973965 borrow_span,
@@ -1011,8 +1003,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10111003 }
10121004 }
10131005
1014- let tcx = self . infcx . tcx ;
1015- let mut err = tcx. temporary_value_borrowed_for_too_long ( proper_span) ;
1006+ let mut err = self . temporary_value_borrowed_for_too_long ( proper_span) ;
10161007 err. span_label (
10171008 proper_span,
10181009 "creates a temporary which is freed while still in use" ,
@@ -1055,8 +1046,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10551046 category : ConstraintCategory ,
10561047 opt_place_desc : Option < & String > ,
10571048 ) -> Option < DiagnosticBuilder < ' cx > > {
1058- let tcx = self . infcx . tcx ;
1059-
10601049 let return_kind = match category {
10611050 ConstraintCategory :: Return => "return" ,
10621051 ConstraintCategory :: Yield => "yield" ,
@@ -1119,7 +1108,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11191108 }
11201109 } ;
11211110
1122- let mut err = tcx . cannot_return_reference_to_local (
1111+ let mut err = self . cannot_return_reference_to_local (
11231112 return_span,
11241113 return_kind,
11251114 reference_desc,
@@ -1144,7 +1133,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11441133 ) -> DiagnosticBuilder < ' cx > {
11451134 let tcx = self . infcx . tcx ;
11461135
1147- let mut err = tcx . cannot_capture_in_long_lived_closure (
1136+ let mut err = self . cannot_capture_in_long_lived_closure (
11481137 args_span,
11491138 captured_var,
11501139 var_span,
@@ -1203,7 +1192,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12031192 "function"
12041193 } ;
12051194
1206- let mut err = tcx. borrowed_data_escapes_closure ( escape_span, escapes_from) ;
1195+ let mut err = borrowck_errors:: borrowed_data_escapes_closure (
1196+ tcx,
1197+ escape_span,
1198+ escapes_from,
1199+ ) ;
12071200
12081201 err. span_label (
12091202 upvar_span,
@@ -1345,9 +1338,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13451338 let loan_spans = self . retrieve_borrow_spans ( loan) ;
13461339 let loan_span = loan_spans. args_or_use ( ) ;
13471340
1348- let tcx = self . infcx . tcx ;
13491341 if loan. kind == BorrowKind :: Shallow {
1350- let mut err = tcx . cannot_mutate_in_match_guard (
1342+ let mut err = self . cannot_mutate_in_match_guard (
13511343 span,
13521344 loan_span,
13531345 & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
@@ -1363,7 +1355,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13631355 return ;
13641356 }
13651357
1366- let mut err = tcx . cannot_assign_to_borrowed (
1358+ let mut err = self . cannot_assign_to_borrowed (
13671359 span,
13681360 loan_span,
13691361 & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
@@ -1427,7 +1419,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14271419 Some ( decl) => ( self . describe_place ( err_place) , decl. source_info . span ) ,
14281420 } ;
14291421
1430- let mut err = self . infcx . tcx . cannot_reassign_immutable (
1422+ let mut err = self . cannot_reassign_immutable (
14311423 span,
14321424 place_description. as_ref ( ) . map ( AsRef :: as_ref) . unwrap_or ( "_" ) ,
14331425 from_arg,
0 commit comments