@@ -120,44 +120,27 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
120
120
self . set . remove ( & lid) ;
121
121
}
122
122
}
123
- }
124
- fn consume_pat ( & mut self , consume_pat : & Pat , cmt : & cmt_ < ' tcx > , _: ConsumeMode ) {
125
123
let map = & self . cx . tcx . hir ( ) ;
126
- if is_argument ( map, consume_pat . hir_id ) {
124
+ if is_argument ( map, cmt . hir_id ) {
127
125
// Skip closure arguments
128
- let parent_id = map. get_parent_node ( consume_pat . hir_id ) ;
126
+ let parent_id = map. get_parent_node ( cmt . hir_id ) ;
129
127
if let Some ( Node :: Expr ( ..) ) = map. find ( map. get_parent_node ( parent_id) ) {
130
128
return ;
131
129
}
132
130
133
131
if is_non_trait_box ( cmt. ty ) && !self . is_large_box ( cmt. ty ) {
134
- self . set . insert ( consume_pat . hir_id ) ;
132
+ self . set . insert ( cmt . hir_id ) ;
135
133
}
136
134
return ;
137
135
}
138
- if let Categorization :: Rvalue = cmt. cat {
139
- if let Some ( Node :: Stmt ( st) ) = map. find ( map. get_parent_node ( cmt. hir_id ) ) {
140
- if let StmtKind :: Local ( ref loc) = st. kind {
141
- if let Some ( ref ex) = loc. init {
142
- if let ExprKind :: Box ( ..) = ex. kind {
143
- if is_non_trait_box ( cmt. ty ) && !self . is_large_box ( cmt. ty ) {
144
- // let x = box (...)
145
- self . set . insert ( consume_pat. hir_id ) ;
146
- }
147
- // TODO Box::new
148
- // TODO vec![]
149
- // TODO "foo".to_owned() and friends
150
- }
151
- }
152
- }
153
- }
154
- }
155
136
if let Categorization :: Local ( lid) = cmt. cat {
156
- if self . set . contains ( & lid) {
157
- // let y = x where x is known
158
- // remove x, insert y
159
- self . set . insert ( consume_pat. hir_id ) ;
160
- self . set . remove ( & lid) ;
137
+ if let Some ( Node :: Binding ( _) ) = map. find ( cmt. hir_id ) {
138
+ if self . set . contains ( & lid) {
139
+ // let y = x where x is known
140
+ // remove x, insert y
141
+ self . set . insert ( cmt. hir_id ) ;
142
+ self . set . remove ( & lid) ;
143
+ }
161
144
}
162
145
}
163
146
}
@@ -166,26 +149,9 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
166
149
& mut self ,
167
150
cmt : & cmt_ < ' tcx > ,
168
151
_: ty:: BorrowKind ,
169
- loan_cause : LoanCause ,
170
152
) {
171
153
if let Categorization :: Local ( lid) = cmt. cat {
172
- match loan_cause {
173
- // `x.foo()`
174
- // Used without autoderef-ing (i.e., `x.clone()`).
175
- LoanCause :: AutoRef |
176
-
177
- // `&x`
178
- // `foo(&x)` where no extra autoref-ing is happening.
179
- LoanCause :: AddrOf |
180
-
181
- // `match x` can move.
182
- LoanCause :: MatchDiscriminant => {
183
- self . set . remove ( & lid) ;
184
- }
185
-
186
- // Do nothing for matches, etc. These can't escape.
187
- _ => { }
188
- }
154
+ self . set . remove ( & lid) ;
189
155
}
190
156
}
191
157
0 commit comments