@@ -61,7 +61,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
6161
6262 let mut err;
6363 let item_msg;
64- let diagnosing : PlaceAndReason < ' _ > ;
64+ let diagnostic : PlaceAndReason < ' _ > ;
6565 let mut opt_source = None ;
6666 let access_place_desc = self . describe_any_place ( access_place. as_ref ( ) ) ;
6767 debug ! ( "report_mutability_error: access_place_desc={:?}" , access_place_desc) ;
@@ -102,7 +102,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
102102 return ;
103103 } else {
104104 item_msg = access_place_desc;
105- diagnosing = if self . is_upvar_field_projection ( access_place. as_ref ( ) ) . is_some ( )
105+ diagnostic = if self . is_upvar_field_projection ( access_place. as_ref ( ) ) . is_some ( )
106106 {
107107 PlaceAndReason :: DeclaredImmute ( item_msg. clone ( ) , None )
108108 } else {
@@ -116,7 +116,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
116116 if self . body . local_decls [ local] . is_ref_for_guard ( ) =>
117117 {
118118 item_msg = access_place_desc;
119- diagnosing = PlaceAndReason :: InPatternGuard ( item_msg . clone ( ) )
119+ diagnostic = PlaceAndReason :: InPatternGuard ( access_place_desc )
120120 }
121121 PlaceRef { local, projection : [ ProjectionElem :: Deref ] }
122122 if self . body . local_decls [ local] . is_ref_to_static ( ) =>
@@ -145,7 +145,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
145145 the_place_err. ty( self . body, self . infcx. tcx) . ty
146146 ) ) ;
147147
148- diagnosing = if self . is_upvar_field_projection ( access_place. as_ref ( ) ) . is_some ( )
148+ diagnostic = if self . is_upvar_field_projection ( access_place. as_ref ( ) ) . is_some ( )
149149 {
150150 PlaceAndReason :: SelfCaptured ( item_msg. clone ( ) )
151151 } else {
@@ -196,14 +196,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
196196 let mut mut_error = None ;
197197 let mut count = 1 ;
198198
199- let cant_access_here = |sp : Span | match error_access {
199+ let access_diagnose_builder = |sp : Span | match error_access {
200200 AccessKind :: MutableBorrow => FnMutBumpFn :: CannotBorrowMut { sp } ,
201201 AccessKind :: Mutate => FnMutBumpFn :: CannotAssign { sp } ,
202202 } ;
203203 let span = match error_access {
204- // cannot assign only happen in Mutate
205204 AccessKind :: Mutate => {
206- err = self . cannot_assign ( span, diagnosing ) ;
205+ err = self . cannot_assign ( span, diagnostic ) ;
207206 act = "assign" ;
208207 acted_on = "written" ;
209208 span
@@ -234,11 +233,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
234233 suggest = false ;
235234 } else {
236235 err =
237- self . cannot_borrow_path_as_mutable_because ( borrow_span, diagnosing ) ;
236+ self . cannot_borrow_path_as_mutable_because ( borrow_span, diagnostic ) ;
238237 }
239238 }
240239 _ => {
241- err = self . cannot_borrow_path_as_mutable_because ( borrow_span, diagnosing ) ;
240+ err = self . cannot_borrow_path_as_mutable_because ( borrow_span, diagnostic ) ;
242241 }
243242 }
244243 if suggest {
@@ -278,7 +277,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
278277 ProjectionElem :: Deref ,
279278 ] ,
280279 } => {
281- err. subdiagnostic ( cant_access_here ( span) ) ;
280+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
282281
283282 let place = Place :: ty_from ( local, proj_base, self . body , self . infcx . tcx ) ;
284283 if let Some ( span) = get_mut_span_in_struct_field ( self . infcx . tcx , place. ty , * field) {
@@ -300,7 +299,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
300299 . is_some_and ( |l| mut_borrow_of_mutable_ref ( l, self . local_names [ local] ) ) =>
301300 {
302301 let decl = & self . body . local_decls [ local] ;
303- err. subdiagnostic ( cant_access_here ( span) ) ;
302+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
304303 if let Some ( mir:: Statement {
305304 source_info,
306305 kind :
@@ -385,7 +384,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
385384 assert_eq ! ( local_decl. mutability, Mutability :: Not ) ;
386385
387386 if count < 10 {
388- err. subdiagnostic ( cant_access_here ( span) ) ;
387+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
389388 }
390389 if suggest {
391390 self . construct_mut_suggestion_for_local_binding_patterns ( & mut err, local) ;
@@ -407,7 +406,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
407406
408407 let captured_place = & self . upvars [ upvar_index. index ( ) ] . place ;
409408
410- err. subdiagnostic ( cant_access_here ( span) ) ;
409+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
411410
412411 let upvar_hir_id = captured_place. get_root_variable ( ) ;
413412
@@ -462,7 +461,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
462461 . span_to_snippet ( span)
463462 . is_ok_and ( |snippet| snippet. starts_with ( "&mut " ) ) =>
464463 {
465- err. subdiagnostic ( cant_access_here ( span) ) ;
464+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
466465 err. span_suggestion (
467466 span,
468467 "try removing `&mut` here" ,
@@ -474,7 +473,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
474473 PlaceRef { local, projection : [ ProjectionElem :: Deref ] }
475474 if self . body . local_decls [ local] . is_ref_for_guard ( ) =>
476475 {
477- err. subdiagnostic ( cant_access_here ( span) ) ;
476+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
478477 err. note (
479478 "variables bound in patterns are immutable until the end of the pattern guard" ,
480479 ) ;
@@ -518,12 +517,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
518517 PlaceRef { local, projection : [ ProjectionElem :: Deref ] }
519518 if local == ty:: CAPTURE_STRUCT_LOCAL && !self . upvars . is_empty ( ) =>
520519 {
521- err. subdiagnostic ( cant_access_here ( span) ) ;
520+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
522521 self . expected_fn_found_fn_mut_call ( & mut err) ;
523522 }
524523
525524 PlaceRef { local : _, projection : [ .., ProjectionElem :: Deref ] } => {
526- err. subdiagnostic ( cant_access_here ( span) ) ;
525+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
527526
528527 match opt_source {
529528 Some ( BorrowedContentSource :: OverloadedDeref ( ty) ) => {
@@ -544,7 +543,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
544543 }
545544
546545 _ => {
547- err. subdiagnostic ( cant_access_here ( span) ) ;
546+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
548547 }
549548 }
550549
0 commit comments