提交 d2d8fa2a 编写于 作者: C Cameron Zwarich

Make analyze_move_out_from use a loop rather than recursion

It will be simpler to make some of the changes that I need to make to
analyze_move_out if it uses a loop rather than recursion.
上级 3851d68a
......@@ -874,23 +874,30 @@ pub fn analyze_move_out_from(&self,
// We must check every element of a move path. See
// `borrowck-move-subcomponent.rs` for a test case.
// check for a conflicting loan:
let mut ret = MoveOk;
self.each_in_scope_restriction(expr_id, move_path, |loan, _| {
// Any restriction prevents moves.
ret = MoveWhileBorrowed(loan.loan_path.clone(), loan.span);
false
});
let mut loan_path = move_path;
loop {
// check for a conflicting loan:
self.each_in_scope_restriction(expr_id, loan_path, |loan, _| {
// Any restriction prevents moves.
ret = MoveWhileBorrowed(loan.loan_path.clone(), loan.span);
false
});
if ret != MoveOk {
return ret
}
if ret != MoveOk {
return ret
}
match *move_path {
LpVar(_) => MoveOk,
LpExtend(ref subpath, _, _) => {
self.analyze_move_out_from(expr_id, &**subpath)
match *loan_path {
LpVar(_) => {
ret = MoveOk;
break;
}
LpExtend(ref lp_base, _, _) => {
loan_path = &**lp_base;
}
}
}
ret
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册