@@ -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
@@ -463,7 +462,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
463462 . span_to_snippet ( span)
464463 . is_ok_and ( |snippet| snippet. starts_with ( "&mut " ) ) =>
465464 {
466- err. subdiagnostic ( cant_access_here ( span) ) ;
465+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
467466 err. span_suggestion (
468467 span,
469468 "try removing `&mut` here" ,
@@ -475,7 +474,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
475474 PlaceRef { local, projection : [ ProjectionElem :: Deref ] }
476475 if self . body . local_decls [ local] . is_ref_for_guard ( ) =>
477476 {
478- err. subdiagnostic ( cant_access_here ( span) ) ;
477+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
479478 err. note (
480479 "variables bound in patterns are immutable until the end of the pattern guard" ,
481480 ) ;
@@ -519,12 +518,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
519518 PlaceRef { local, projection : [ ProjectionElem :: Deref ] }
520519 if local == ty:: CAPTURE_STRUCT_LOCAL && !self . upvars . is_empty ( ) =>
521520 {
522- err. subdiagnostic ( cant_access_here ( span) ) ;
521+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
523522 self . expected_fn_found_fn_mut_call ( & mut err) ;
524523 }
525524
526525 PlaceRef { local : _, projection : [ .., ProjectionElem :: Deref ] } => {
527- err. subdiagnostic ( cant_access_here ( span) ) ;
526+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
528527
529528 match opt_source {
530529 Some ( BorrowedContentSource :: OverloadedDeref ( ty) ) => {
@@ -545,7 +544,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
545544 }
546545
547546 _ => {
548- err. subdiagnostic ( cant_access_here ( span) ) ;
547+ err. subdiagnostic ( access_diagnose_builder ( span) ) ;
549548 }
550549 }
551550
0 commit comments