@@ -882,28 +882,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
882
882
}
883
883
}
884
884
885
- // We add a special note about `IndexMut`, if the source of this error
886
- // is the fact that `Index` is implemented, but `IndexMut` is not. Needing
887
- // to implement two traits for "one operator" is not very intuitive for
888
- // many programmers.
889
- if err. cmt . note == mc:: NoteIndex {
890
- let node_id = self . tcx . hir . hir_to_node_id ( err. cmt . hir_id ) ;
891
- let node = self . tcx . hir . get ( node_id) ;
892
-
893
- // This pattern probably always matches.
894
- if let hir_map:: NodeExpr (
895
- hir:: Expr { node : hir:: ExprKind :: Index ( lhs, _) , ..}
896
- ) = node {
897
- let ty = self . tables . expr_ty ( lhs) ;
898
-
899
- db. help ( & format ! (
900
- "trait `IndexMut` is required to modify indexed content, but \
901
- it is not implemented for {}",
902
- ty
903
- ) ) ;
904
- }
905
- }
906
-
907
885
db
908
886
}
909
887
BorrowViolation ( euv:: ClosureCapture ( _) ) => {
@@ -924,6 +902,28 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
924
902
}
925
903
} ;
926
904
905
+ // We add a special note about `IndexMut`, if the source of this error
906
+ // is the fact that `Index` is implemented, but `IndexMut` is not. Needing
907
+ // to implement two traits for "one operator" is not very intuitive for
908
+ // many programmers.
909
+ if err. cmt . note == mc:: NoteIndex {
910
+ let node_id = self . tcx . hir . hir_to_node_id ( err. cmt . hir_id ) ;
911
+ let node = self . tcx . hir . get ( node_id) ;
912
+
913
+ // This pattern probably always matches.
914
+ if let hir_map:: NodeExpr (
915
+ hir:: Expr { node : hir:: ExprKind :: Index ( lhs, _) , ..}
916
+ ) = node {
917
+ let ty = self . tables . expr_ty ( lhs) ;
918
+
919
+ db. help ( & format ! (
920
+ "trait `IndexMut` is required to modify indexed content, but \
921
+ it is not implemented for `{}`",
922
+ ty
923
+ ) ) ;
924
+ }
925
+ }
926
+
927
927
self . note_and_explain_mutbl_error ( & mut db, & err, & error_span) ;
928
928
self . note_immutability_blame (
929
929
& mut db,
0 commit comments