summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/borrowck-for-loop-head-linkage.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/borrowck-for-loop-head-linkage.rs')
-rw-r--r--tests/ui/borrowck/borrowck-for-loop-head-linkage.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-for-loop-head-linkage.rs b/tests/ui/borrowck/borrowck-for-loop-head-linkage.rs
new file mode 100644
index 000000000..a84b695aa
--- /dev/null
+++ b/tests/ui/borrowck/borrowck-for-loop-head-linkage.rs
@@ -0,0 +1,10 @@
+use std::iter::repeat;
+
+fn main() {
+ let mut vector = vec![1, 2];
+ for &x in &vector {
+ let cap = vector.capacity();
+ vector.extend(repeat(0)); //~ ERROR cannot borrow
+ vector[1] = 5; //~ ERROR cannot borrow
+ }
+}