Skip to content

Commit 514f7e8

Browse files
author
Jonathan Turner
committed
---
yaml --- r: 275919 b: refs/heads/borrowck-snippet c: 8c49b35 h: refs/heads/master i: 275917: ede1995 275915: 32faae7 275911: c6c1c5b 275903: bce9c94
1 parent 2f97d50 commit 514f7e8

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ refs/tags/1.5.0: d8027afc009e55fb07776831094a13b1b64b6305
3939
refs/tags/1.6.0: 4fe6048e8dd100ec1c61a020d01f75046b42e818
4040
refs/tags/1.7.0: 2d2a9311cbe05eb47960489259e1e9408062c863
4141
refs/tags/1.8.0: 6bef00072dbaa86da9dc73b09f926cf67c696b39
42-
refs/heads/borrowck-snippet: 03e3a362b434ddeb47fb0aa3a140119ace9e250d
42+
refs/heads/borrowck-snippet: 8c49b353b60adb2719f60ddba686c938d156d61f

branches/borrowck-snippet/src/librustc_borrowck/borrowck/check_loans.rs

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,17 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
648648
copy_path: &LoanPath<'tcx>) {
649649
match self.analyze_restrictions_on_use(id, copy_path, ty::ImmBorrow) {
650650
UseOk => { }
651-
UseWhileBorrowed(loan_path, loan_span) => {
651+
UseWhileBorrowed(_, loan_span) => {
652652
struct_span_err!(self.bccx, span, E0503,
653653
"cannot use `{}` because it was mutably borrowed",
654654
&self.bccx.loan_path_to_string(copy_path))
655-
.span_note(loan_span,
656-
&format!("borrow of `{}` occurs here",
657-
&self.bccx.loan_path_to_string(&loan_path))
655+
.span_label(loan_span,
656+
&format!("mutable borrow of `{}` occurs here",
657+
&self.bccx.loan_path_to_string(copy_path))
658+
)
659+
.span_label(span,
660+
&format!("use of `{}` occurs here",
661+
&self.bccx.loan_path_to_string(copy_path))
658662
)
659663
.emit();
660664
}
@@ -671,25 +675,38 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
671675
// loans are incompatible with that.
672676
match self.analyze_restrictions_on_use(id, move_path, ty::MutBorrow) {
673677
UseOk => { }
674-
UseWhileBorrowed(loan_path, loan_span) => {
678+
UseWhileBorrowed(_, loan_span) => {
675679
let mut err = match move_kind {
676-
move_data::Captured =>
680+
move_data::Captured => {
677681
struct_span_err!(self.bccx, span, E0504,
678682
"cannot move `{}` into closure because it is borrowed",
679-
&self.bccx.loan_path_to_string(move_path)),
683+
&self.bccx.loan_path_to_string(move_path))
684+
.span_label(
685+
loan_span,
686+
&format!("borrow of `{}` occurs here",
687+
&self.bccx.loan_path_to_string(move_path)))
688+
.span_label(
689+
span,
690+
&format!("move of `{}` occurs here",
691+
&self.bccx.loan_path_to_string(move_path)))
692+
}
680693
move_data::Declared |
681694
move_data::MoveExpr |
682-
move_data::MovePat =>
695+
move_data::MovePat => {
683696
struct_span_err!(self.bccx, span, E0505,
684697
"cannot move out of `{}` because it is borrowed",
685698
&self.bccx.loan_path_to_string(move_path))
699+
.span_label(
700+
loan_span,
701+
&format!("borrow of `{}` occurs here",
702+
&self.bccx.loan_path_to_string(move_path)))
703+
.span_label(
704+
span,
705+
&format!("move out of `{}` occurs here",
706+
&self.bccx.loan_path_to_string(move_path)))
707+
}
686708
};
687709

688-
err.span_note(
689-
loan_span,
690-
&format!("borrow of `{}` occurs here",
691-
&self.bccx.loan_path_to_string(&loan_path))
692-
);
693710
err.emit();
694711
}
695712
}
@@ -855,9 +872,12 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
855872
struct_span_err!(self.bccx, span, E0506,
856873
"cannot assign to `{}` because it is borrowed",
857874
self.bccx.loan_path_to_string(loan_path))
858-
.span_note(loan.span,
875+
.span_label(loan.span,
859876
&format!("borrow of `{}` occurs here",
860877
self.bccx.loan_path_to_string(loan_path)))
878+
.span_label(span,
879+
&format!("assignment to `{}` occurs here",
880+
self.bccx.loan_path_to_string(loan_path)))
861881
.emit();
862882
}
863883
}

branches/borrowck-snippet/src/test/compile-fail/borrowck/borrowck-vec-pattern-nesting.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fn a() {
1919
[box ref _a, _, _] => {
2020
//~^ borrow of `vec[..]` occurs here
2121
vec[0] = box 4; //~ ERROR cannot assign
22+
//~^ assignment to `vec[..]` occurs here
2223
}
2324
}
2425
}
@@ -30,6 +31,7 @@ fn b() {
3031
[_b..] => {
3132
//~^ borrow of `vec[..]` occurs here
3233
vec[0] = box 4; //~ ERROR cannot assign
34+
//~^ assignment to `vec[..]` occurs here
3335
}
3436
}
3537
}

branches/borrowck-snippet/src/test/compile-fail/issue-25793.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ macro_rules! width(
1212
($this:expr) => {
1313
$this.width.unwrap()
1414
//~^ ERROR cannot use `self.width` because it was mutably borrowed
15+
//~| use of `self.width` occurs here
1516
}
1617
);
1718

@@ -27,7 +28,7 @@ impl HasInfo {
2728
fn get_other(&mut self) -> usize {
2829
self.get_size(width!(self))
2930
//~^ NOTE in this expansion of width!
30-
//~| NOTE borrow of `*self` occurs here
31+
//~| NOTE mutable borrow of `self.width` occurs here
3132
}
3233
}
3334

0 commit comments

Comments
 (0)