@@ -497,14 +497,34 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
497497 _proper_span : Span ,
498498 _end_span : Option < Span > ,
499499 ) {
500+ debug ! (
501+ "report_unscoped_local_value_does_not_live_long_enough(\
502+ {:?}, {:?}, {:?}, {:?}, {:?}, {:?}\
503+ )",
504+ context,
505+ name,
506+ scope_tree,
507+ borrow,
508+ drop_span,
509+ borrow_span
510+ ) ;
511+
500512 let mut err = self . tcx . path_does_not_live_long_enough ( borrow_span,
501513 & format ! ( "`{}`" , name) ,
502514 Origin :: Mir ) ;
503515 err. span_label ( borrow_span, "borrowed value does not live long enough" ) ;
504516 err. span_label ( drop_span, "borrowed value only lives until here" ) ;
505- self . tcx . note_and_explain_region ( scope_tree, & mut err,
506- "borrowed value must be valid for " ,
507- borrow. region , "..." ) ;
517+
518+ if !self . tcx . sess . nll ( ) {
519+ self . tcx . note_and_explain_region (
520+ scope_tree,
521+ & mut err,
522+ "borrowed value must be valid for " ,
523+ borrow. region ,
524+ "..." ,
525+ ) ;
526+ }
527+
508528 self . explain_why_borrow_contains_point ( context, borrow, & mut err) ;
509529 err. emit ( ) ;
510530 }
@@ -519,14 +539,33 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
519539 proper_span : Span ,
520540 _end_span : Option < Span >
521541 ) {
542+ debug ! (
543+ "report_unscoped_temporary_value_does_not_live_long_enough(\
544+ {:?}, {:?}, {:?}, {:?}, {:?}\
545+ )",
546+ context,
547+ scope_tree,
548+ borrow,
549+ drop_span,
550+ proper_span
551+ ) ;
552+
522553 let mut err = self . tcx . path_does_not_live_long_enough ( proper_span,
523554 "borrowed value" ,
524555 Origin :: Mir ) ;
525556 err. span_label ( proper_span, "temporary value does not live long enough" ) ;
526557 err. span_label ( drop_span, "temporary value only lives until here" ) ;
527- self . tcx . note_and_explain_region ( scope_tree, & mut err,
528- "borrowed value must be valid for " ,
529- borrow. region , "..." ) ;
558+
559+ if !self . tcx . sess . nll ( ) {
560+ self . tcx . note_and_explain_region (
561+ scope_tree,
562+ & mut err,
563+ "borrowed value must be valid for " ,
564+ borrow. region ,
565+ "..." ,
566+ ) ;
567+ }
568+
530569 self . explain_why_borrow_contains_point ( context, borrow, & mut err) ;
531570 err. emit ( ) ;
532571 }
0 commit comments