@@ -164,6 +164,23 @@ 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 (
175
+ hir:: def:: DefKind :: Ctor ( _, _) | hir:: def:: Res :: SelfCtor ( _) ,
176
+ _,
177
+ ) ,
178
+ ..
179
+ } ,
180
+ ) ) => true ,
181
+ _ => false ,
182
+ }
183
+ }
167
184
}
168
185
169
186
impl < ' tcx > ScopeCollector < ' tcx > {
@@ -336,7 +353,7 @@ impl<'tcx> Visitor<'tcx> for ScopeCollector<'tcx> {
336
353
}
337
354
338
355
hir:: ExprKind :: Struct ( _path, fields, struct_base) => {
339
- for hir:: ExprField { expr, .. } in fields {
356
+ for & hir:: ExprField { expr, .. } in fields {
340
357
self . cx . temp_lifetime = prev_temp_lifetime;
341
358
self . cx . temp_lifetime . is_result = true ;
342
359
self . visit_expr ( expr) ;
@@ -349,6 +366,14 @@ impl<'tcx> Visitor<'tcx> for ScopeCollector<'tcx> {
349
366
}
350
367
}
351
368
369
+ hir:: ExprKind :: Call ( callee, args) if self . is_data_constructor ( callee) => {
370
+ for & hir:: ExprField { expr, .. } in args {
371
+ self . cx . temp_lifetime = prev_temp_lifetime;
372
+ self . cx . temp_lifetime . is_result = true ;
373
+ self . visit_expr ( expr) ;
374
+ }
375
+ }
376
+
352
377
hir:: ExprKind :: Tup ( subexprs) => {
353
378
for subexpr in subexprs {
354
379
self . cx . temp_lifetime = prev_temp_lifetime;
0 commit comments