@@ -164,6 +164,23 @@ impl<'tcx> ScopeCollector<'tcx> {
164164 cx : Context { temp_lifetime : TemporaryLifetimeScopes :: new_static ( ) , var_parent : None } ,
165165 }
166166 }
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+ }
167184}
168185
169186impl < ' tcx > ScopeCollector < ' tcx > {
@@ -336,7 +353,7 @@ impl<'tcx> Visitor<'tcx> for ScopeCollector<'tcx> {
336353 }
337354
338355 hir:: ExprKind :: Struct ( _path, fields, struct_base) => {
339- for hir:: ExprField { expr, .. } in fields {
356+ for & hir:: ExprField { expr, .. } in fields {
340357 self . cx . temp_lifetime = prev_temp_lifetime;
341358 self . cx . temp_lifetime . is_result = true ;
342359 self . visit_expr ( expr) ;
@@ -349,6 +366,14 @@ impl<'tcx> Visitor<'tcx> for ScopeCollector<'tcx> {
349366 }
350367 }
351368
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+
352377 hir:: ExprKind :: Tup ( subexprs) => {
353378 for subexpr in subexprs {
354379 self . cx . temp_lifetime = prev_temp_lifetime;
0 commit comments