Skip to content

Commit 9f9bf94

Browse files
committed
Make ui/borrowck/borrowck-overloaded-index-move-index.rs robust w.r.t. NLL.
1 parent affddf6 commit 9f9bf94

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
error[E0505]: cannot move out of `s` because it is borrowed
2+
--> $DIR/borrowck-overloaded-index-move-index.rs:60:22
3+
|
4+
LL | let rs = &mut s;
5+
| ------ borrow of `s` occurs here
6+
LL |
7+
LL | println!("{}", f[s]);
8+
| ^ move out of `s` occurs here
9+
...
10+
LL | use_mut(rs);
11+
| -- borrow later used here
12+
13+
error[E0505]: cannot move out of `s` because it is borrowed
14+
--> $DIR/borrowck-overloaded-index-move-index.rs:63:7
15+
|
16+
LL | let rs = &mut s;
17+
| ------ borrow of `s` occurs here
18+
...
19+
LL | f[s] = 10;
20+
| ^ move out of `s` occurs here
21+
...
22+
LL | use_mut(rs);
23+
| -- borrow later used here
24+
125
error[E0382]: use of moved value: `s`
226
--> $DIR/borrowck-overloaded-index-move-index.rs:63:7
327
|
@@ -9,6 +33,7 @@ LL | f[s] = 10;
933
|
1034
= note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
1135

12-
error: aborting due to previous error
36+
error: aborting due to 3 previous errors
1337

14-
For more information about this error, try `rustc --explain E0382`.
38+
Some errors occurred: E0382, E0505.
39+
For more information about an error, try `rustc --explain E0382`.

src/test/ui/borrowck/borrowck-overloaded-index-move-index.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,8 @@ fn main() {
7171
let _j = &i;
7272
println!("{}", s[i]); // no error, i is copy
7373
println!("{}", s[i]);
74+
75+
use_mut(rs);
7476
}
77+
78+
fn use_mut<T>(_: &mut T) { }

0 commit comments

Comments
 (0)