Skip to content

Commit cf10bcf

Browse files
author
Josh Leeb-du Toit
committed
Move issue-42106 test from compile-fail to ui
1 parent 37f2382 commit cf10bcf

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/test/compile-fail/issue-42106.rs renamed to src/test/ui/issue-42106.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
fn do_something<T>(collection: &mut Vec<T>) {
1212
let _a = &collection;
13-
collection.swap(1, 2); //~ ERROR E0502
13+
collection.swap(1, 2);
1414
}
1515

1616
fn main() {}

src/test/ui/issue-42106.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable
2+
--> $DIR/issue-42106.rs:13:5
3+
|
4+
12 | let _a = &collection;
5+
| ---------- immutable borrow occurs here
6+
13 | collection.swap(1, 2);
7+
| ^^^^^^^^^^ mutable borrow occurs here
8+
14 | }
9+
| - immutable borrow ends here
10+
11+
error: aborting due to 2 previous errors
12+

0 commit comments

Comments
 (0)