@@ -106,44 +106,48 @@ fn is_argument(map: &hir::map::Map<'_>, id: HirId) -> bool {
106
106
107
107
impl < ' a , ' tcx > Delegate < ' tcx > for EscapeDelegate < ' a , ' tcx > {
108
108
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
122
113
self . set . remove ( & lid) ;
123
114
}
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
+ }
124
124
}
125
125
}
126
126
}
127
127
128
128
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
+ }
131
133
}
132
134
}
133
135
134
136
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
+ }
142
145
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 ;
145
150
}
146
- return ;
147
151
}
148
152
}
149
153
}
0 commit comments