@@ -15,9 +15,9 @@ use rustc::hir;
1515use rustc:: hir:: def_id:: DefId ;
1616use rustc:: middle:: region:: ScopeTree ;
1717use rustc:: mir:: {
18- self , AggregateKind , BindingForm , BorrowKind , ClearCrossCrate , FakeReadCause , Field , Local ,
19- LocalDecl , LocalKind , Location , Operand , Place , PlaceProjection , ProjectionElem , Rvalue ,
20- Statement , StatementKind , TerminatorKind , VarBindingForm ,
18+ self , AggregateKind , BindingForm , BorrowKind , ClearCrossCrate , Field , Local ,
19+ LocalDecl , LocalKind , Location , Operand , Place , PlaceProjection , ProjectionElem ,
20+ Rvalue , Statement , StatementKind , TerminatorKind , VarBindingForm ,
2121} ;
2222use rustc:: ty;
2323use rustc:: util:: ppaux:: with_highlight_region_for_bound_region;
@@ -262,7 +262,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
262262 move_spans. var_span_label ( & mut err, "move occurs due to use in closure" ) ;
263263
264264 self . explain_why_borrow_contains_point ( context, borrow, None )
265- . emit ( self . infcx . tcx , & mut err) ;
265+ . emit ( self . infcx . tcx , & mut err, String :: new ( ) ) ;
266266 err. buffer ( & mut self . errors_buffer ) ;
267267 }
268268
@@ -299,7 +299,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
299299 } ) ;
300300
301301 self . explain_why_borrow_contains_point ( context, borrow, None )
302- . emit ( self . infcx . tcx , & mut err) ;
302+ . emit ( self . infcx . tcx , & mut err, String :: new ( ) ) ;
303303 err. buffer ( & mut self . errors_buffer ) ;
304304 }
305305
@@ -319,6 +319,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
319319 let desc_place = self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ;
320320 let tcx = self . infcx . tcx ;
321321
322+ let first_borrow_desc;
323+
322324 // FIXME: supply non-"" `opt_via` when appropriate
323325 let mut err = match (
324326 gen_borrow_kind,
@@ -328,8 +330,23 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
328330 "immutable" ,
329331 "mutable" ,
330332 ) {
331- ( BorrowKind :: Shared , lft, _, BorrowKind :: Mut { .. } , _, rgt)
332- | ( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Shared , rgt, _) => {
333+ ( BorrowKind :: Shared , lft, _, BorrowKind :: Mut { .. } , _, rgt) => {
334+ first_borrow_desc = "mutable " ;
335+ tcx. cannot_reborrow_already_borrowed (
336+ span,
337+ & desc_place,
338+ "" ,
339+ lft,
340+ issued_span,
341+ "it" ,
342+ rgt,
343+ "" ,
344+ None ,
345+ Origin :: Mir ,
346+ )
347+ }
348+ ( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Shared , rgt, _) => {
349+ first_borrow_desc = "immutable " ;
333350 tcx. cannot_reborrow_already_borrowed (
334351 span,
335352 & desc_place,
@@ -345,6 +362,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
345362 }
346363
347364 ( BorrowKind :: Mut { .. } , _, _, BorrowKind :: Mut { .. } , _, _) => {
365+ first_borrow_desc = "first " ;
348366 tcx. cannot_mutably_borrow_multiply (
349367 span,
350368 & desc_place,
@@ -357,6 +375,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
357375 }
358376
359377 ( BorrowKind :: Unique , _, _, BorrowKind :: Unique , _, _) => {
378+ first_borrow_desc = "first " ;
360379 tcx. cannot_uniquely_borrow_by_two_closures (
361380 span,
362381 & desc_place,
@@ -384,18 +403,22 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
384403 return ;
385404 }
386405
387- ( BorrowKind :: Unique , _, _, _, _, _) => tcx. cannot_uniquely_borrow_by_one_closure (
388- span,
389- & desc_place,
390- "" ,
391- issued_span,
392- "it" ,
393- "" ,
394- None ,
395- Origin :: Mir ,
396- ) ,
406+ ( BorrowKind :: Unique , _, _, _, _, _) => {
407+ first_borrow_desc = "first " ;
408+ tcx. cannot_uniquely_borrow_by_one_closure (
409+ span,
410+ & desc_place,
411+ "" ,
412+ issued_span,
413+ "it" ,
414+ "" ,
415+ None ,
416+ Origin :: Mir ,
417+ )
418+ } ,
397419
398420 ( BorrowKind :: Shared , lft, _, BorrowKind :: Unique , _, _) => {
421+ first_borrow_desc = "first " ;
399422 tcx. cannot_reborrow_already_uniquely_borrowed (
400423 span,
401424 & desc_place,
@@ -409,6 +432,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
409432 }
410433
411434 ( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Unique , _, _) => {
435+ first_borrow_desc = "first " ;
412436 tcx. cannot_reborrow_already_uniquely_borrowed (
413437 span,
414438 & desc_place,
@@ -459,7 +483,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
459483 }
460484
461485 self . explain_why_borrow_contains_point ( context, issued_borrow, None )
462- . emit ( self . infcx . tcx , & mut err) ;
486+ . emit ( self . infcx . tcx , & mut err, first_borrow_desc . to_string ( ) ) ;
463487
464488 err. buffer ( & mut self . errors_buffer ) ;
465489 }
@@ -614,7 +638,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
614638
615639 if let BorrowExplanation :: MustBeValidFor ( ..) = explanation {
616640 } else {
617- explanation. emit ( self . infcx . tcx , & mut err) ;
641+ explanation. emit ( self . infcx . tcx , & mut err, String :: new ( ) ) ;
618642 }
619643 } else {
620644 err. span_label ( borrow_span, "borrowed value does not live long enough" ) ;
@@ -625,7 +649,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
625649
626650 borrow_spans. args_span_label ( & mut err, "value captured here" ) ;
627651
628- explanation. emit ( self . infcx . tcx , & mut err) ;
652+ explanation. emit ( self . infcx . tcx , & mut err, String :: new ( ) ) ;
629653 }
630654
631655 err
@@ -685,7 +709,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
685709 _ => { }
686710 }
687711
688- explanation. emit ( self . infcx . tcx , & mut err) ;
712+ explanation. emit ( self . infcx . tcx , & mut err, String :: new ( ) ) ;
689713
690714 err. buffer ( & mut self . errors_buffer ) ;
691715 }
@@ -752,7 +776,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
752776 }
753777 _ => { }
754778 }
755- explanation. emit ( self . infcx . tcx , & mut err) ;
779+ explanation. emit ( self . infcx . tcx , & mut err, String :: new ( ) ) ;
756780
757781 borrow_spans. args_span_label ( & mut err, "value captured here" ) ;
758782
@@ -889,7 +913,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
889913 loan_spans. var_span_label ( & mut err, "borrow occurs due to use in closure" ) ;
890914
891915 self . explain_why_borrow_contains_point ( context, loan, None )
892- . emit ( self . infcx . tcx , & mut err) ;
916+ . emit ( self . infcx . tcx , & mut err, String :: new ( ) ) ;
893917
894918 err. buffer ( & mut self . errors_buffer ) ;
895919 }
@@ -1262,21 +1286,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
12621286 }
12631287 }
12641288
1265- /// Returns the `FakeReadCause` at this location if it is a `FakeRead` statement.
1266- pub ( super ) fn retrieve_fake_read_cause_for_location (
1267- & self ,
1268- location : & Location ,
1269- ) -> Option < FakeReadCause > {
1270- let stmt = self . mir . basic_blocks ( ) [ location. block ]
1271- . statements
1272- . get ( location. statement_index ) ?;
1273- if let StatementKind :: FakeRead ( cause, _) = stmt. kind {
1274- Some ( cause)
1275- } else {
1276- None
1277- }
1278- }
1279-
12801289 fn classify_drop_access_kind ( & self , place : & Place < ' tcx > ) -> StorageDeadOrDrop < ' tcx > {
12811290 let tcx = self . infcx . tcx ;
12821291 match place {
0 commit comments