Skip to content

Commit

Permalink
s/Second borrow/Previous borrow/ in error messages.
Browse files Browse the repository at this point in the history
When a borrow occurs twice illegally, Rust will label the other borrow
as the "second borrow".  This is quite confusing, as the "second borrow"
usually happened before the flagged borrow (e.g. as far as dataflow
is concerned, the first borrow is OK, the second borrow is illegal.)
This patch renames "second borrow" to "previous borrow", to make the
spatial relationship between the two borrows clearer.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
  • Loading branch information
ezyang committed Dec 17, 2013
1 parent dc65762 commit 4584acd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/check_loans.rs
Expand Up @@ -238,7 +238,7 @@ impl<'a> CheckLoanCtxt<'a> {
self.bccx.loan_path_to_str(new_loan.loan_path)));
self.bccx.span_note(
old_loan.span,
format!("second borrow of `{}` as mutable occurs here",
format!("previous borrow of `{}` as mutable occurs here",
self.bccx.loan_path_to_str(new_loan.loan_path)));
return false;
}
Expand All @@ -253,7 +253,7 @@ impl<'a> CheckLoanCtxt<'a> {
self.bccx.mut_to_str(old_loan.mutbl)));
self.bccx.span_note(
old_loan.span,
format!("second borrow of `{}` occurs here",
format!("previous borrow of `{}` occurs here",
self.bccx.loan_path_to_str(new_loan.loan_path)));
return false;
}
Expand Down

5 comments on commit 4584acd

@bors
Copy link
Contributor

@bors bors commented on 4584acd Dec 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from cmr
at ezyang@4584acd

@bors
Copy link
Contributor

@bors bors commented on 4584acd Dec 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ezyang/rust/reword-second-borrow = 4584acd into auto

@bors
Copy link
Contributor

@bors bors commented on 4584acd Dec 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ezyang/rust/reword-second-borrow = 4584acd merged ok, testing candidate = f43402f

@bors
Copy link
Contributor

@bors bors commented on 4584acd Dec 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 4584acd Dec 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = f43402f

Please sign in to comment.