summaryrefslogtreecommitdiffstats
path: root/src/test/ui/regions/regions-proc-bound-capture.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/regions/regions-proc-bound-capture.rs')
-rw-r--r--src/test/ui/regions/regions-proc-bound-capture.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/ui/regions/regions-proc-bound-capture.rs b/src/test/ui/regions/regions-proc-bound-capture.rs
new file mode 100644
index 000000000..f79d9dc90
--- /dev/null
+++ b/src/test/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() { }