@@ -647,16 +647,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
647
647
let hir_map = self . infcx . tcx . hir ( ) ;
648
648
let def_id = self . body . source . def_id ( ) ;
649
649
let Some ( local_def_id) = def_id. as_local ( ) else { return } ;
650
- let Some ( body_id) = hir_map. maybe_body_owned_by ( local_def_id) else { return } ;
651
- let body = self . infcx . tcx . hir ( ) . body ( body_id) ;
650
+ let Some ( body) = hir_map. maybe_body_owned_by ( local_def_id) else { return } ;
652
651
653
652
let mut v = SuggestIndexOperatorAlternativeVisitor {
654
653
assign_span : span,
655
654
err,
656
655
ty,
657
656
suggested : false ,
658
657
} ;
659
- v. visit_body ( body) ;
658
+ v. visit_body ( & body) ;
660
659
if !v. suggested {
661
660
err. help ( format ! (
662
661
"to modify a `{ty}`, use `.get_mut()`, `.insert()` or the entry API" ,
@@ -746,9 +745,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
746
745
// `fn foo(&x: &i32)` -> `fn foo(&(mut x): &i32)`
747
746
let def_id = self . body . source . def_id ( ) ;
748
747
if let Some ( local_def_id) = def_id. as_local ( )
749
- && let Some ( body_id) = self . infcx . tcx . hir ( ) . maybe_body_owned_by ( local_def_id)
750
- && let body = self . infcx . tcx . hir ( ) . body ( body_id)
751
- && let Some ( hir_id) = ( BindingFinder { span : pat_span } ) . visit_body ( body) . break_value ( )
748
+ && let Some ( body) = self . infcx . tcx . hir ( ) . maybe_body_owned_by ( local_def_id)
749
+ && let Some ( hir_id) = ( BindingFinder { span : pat_span } ) . visit_body ( & body) . break_value ( )
752
750
&& let node = self . infcx . tcx . hir_node ( hir_id)
753
751
&& let hir:: Node :: LetStmt ( hir:: LetStmt {
754
752
pat : hir:: Pat { kind : hir:: PatKind :: Ref ( _, _) , .. } ,
@@ -867,8 +865,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
867
865
}
868
866
}
869
867
}
870
- if let Some ( body_id ) = hir_map. maybe_body_owned_by ( self . mir_def_id ( ) )
871
- && let Block ( block, _) = hir_map . body ( body_id ) . value . kind
868
+ if let Some ( body ) = hir_map. maybe_body_owned_by ( self . mir_def_id ( ) )
869
+ && let Block ( block, _) = body. value . kind
872
870
{
873
871
// `span` corresponds to the expression being iterated, find the `for`-loop desugared
874
872
// expression with that span in order to identify potential fixes when encountering a
@@ -1189,10 +1187,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
1189
1187
Some ( ( false , err_label_span, message, _) ) => {
1190
1188
let def_id = self . body . source . def_id ( ) ;
1191
1189
let hir_id = if let Some ( local_def_id) = def_id. as_local ( )
1192
- && let Some ( body_id ) = self . infcx . tcx . hir ( ) . maybe_body_owned_by ( local_def_id)
1190
+ && let Some ( body ) = self . infcx . tcx . hir ( ) . maybe_body_owned_by ( local_def_id)
1193
1191
{
1194
- let body = self . infcx . tcx . hir ( ) . body ( body_id) ;
1195
- BindingFinder { span : err_label_span } . visit_body ( body) . break_value ( )
1192
+ BindingFinder { span : err_label_span } . visit_body ( & body) . break_value ( )
1196
1193
} else {
1197
1194
None
1198
1195
} ;
0 commit comments