Skip to content

Commit 9bb8b65

Browse files
committed
Update E0503 to the new format
Fixes #35703 Part of #35233
1 parent 4901896 commit 9bb8b65

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

src/librustc_borrowck/borrowck/check_loans.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,13 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
647647
struct_span_err!(self.bccx, span, E0503,
648648
"cannot use `{}` because it was mutably borrowed",
649649
&self.bccx.loan_path_to_string(copy_path))
650-
.span_note(loan_span,
650+
.span_label(loan_span,
651651
&format!("borrow of `{}` occurs here",
652652
&self.bccx.loan_path_to_string(&loan_path))
653653
)
654+
.span_label(span,
655+
&format!("use of borrowed `{}`",
656+
&self.bccx.loan_path_to_string(&loan_path)))
654657
.emit();
655658
}
656659
}

src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fn copy_after_mut_borrow() {
7171
let _x = &mut a.x;
7272
//~^ NOTE borrow of `a.x` occurs here
7373
let _y = a.y; //~ ERROR cannot use
74+
//~^ NOTE use of borrowed `a.x`
7475
}
7576

7677
fn move_after_mut_borrow() {
@@ -141,6 +142,7 @@ fn copy_after_mut_borrow_nested() {
141142
let _x = &mut a.x.x;
142143
//~^ NOTE borrow of `a.x.x` occurs here
143144
let _y = a.y; //~ ERROR cannot use
145+
//~^ NOTE use of borrowed `a.x.x`
144146
}
145147

146148
fn move_after_mut_borrow_nested() {

src/test/compile-fail/issue-25793.rs

+1
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+
//~| NOTE use of borrowed `*self`
1516
}
1617
);
1718

src/test/compile-fail/regions-escape-loop-via-vec.rs

+9
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@
1212
fn broken() {
1313
let mut x = 3;
1414
let mut _y = vec!(&mut x);
15+
//~^ NOTE borrow of `x` occurs here
16+
//~| NOTE borrow of `x` occurs here
17+
//~| NOTE borrow of `x` occurs here
1518
while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
19+
//~^ NOTE use of borrowed `x`
1620
let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
21+
//~^ NOTE use of borrowed `x`
1722
_y.push(&mut z); //~ ERROR `z` does not live long enough
23+
//~^ NOTE does not live long enough
1824
x += 1; //~ ERROR cannot assign
25+
//~^ NOTE assignment to borrowed `x` occurs here
1926
}
27+
//~^ NOTE borrowed value only valid until here
2028
}
29+
//~^ NOTE borrowed value must be valid until here
2130

2231
fn main() { }

0 commit comments

Comments
 (0)