@@ -164,6 +164,21 @@ impl<'tcx> ScopeCollector<'tcx> {
164
164
cx : Context { temp_lifetime : TemporaryLifetimeScopes :: new_static ( ) , var_parent : None } ,
165
165
}
166
166
}
167
+
168
+ fn is_data_constructor ( & self , callee : & hir:: Expr < ' _ > ) -> bool {
169
+ match callee. kind {
170
+ hir:: ExprKind :: Path ( hir:: QPath :: Resolved (
171
+ _,
172
+ hir:: Path {
173
+ res :
174
+ hir:: def:: Res :: Def ( hir:: def:: DefKind :: Ctor ( _, _) , _)
175
+ | hir:: def:: Res :: SelfCtor ( _) ,
176
+ ..
177
+ } ,
178
+ ) ) => true ,
179
+ _ => false ,
180
+ }
181
+ }
167
182
}
168
183
169
184
impl < ' tcx > ScopeCollector < ' tcx > {
@@ -336,7 +351,7 @@ impl<'tcx> Visitor<'tcx> for ScopeCollector<'tcx> {
336
351
}
337
352
338
353
hir:: ExprKind :: Struct ( _path, fields, struct_base) => {
339
- for hir:: ExprField { expr, .. } in fields {
354
+ for & hir:: ExprField { expr, .. } in fields {
340
355
self . cx . temp_lifetime = prev_temp_lifetime;
341
356
self . cx . temp_lifetime . is_result = true ;
342
357
self . visit_expr ( expr) ;
@@ -349,6 +364,14 @@ impl<'tcx> Visitor<'tcx> for ScopeCollector<'tcx> {
349
364
}
350
365
}
351
366
367
+ hir:: ExprKind :: Call ( callee, args) if self . is_data_constructor ( callee) => {
368
+ for expr in args {
369
+ self . cx . temp_lifetime = prev_temp_lifetime;
370
+ self . cx . temp_lifetime . is_result = true ;
371
+ self . visit_expr ( expr) ;
372
+ }
373
+ }
374
+
352
375
hir:: ExprKind :: Tup ( subexprs) => {
353
376
for subexpr in subexprs {
354
377
self . cx . temp_lifetime = prev_temp_lifetime;
0 commit comments