@@ -6,6 +6,7 @@ use clippy_utils::{binop_traits, eq_expr_value, trait_ref_of_method};
6
6
use core:: ops:: ControlFlow ;
7
7
use rustc_errors:: Applicability ;
8
8
use rustc_hir as hir;
9
+ use rustc_hir:: { HirId , HirIdSet } ;
9
10
use rustc_hir_typeck:: expr_use_visitor:: { Delegate , ExprUseVisitor , PlaceBase , PlaceWithHirId } ;
10
11
use rustc_lint:: LateContext ;
11
12
use rustc_middle:: mir:: FakeReadCause ;
@@ -98,10 +99,10 @@ pub(super) fn check<'tcx>(
98
99
}
99
100
}
100
101
101
- fn imm_borrows_in_expr ( cx : & LateContext < ' _ > , e : & hir:: Expr < ' _ > ) -> hir :: HirIdSet {
102
- struct S ( hir :: HirIdSet ) ;
102
+ fn imm_borrows_in_expr ( cx : & LateContext < ' _ > , e : & hir:: Expr < ' _ > ) -> HirIdSet {
103
+ struct S ( HirIdSet ) ;
103
104
impl Delegate < ' _ > for S {
104
- fn borrow ( & mut self , place : & PlaceWithHirId < ' _ > , _: hir :: HirId , kind : BorrowKind ) {
105
+ fn borrow ( & mut self , place : & PlaceWithHirId < ' _ > , _: HirId , kind : BorrowKind ) {
105
106
if matches ! ( kind, BorrowKind :: ImmBorrow | BorrowKind :: UniqueImmBorrow ) {
106
107
self . 0 . insert ( match place. place . base {
107
108
PlaceBase :: Local ( id) => id,
@@ -111,13 +112,13 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
111
112
}
112
113
}
113
114
114
- fn consume ( & mut self , _: & PlaceWithHirId < ' _ > , _: hir :: HirId ) { }
115
- fn mutate ( & mut self , _: & PlaceWithHirId < ' _ > , _: hir :: HirId ) { }
116
- fn fake_read ( & mut self , _: & PlaceWithHirId < ' _ > , _: FakeReadCause , _: hir :: HirId ) { }
117
- fn copy ( & mut self , _: & PlaceWithHirId < ' _ > , _: hir :: HirId ) { }
115
+ fn consume ( & mut self , _: & PlaceWithHirId < ' _ > , _: HirId ) { }
116
+ fn mutate ( & mut self , _: & PlaceWithHirId < ' _ > , _: HirId ) { }
117
+ fn fake_read ( & mut self , _: & PlaceWithHirId < ' _ > , _: FakeReadCause , _: HirId ) { }
118
+ fn copy ( & mut self , _: & PlaceWithHirId < ' _ > , _: HirId ) { }
118
119
}
119
120
120
- let mut s = S ( hir :: HirIdSet :: default ( ) ) ;
121
+ let mut s = S ( HirIdSet :: default ( ) ) ;
121
122
let infcx = cx. tcx . infer_ctxt ( ) . build ( ) ;
122
123
let mut v = ExprUseVisitor :: new (
123
124
& mut s,
@@ -130,10 +131,10 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
130
131
s. 0
131
132
}
132
133
133
- fn mut_borrows_in_expr ( cx : & LateContext < ' _ > , e : & hir:: Expr < ' _ > ) -> hir :: HirIdSet {
134
- struct S ( hir :: HirIdSet ) ;
134
+ fn mut_borrows_in_expr ( cx : & LateContext < ' _ > , e : & hir:: Expr < ' _ > ) -> HirIdSet {
135
+ struct S ( HirIdSet ) ;
135
136
impl Delegate < ' _ > for S {
136
- fn borrow ( & mut self , place : & PlaceWithHirId < ' _ > , _: hir :: HirId , kind : BorrowKind ) {
137
+ fn borrow ( & mut self , place : & PlaceWithHirId < ' _ > , _: HirId , kind : BorrowKind ) {
137
138
if matches ! ( kind, BorrowKind :: MutBorrow ) {
138
139
self . 0 . insert ( match place. place . base {
139
140
PlaceBase :: Local ( id) => id,
@@ -143,13 +144,13 @@ fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
143
144
}
144
145
}
145
146
146
- fn consume ( & mut self , _: & PlaceWithHirId < ' _ > , _: hir :: HirId ) { }
147
- fn mutate ( & mut self , _: & PlaceWithHirId < ' _ > , _: hir :: HirId ) { }
148
- fn fake_read ( & mut self , _: & PlaceWithHirId < ' _ > , _: FakeReadCause , _: hir :: HirId ) { }
149
- fn copy ( & mut self , _: & PlaceWithHirId < ' _ > , _: hir :: HirId ) { }
147
+ fn consume ( & mut self , _: & PlaceWithHirId < ' _ > , _: HirId ) { }
148
+ fn mutate ( & mut self , _: & PlaceWithHirId < ' _ > , _: HirId ) { }
149
+ fn fake_read ( & mut self , _: & PlaceWithHirId < ' _ > , _: FakeReadCause , _: HirId ) { }
150
+ fn copy ( & mut self , _: & PlaceWithHirId < ' _ > , _: HirId ) { }
150
151
}
151
152
152
- let mut s = S ( hir :: HirIdSet :: default ( ) ) ;
153
+ let mut s = S ( HirIdSet :: default ( ) ) ;
153
154
let infcx = cx. tcx . infer_ctxt ( ) . build ( ) ;
154
155
let mut v = ExprUseVisitor :: new (
155
156
& mut s,
0 commit comments