@@ -35,6 +35,7 @@ pub(crate) fn check_pointers<'a, 'tcx, F>(
3535 body : & mut Body < ' tcx > ,
3636 excluded_pointees : & ' a [ Ty < ' tcx > ] ,
3737 on_finding : F ,
38+ check_for_borrows : bool ,
3839) where
3940 F : Fn (
4041 /* tcx: */ TyCtxt < ' tcx > ,
@@ -66,7 +67,13 @@ pub(crate) fn check_pointers<'a, 'tcx, F>(
6667 let statement = & basic_blocks[ block] . statements [ statement_index] ;
6768 let source_info = statement. source_info ;
6869
69- let mut finder = PointerFinder :: new ( tcx, local_decls, typing_env, excluded_pointees) ;
70+ let mut finder = PointerFinder :: new (
71+ tcx,
72+ local_decls,
73+ typing_env,
74+ excluded_pointees,
75+ check_for_borrows,
76+ ) ;
7077 finder. visit_statement ( statement, location) ;
7178
7279 for ( local, ty) in finder. into_found_pointers ( ) {
@@ -110,6 +117,7 @@ struct PointerFinder<'a, 'tcx> {
110117 typing_env : ty:: TypingEnv < ' tcx > ,
111118 pointers : Vec < ( Place < ' tcx > , Ty < ' tcx > ) > ,
112119 excluded_pointees : & ' a [ Ty < ' tcx > ] ,
120+ check_for_borrows : bool ,
113121}
114122
115123impl < ' a , ' tcx > PointerFinder < ' a , ' tcx > {
@@ -118,8 +126,16 @@ impl<'a, 'tcx> PointerFinder<'a, 'tcx> {
118126 local_decls : & ' a mut LocalDecls < ' tcx > ,
119127 typing_env : ty:: TypingEnv < ' tcx > ,
120128 excluded_pointees : & ' a [ Ty < ' tcx > ] ,
129+ check_for_borrows : bool ,
121130 ) -> Self {
122- PointerFinder { tcx, local_decls, typing_env, excluded_pointees, pointers : Vec :: new ( ) }
131+ PointerFinder {
132+ tcx,
133+ local_decls,
134+ typing_env,
135+ excluded_pointees,
136+ pointers : Vec :: new ( ) ,
137+ check_for_borrows,
138+ }
123139 }
124140
125141 fn into_found_pointers ( self ) -> Vec < ( Place < ' tcx > , Ty < ' tcx > ) > {
@@ -134,14 +150,16 @@ impl<'a, 'tcx> Visitor<'tcx> for PointerFinder<'a, 'tcx> {
134150 match context {
135151 PlaceContext :: MutatingUse (
136152 MutatingUseContext :: Store
137- | MutatingUseContext :: AsmOutput
138153 | MutatingUseContext :: Call
139154 | MutatingUseContext :: Yield
140155 | MutatingUseContext :: Drop ,
141156 ) => { }
142157 PlaceContext :: NonMutatingUse (
143158 NonMutatingUseContext :: Copy | NonMutatingUseContext :: Move ,
144159 ) => { }
160+ PlaceContext :: MutatingUse ( MutatingUseContext :: Borrow )
161+ | PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: SharedBorrow )
162+ if self . check_for_borrows => { }
145163 _ => {
146164 return ;
147165 }
0 commit comments