88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11+ use borrow_check:: WriteKind ;
1112use syntax_pos:: Span ;
1213use rustc:: middle:: region:: ScopeTree ;
1314use rustc:: mir:: { BorrowKind , Field , Local , LocalKind , Location , Operand } ;
@@ -162,7 +163,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
162163 format ! ( "borrow of {} occurs here" , borrow_msg) ,
163164 ) ;
164165 err. span_label ( span, format ! ( "move out of {} occurs here" , value_msg) ) ;
165- self . explain_why_borrow_contains_point ( context, borrow, & mut err) ;
166+ self . explain_why_borrow_contains_point ( context, borrow, None , & mut err) ;
166167 err. emit ( ) ;
167168 }
168169
@@ -182,7 +183,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
182183 Origin :: Mir ,
183184 ) ;
184185
185- self . explain_why_borrow_contains_point ( context, borrow, & mut err) ;
186+ self . explain_why_borrow_contains_point ( context, borrow, None , & mut err) ;
186187
187188 err. emit ( ) ;
188189 }
@@ -380,7 +381,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
380381 ) ;
381382 }
382383
383- self . explain_why_borrow_contains_point ( context, issued_borrow, & mut err) ;
384+ self . explain_why_borrow_contains_point ( context, issued_borrow, None , & mut err) ;
384385
385386 err. emit ( ) ;
386387 }
@@ -389,8 +390,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
389390 & mut self ,
390391 context : Context ,
391392 borrow : & BorrowData < ' tcx > ,
392- drop_span : Span ,
393+ place_span : ( & Place < ' tcx > , Span ) ,
394+ kind : Option < WriteKind > ,
393395 ) {
396+ let drop_span = place_span. 1 ;
394397 let scope_tree = self . tcx . region_scope_tree ( self . mir_def_id ) ;
395398 let root_place = self . prefixes ( & borrow. borrowed_place , PrefixSet :: All )
396399 . last ( )
@@ -450,6 +453,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
450453 drop_span,
451454 borrow_span,
452455 proper_span,
456+ kind. map ( |k| ( k, place_span. 0 ) ) ,
453457 ) ;
454458 }
455459 ( RegionKind :: ReEarlyBound ( _) , None )
@@ -495,7 +499,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
495499 drop_span,
496500 format ! ( "`{}` dropped here while still borrowed" , name) ,
497501 ) ;
498- self . explain_why_borrow_contains_point ( context, borrow, & mut err) ;
502+ self . explain_why_borrow_contains_point ( context, borrow, None , & mut err) ;
499503 err. emit ( ) ;
500504 }
501505
@@ -517,7 +521,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
517521 "temporary value dropped here while still borrowed" ,
518522 ) ;
519523 err. note ( "consider using a `let` binding to increase its lifetime" ) ;
520- self . explain_why_borrow_contains_point ( context, borrow, & mut err) ;
524+ self . explain_why_borrow_contains_point ( context, borrow, None , & mut err) ;
521525 err. emit ( ) ;
522526 }
523527
@@ -530,6 +534,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
530534 drop_span : Span ,
531535 borrow_span : Span ,
532536 _proper_span : Span ,
537+ kind_place : Option < ( WriteKind , & Place < ' tcx > ) > ,
533538 ) {
534539 debug ! (
535540 "report_unscoped_local_value_does_not_live_long_enough(\
@@ -544,7 +549,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
544549 err. span_label ( borrow_span, "borrowed value does not live long enough" ) ;
545550 err. span_label ( drop_span, "borrowed value only lives until here" ) ;
546551
547- self . explain_why_borrow_contains_point ( context, borrow, & mut err) ;
552+ self . explain_why_borrow_contains_point ( context, borrow, kind_place , & mut err) ;
548553 err. emit ( ) ;
549554 }
550555
@@ -570,7 +575,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
570575 err. span_label ( proper_span, "temporary value does not live long enough" ) ;
571576 err. span_label ( drop_span, "temporary value only lives until here" ) ;
572577
573- self . explain_why_borrow_contains_point ( context, borrow, & mut err) ;
578+ self . explain_why_borrow_contains_point ( context, borrow, None , & mut err) ;
574579 err. emit ( ) ;
575580 }
576581
@@ -588,7 +593,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
588593 Origin :: Mir ,
589594 ) ;
590595
591- self . explain_why_borrow_contains_point ( context, loan, & mut err) ;
596+ self . explain_why_borrow_contains_point ( context, loan, None , & mut err) ;
592597
593598 err. emit ( ) ;
594599 }
0 commit comments