Skip to content

Commit e0c1ba6

Browse files
author
Cameron Zwarich
committed
---
yaml --- r: 152517 b: refs/heads/try2 c: 036833e h: refs/heads/master i: 152515: e0cccbf v: v3
1 parent 6bcaa7a commit e0c1ba6

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 24b1b79cf1d2a27c3f8d1c518fcfa7a1ec832154
8+
refs/heads/try2: 036833ece95aa5fc9a1110c5691488193138eb8f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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)