summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/regions-proc-bound-capture.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/regions/regions-proc-bound-capture.rs')
-rw-r--r--tests/ui/regions/regions-proc-bound-capture.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/ui/regions/regions-proc-bound-capture.rs b/tests/ui/regions/regions-proc-bound-capture.rs
new file mode 100644
index 000000000..f79d9dc90
--- /dev/null
+++ b/tests/ui/regions/regions-proc-bound-capture.rs
@@ -0,0 +1,13 @@
+fn borrowed_proc<'a>(x: &'a isize) -> Box<dyn FnMut()->(isize) + 'a> {
+ // This is legal, because the region bound on `proc`
+ // states that it captures `x`.
+ Box::new(move|| { *x })
+}
+
+fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + 'static> {
+ // This is illegal, because the region bound on `proc` is 'static.
+ Box::new(move || { *x })
+ //~^ ERROR lifetime may not live long enough
+}
+
+fn main() { }