@@ -3757,13 +3757,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
37573757 assigned_span : Span ,
37583758 err_place : Place < ' tcx > ,
37593759 ) {
3760- let ( from_arg, local_decl, local_name) = match err_place. as_local ( ) {
3761- Some ( local) => (
3762- self . body . local_kind ( local) == LocalKind :: Arg ,
3763- Some ( & self . body . local_decls [ local] ) ,
3764- self . local_names [ local] ,
3765- ) ,
3766- None => ( false , None , None ) ,
3760+ let ( from_arg, local_decl) = match err_place. as_local ( ) {
3761+ Some ( local) => {
3762+ ( self . body . local_kind ( local) == LocalKind :: Arg , Some ( & self . body . local_decls [ local] ) )
3763+ }
3764+ None => ( false , None ) ,
37673765 } ;
37683766
37693767 // If root local is initialized immediately (everything apart from let
@@ -3795,13 +3793,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
37953793 err. span_label ( assigned_span, format ! ( "first assignment to {place_description}" ) ) ;
37963794 }
37973795 if let Some ( decl) = local_decl
3798- && let Some ( name) = local_name
37993796 && decl. can_be_made_mutable ( )
38003797 {
38013798 err. span_suggestion (
3802- decl. source_info . span ,
3799+ decl. source_info . span . shrink_to_lo ( ) ,
38033800 "consider making this binding mutable" ,
3804- format ! ( "mut {name}" ) ,
3801+ "mut " . to_string ( ) ,
38053802 Applicability :: MachineApplicable ,
38063803 ) ;
38073804 if !from_arg
@@ -3814,9 +3811,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
38143811 )
38153812 {
38163813 err. span_suggestion (
3817- decl. source_info . span ,
3814+ decl. source_info . span . shrink_to_lo ( ) ,
38183815 "to modify the original value, take a borrow instead" ,
3819- format ! ( "ref mut {name}" ) ,
3816+ "ref mut " . to_string ( ) ,
38203817 Applicability :: MaybeIncorrect ,
38213818 ) ;
38223819 }
0 commit comments