We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 37f2382 commit cf10bcfCopy full SHA for cf10bcf
src/test/compile-fail/issue-42106.rs renamed to src/test/ui/issue-42106.rs
@@ -10,7 +10,7 @@
10
11
fn do_something<T>(collection: &mut Vec<T>) {
12
let _a = &collection;
13
- collection.swap(1, 2); //~ ERROR E0502
+ collection.swap(1, 2);
14
}
15
16
fn main() {}
src/test/ui/issue-42106.stderr
@@ -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
+
+error: aborting due to 2 previous errors
0 commit comments