Skip to content

Commit b75fbbf

Browse files
committed
Make ui/borrowck/borrowck-overloaded-call.rs robust w.r.t. NLL.
1 parent cf71582 commit b75fbbf

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable
2+
--> $DIR/borrowck-overloaded-call.rs:69:5
3+
|
4+
LL | let sp = &mut s;
5+
| ------ mutable borrow occurs here
6+
LL | s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable
7+
| ^ immutable borrow occurs here
8+
LL | use_mut(sp);
9+
| -- mutable borrow later used here
10+
111
error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable
212
--> $DIR/borrowck-overloaded-call.rs:77:5
313
|
@@ -17,7 +27,7 @@ LL | s(" world".to_string()); //~ ERROR use of moved value: `s`
1727
|
1828
= note: move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait
1929

20-
error: aborting due to 2 previous errors
30+
error: aborting due to 3 previous errors
2131

22-
Some errors occurred: E0382, E0596.
32+
Some errors occurred: E0382, E0502, E0596.
2333
For more information about an error, try `rustc --explain E0382`.

src/test/ui/borrowck/borrowck-overloaded-call.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ fn f() {
6767
};
6868
let sp = &mut s;
6969
s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable
70+
use_mut(sp);
7071
}
71-
7272
fn g() {
7373
let s = SFnMut {
7474
x: 1,
@@ -86,3 +86,5 @@ fn h() {
8686
}
8787

8888
fn main() {}
89+
90+
fn use_mut<T>(_: &mut T) { }

src/test/ui/borrowck/borrowck-overloaded-call.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let sp = &mut s;
55
| - mutable borrow occurs here
66
LL | s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable
77
| ^ immutable borrow occurs here
8+
LL | use_mut(sp);
89
LL | }
910
| - mutable borrow ends here
1011

0 commit comments

Comments
 (0)