Implement temporary lifetime extension for tuple ctors.
This commit is contained in:
@@ -10,6 +10,7 @@ use std::mem;
|
|||||||
|
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::intravisit::{self, Visitor};
|
use rustc_hir::intravisit::{self, Visitor};
|
||||||
use rustc_hir::{Arm, Block, Expr, LetStmt, Pat, PatKind, Stmt};
|
use rustc_hir::{Arm, Block, Expr, LetStmt, Pat, PatKind, Stmt};
|
||||||
@@ -752,13 +753,16 @@ fn resolve_local<'tcx>(
|
|||||||
record_rvalue_scope_if_borrow_expr(visitor, arm.body, blk_id);
|
record_rvalue_scope_if_borrow_expr(visitor, arm.body, blk_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) => {
|
hir::ExprKind::Call(func, args) => {
|
||||||
// FIXME(@dingxiangfei2009): choose call arguments here
|
// Recurse into tuple constructors, such as `Some(&temp())`.
|
||||||
// for candidacy for extended parameter rule application
|
if let hir::ExprKind::Path(path) = &func.kind
|
||||||
|
&& let hir::QPath::Resolved(None, path) = path
|
||||||
|
&& let Res::SelfCtor(_) | Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) = path.res
|
||||||
|
{
|
||||||
|
for arg in args {
|
||||||
|
record_rvalue_scope_if_borrow_expr(visitor, arg, blk_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
hir::ExprKind::Index(..) => {
|
|
||||||
// FIXME(@dingxiangfei2009): select the indices
|
|
||||||
// as candidate for rvalue scope rules
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user