Skip to content

Commit

Permalink
Rollup merge of rust-lang#35817 - wesleywiser:fix_35703, r=jonathandt…
Browse files Browse the repository at this point in the history
…urner

Update E0503 to the new format

Fixes rust-lang#35703
Part of rust-lang#35233

r? @jonathandturner
  • Loading branch information
Jonathan Turner authored Aug 22, 2016
2 parents b695049 + 9bb8b65 commit 40f40e6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustc_borrowck/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,13 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
struct_span_err!(self.bccx, span, E0503,
"cannot use `{}` because it was mutably borrowed",
&self.bccx.loan_path_to_string(copy_path))
.span_note(loan_span,
.span_label(loan_span,
&format!("borrow of `{}` occurs here",
&self.bccx.loan_path_to_string(&loan_path))
)
.span_label(span,
&format!("use of borrowed `{}`",
&self.bccx.loan_path_to_string(&loan_path)))
.emit();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fn copy_after_mut_borrow() {
let _x = &mut a.x;
//~^ NOTE borrow of `a.x` occurs here
let _y = a.y; //~ ERROR cannot use
//~^ NOTE use of borrowed `a.x`
}

fn move_after_mut_borrow() {
Expand Down Expand Up @@ -141,6 +142,7 @@ fn copy_after_mut_borrow_nested() {
let _x = &mut a.x.x;
//~^ NOTE borrow of `a.x.x` occurs here
let _y = a.y; //~ ERROR cannot use
//~^ NOTE use of borrowed `a.x.x`
}

fn move_after_mut_borrow_nested() {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-25793.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ macro_rules! width(
($this:expr) => {
$this.width.unwrap()
//~^ ERROR cannot use `self.width` because it was mutably borrowed
//~| NOTE use of borrowed `*self`
}
);

Expand Down
9 changes: 9 additions & 0 deletions src/test/compile-fail/regions-escape-loop-via-vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@
fn broken() {
let mut x = 3;
let mut _y = vec!(&mut x);
//~^ NOTE borrow of `x` occurs here
//~| NOTE borrow of `x` occurs here
//~| NOTE borrow of `x` occurs here
while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
//~^ NOTE use of borrowed `x`
let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
//~^ NOTE use of borrowed `x`
_y.push(&mut z); //~ ERROR `z` does not live long enough
//~^ NOTE does not live long enough
x += 1; //~ ERROR cannot assign
//~^ NOTE assignment to borrowed `x` occurs here
}
//~^ NOTE borrowed value only valid until here
}
//~^ NOTE borrowed value must be valid until here

fn main() { }

0 comments on commit 40f40e6

Please sign in to comment.