mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
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.
This commit is contained in:
parent
3851d68a27
commit
d2d8fa2a09
@ -874,23 +874,30 @@ impl<'a> CheckLoanCtxt<'a> {
|
|||||||
// We must check every element of a move path. See
|
// We must check every element of a move path. See
|
||||||
// `borrowck-move-subcomponent.rs` for a test case.
|
// `borrowck-move-subcomponent.rs` for a test case.
|
||||||
|
|
||||||
// check for a conflicting loan:
|
|
||||||
let mut ret = MoveOk;
|
let mut ret = MoveOk;
|
||||||
self.each_in_scope_restriction(expr_id, move_path, |loan, _| {
|
let mut loan_path = move_path;
|
||||||
// Any restriction prevents moves.
|
loop {
|
||||||
ret = MoveWhileBorrowed(loan.loan_path.clone(), loan.span);
|
// check for a conflicting loan:
|
||||||
false
|
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 {
|
if ret != MoveOk {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
match *move_path {
|
match *loan_path {
|
||||||
LpVar(_) => MoveOk,
|
LpVar(_) => {
|
||||||
LpExtend(ref subpath, _, _) => {
|
ret = MoveOk;
|
||||||
self.analyze_move_out_from(expr_id, &**subpath)
|
break;
|
||||||
|
}
|
||||||
|
LpExtend(ref lp_base, _, _) => {
|
||||||
|
loan_path = &**lp_base;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user