@@ -106,44 +106,48 @@ fn is_argument(map: &hir::map::Map<'_>, id: HirId) -> bool {
106106
107107impl < ' a , ' tcx > Delegate < ' tcx > for EscapeDelegate < ' a , ' tcx > {
108108 fn consume ( & mut self , cmt : & Place < ' tcx > , mode : ConsumeMode ) {
109- if let PlaceBase :: Local ( lid) = cmt. base {
110- if let ConsumeMode :: Move = mode {
111- // moved out or in. clearly can't be localized
112- self . set . remove ( & lid) ;
113- }
114- }
115- let map = & self . cx . tcx . hir ( ) ;
116- if let PlaceBase :: Local ( lid) = cmt. base {
117- if let Some ( Node :: Binding ( _) ) = map. find ( cmt. hir_id ) {
118- if self . set . contains ( & lid) {
119- // let y = x where x is known
120- // remove x, insert y
121- self . set . insert ( cmt. hir_id ) ;
109+ if cmt. projections . is_empty ( ) {
110+ if let PlaceBase :: Local ( lid) = cmt. base {
111+ if let ConsumeMode :: Move = mode {
112+ // moved out or in. clearly can't be localized
122113 self . set . remove ( & lid) ;
123114 }
115+ let map = & self . cx . tcx . hir ( ) ;
116+ if let Some ( Node :: Binding ( _) ) = map. find ( cmt. hir_id ) {
117+ if self . set . contains ( & lid) {
118+ // let y = x where x is known
119+ // remove x, insert y
120+ self . set . insert ( cmt. hir_id ) ;
121+ self . set . remove ( & lid) ;
122+ }
123+ }
124124 }
125125 }
126126 }
127127
128128 fn borrow ( & mut self , cmt : & Place < ' tcx > , _: ty:: BorrowKind ) {
129- if let PlaceBase :: Local ( lid) = cmt. base {
130- self . set . remove ( & lid) ;
129+ if cmt. projections . is_empty ( ) {
130+ if let PlaceBase :: Local ( lid) = cmt. base {
131+ self . set . remove ( & lid) ;
132+ }
131133 }
132134 }
133135
134136 fn mutate ( & mut self , cmt : & Place < ' tcx > ) {
135- let map = & self . cx . tcx . hir ( ) ;
136- if is_argument ( map, cmt. hir_id ) {
137- // Skip closure arguments
138- let parent_id = map. get_parent_node ( cmt. hir_id ) ;
139- if let Some ( Node :: Expr ( ..) ) = map. find ( map. get_parent_node ( parent_id) ) {
140- return ;
141- }
137+ if cmt. projections . is_empty ( ) {
138+ let map = & self . cx . tcx . hir ( ) ;
139+ if is_argument ( map, cmt. hir_id ) {
140+ // Skip closure arguments
141+ let parent_id = map. get_parent_node ( cmt. hir_id ) ;
142+ if let Some ( Node :: Expr ( ..) ) = map. find ( map. get_parent_node ( parent_id) ) {
143+ return ;
144+ }
142145
143- if is_non_trait_box ( cmt. ty ) && !self . is_large_box ( cmt. ty ) {
144- self . set . insert ( cmt. hir_id ) ;
146+ if is_non_trait_box ( cmt. ty ) && !self . is_large_box ( cmt. ty ) {
147+ self . set . insert ( cmt. hir_id ) ;
148+ }
149+ return ;
145150 }
146- return ;
147151 }
148152 }
149153}
0 commit comments