parent
490189634b
commit
9bb8b65bdd
4 changed files with 16 additions and 1 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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() { }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue