Skip to content

Commit c324043

Browse files
committed
Implement temporary lifetime extension for tuple ctors.
1 parent 6e23095 commit c324043

File tree

1 file changed

+11
-7
lines changed
  • compiler/rustc_hir_analysis/src/check

1 file changed

+11
-7
lines changed

compiler/rustc_hir_analysis/src/check/region.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::mem;
1010

1111
use rustc_data_structures::fx::FxHashMap;
1212
use rustc_hir as hir;
13+
use rustc_hir::def::{DefKind, Res};
1314
use rustc_hir::def_id::DefId;
1415
use rustc_hir::intravisit::{self, Visitor};
1516
use rustc_hir::{Arm, Block, Expr, LetStmt, Pat, PatKind, Stmt};
@@ -752,13 +753,16 @@ fn resolve_local<'tcx>(
752753
record_rvalue_scope_if_borrow_expr(visitor, arm.body, blk_id);
753754
}
754755
}
755-
hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) => {
756-
// FIXME(@dingxiangfei2009): choose call arguments here
757-
// for candidacy for extended parameter rule application
758-
}
759-
hir::ExprKind::Index(..) => {
760-
// FIXME(@dingxiangfei2009): select the indices
761-
// as candidate for rvalue scope rules
756+
hir::ExprKind::Call(func, args) => {
757+
// Recurse into tuple constructors, such as `Some(&temp())`.
758+
if let hir::ExprKind::Path(path) = &func.kind
759+
&& let hir::QPath::Resolved(None, path) = path
760+
&& let Res::SelfCtor(..) | Res::Def(DefKind::Ctor(..), _) = path.res
761+
{
762+
for arg in args {
763+
record_rvalue_scope_if_borrow_expr(visitor, arg, blk_id);
764+
}
765+
}
762766
}
763767
_ => {}
764768
}

0 commit comments

Comments
 (0)