@@ -2959,21 +2959,27 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
29592959 }
29602960 }
29612961
2962- let mut err = self . path_does_not_live_long_enough ( borrow_span, & format ! ( "`{name}`" ) ) ;
2962+ let name = if borrow_span. in_external_macro ( self . infcx . tcx . sess . source_map ( ) ) {
2963+ // Don't name local variables in external macros.
2964+ "value" . to_string ( )
2965+ } else {
2966+ format ! ( "`{name}`" )
2967+ } ;
2968+
2969+ let mut err = self . path_does_not_live_long_enough ( borrow_span, & name) ;
29632970
29642971 if let Some ( annotation) = self . annotate_argument_and_return_for_borrow ( borrow) {
29652972 let region_name = annotation. emit ( self , & mut err) ;
29662973
29672974 err. span_label (
29682975 borrow_span,
2969- format ! ( "` {name}` would have to be valid for `{region_name}`..." ) ,
2976+ format ! ( "{name} would have to be valid for `{region_name}`..." ) ,
29702977 ) ;
29712978
29722979 err. span_label (
29732980 drop_span,
29742981 format ! (
2975- "...but `{}` will be dropped here, when the {} returns" ,
2976- name,
2982+ "...but {name} will be dropped here, when the {} returns" ,
29772983 self . infcx
29782984 . tcx
29792985 . opt_item_name( self . mir_def_id( ) . to_def_id( ) )
@@ -3011,7 +3017,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
30113017 }
30123018 } else {
30133019 err. span_label ( borrow_span, "borrowed value does not live long enough" ) ;
3014- err. span_label ( drop_span, format ! ( "` {name}` dropped here while still borrowed" ) ) ;
3020+ err. span_label ( drop_span, format ! ( "{name} dropped here while still borrowed" ) ) ;
30153021
30163022 borrow_spans. args_subdiag ( & mut err, |args_span| {
30173023 crate :: session_diagnostics:: CaptureArgLabel :: Capture {
0 commit comments