about summary refs log tree commit diff
path: root/tests/ui/impl-trait/precise-capturing/foreign-2021.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/impl-trait/precise-capturing/foreign-2021.rs')
-rw-r--r--tests/ui/impl-trait/precise-capturing/foreign-2021.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/precise-capturing/foreign-2021.rs b/tests/ui/impl-trait/precise-capturing/foreign-2021.rs
new file mode 100644
index 00000000000..aee412ff7f1
--- /dev/null
+++ b/tests/ui/impl-trait/precise-capturing/foreign-2021.rs
@@ -0,0 +1,15 @@
+//@ aux-build: foreign.rs
+
+extern crate foreign;
+
+fn main() {
+    let mut x = vec![];
+    let h = foreign::hello(&x);
+    //~^ NOTE this call may capture more lifetimes than intended
+    //~| NOTE immutable borrow occurs here
+    x.push(0);
+    //~^ ERROR cannot borrow `x` as mutable
+    //~| NOTE mutable borrow occurs here
+    println!("{h}");
+    //~^ NOTE immutable borrow later used here
+}