@@ -120,44 +120,27 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
120120 self . set . remove ( & lid) ;
121121 }
122122 }
123- }
124- fn consume_pat ( & mut self , consume_pat : & Pat , cmt : & cmt_ < ' tcx > , _: ConsumeMode ) {
125123 let map = & self . cx . tcx . hir ( ) ;
126- if is_argument ( map, consume_pat . hir_id ) {
124+ if is_argument ( map, cmt . hir_id ) {
127125 // 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 ) ;
129127 if let Some ( Node :: Expr ( ..) ) = map. find ( map. get_parent_node ( parent_id) ) {
130128 return ;
131129 }
132130
133131 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 ) ;
135133 }
136134 return ;
137135 }
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- }
155136 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+ }
161144 }
162145 }
163146 }
@@ -166,26 +149,9 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
166149 & mut self ,
167150 cmt : & cmt_ < ' tcx > ,
168151 _: ty:: BorrowKind ,
169- loan_cause : LoanCause ,
170152 ) {
171153 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) ;
189155 }
190156 }
191157
0 commit comments