@@ -131,22 +131,20 @@ pub(super) fn is_active<'tcx>(
131131/// Determines if a given borrow is borrowing local data
132132/// This is called for all Yield statements on movable generators
133133pub ( super ) fn borrow_of_local_data < ' tcx > ( place : & Place < ' tcx > ) -> bool {
134- match place {
135- Place :: Base ( PlaceBase :: Static ( ..) ) => false ,
136- Place :: Base ( PlaceBase :: Local ( ..) ) => true ,
137- Place :: Projection ( box proj) => {
138- match proj. elem {
139- // Reborrow of already borrowed data is ignored
140- // Any errors will be caught on the initial borrow
141- ProjectionElem :: Deref => false ,
134+ place. iterate ( |place_base, place_projection| {
135+ match place_base {
136+ PlaceBase :: Static ( ..) => return false ,
137+ PlaceBase :: Local ( ..) => { } ,
138+ }
142139
143- // For interior references and downcasts, find out if the base is local
144- ProjectionElem :: Field ( ..)
145- | ProjectionElem :: Index ( ..)
146- | ProjectionElem :: ConstantIndex { .. }
147- | ProjectionElem :: Subslice { .. }
148- | ProjectionElem :: Downcast ( ..) => borrow_of_local_data ( & proj. base ) ,
140+ for proj in place_projection {
141+ // Reborrow of already borrowed data is ignored
142+ // Any errors will be caught on the initial borrow
143+ if proj. elem == ProjectionElem :: Deref {
144+ return false ;
149145 }
150146 }
151- }
147+
148+ true
149+ } )
152150}
0 commit comments