Skip to content

Commit 036833e

Browse files
author
Cameron Zwarich
committed
Rename analyze_move_out_from to analyze_restrictions_on_use
Also rename MoveError to UseError and MoveOk / MoveWhileBorrowed to UseOk / UseWhileBorrowed.
1 parent 24b1b79 commit 036833e

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ pub fn check_loans(bccx: &BorrowckCtxt,
150150
}
151151

152152
#[deriving(PartialEq)]
153-
enum MoveError {
154-
MoveOk,
155-
MoveWhileBorrowed(/*loan*/Rc<LoanPath>, /*loan*/Span)
153+
enum UseError {
154+
UseOk,
155+
UseWhileBorrowed(/*loan*/Rc<LoanPath>, /*loan*/Span)
156156
}
157157

158158
impl<'a> CheckLoanCtxt<'a> {
@@ -479,9 +479,9 @@ impl<'a> CheckLoanCtxt<'a> {
479479
// We want to detect if there are any loans at all, so we search for
480480
// any loans incompatible with MutBorrrow, since all other kinds of
481481
// loans are incompatible with that.
482-
match self.analyze_move_out_from(id, move_path, ty::MutBorrow) {
483-
MoveOk => { }
484-
MoveWhileBorrowed(loan_path, loan_span) => {
482+
match self.analyze_restrictions_on_use(id, move_path, ty::MutBorrow) {
483+
UseOk => { }
484+
UseWhileBorrowed(loan_path, loan_span) => {
485485
let err_message = match move_kind {
486486
move_data::Captured =>
487487
format!("cannot move `{}` into closure because it is borrowed",
@@ -866,16 +866,16 @@ impl<'a> CheckLoanCtxt<'a> {
866866
self.bccx.loan_path_to_str(loan_path)).as_slice());
867867
}
868868

869-
pub fn analyze_move_out_from(&self,
870-
expr_id: ast::NodeId,
871-
move_path: &LoanPath,
872-
borrow_kind: ty::BorrowKind)
873-
-> MoveError {
874-
debug!("analyze_move_out_from(expr_id={:?}, move_path={})",
869+
pub fn analyze_restrictions_on_use(&self,
870+
expr_id: ast::NodeId,
871+
use_path: &LoanPath,
872+
borrow_kind: ty::BorrowKind)
873+
-> UseError {
874+
debug!("analyze_restrictions_on_use(expr_id={:?}, use_path={})",
875875
self.tcx().map.node_to_str(expr_id),
876-
move_path.repr(self.tcx()));
876+
use_path.repr(self.tcx()));
877877

878-
let mut ret = MoveOk;
878+
let mut ret = UseOk;
879879

880880
// First, we check for a restriction on the path P being used. This
881881
// accounts for borrows of P but also borrows of subpaths, like P.a.b.
@@ -884,9 +884,9 @@ impl<'a> CheckLoanCtxt<'a> {
884884
// let x = &mut a.b.c; // Restricts a, a.b, and a.b.c
885885
// let y = a; // Conflicts with restriction
886886

887-
self.each_in_scope_restriction(expr_id, move_path, |loan, _restr| {
887+
self.each_in_scope_restriction(expr_id, use_path, |loan, _restr| {
888888
if incompatible(loan.kind, borrow_kind) {
889-
ret = MoveWhileBorrowed(loan.loan_path.clone(), loan.span);
889+
ret = UseWhileBorrowed(loan.loan_path.clone(), loan.span);
890890
false
891891
} else {
892892
true
@@ -905,12 +905,12 @@ impl<'a> CheckLoanCtxt<'a> {
905905
// let x = &mut a.b;
906906
// let y = a.c;
907907

908-
let mut loan_path = move_path;
908+
let mut loan_path = use_path;
909909
loop {
910910
self.each_in_scope_loan(expr_id, |loan| {
911911
if *loan.loan_path == *loan_path &&
912912
incompatible(loan.kind, borrow_kind) {
913-
ret = MoveWhileBorrowed(loan.loan_path.clone(), loan.span);
913+
ret = UseWhileBorrowed(loan.loan_path.clone(), loan.span);
914914
false
915915
} else {
916916
true

0 commit comments

Comments
 (0)