Skip to content

Update E0503 to the new format #35817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() { }