summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/regions-static-closure.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/regions/regions-static-closure.rs')
-rw-r--r--tests/ui/regions/regions-static-closure.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ui/regions/regions-static-closure.rs b/tests/ui/regions/regions-static-closure.rs
new file mode 100644
index 000000000..09cd56220
--- /dev/null
+++ b/tests/ui/regions/regions-static-closure.rs
@@ -0,0 +1,19 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+struct closure_box<'a> {
+ cl: Box<dyn FnMut() + 'a>,
+}
+
+fn box_it<'a>(x: Box<dyn FnMut() + 'a>) -> closure_box<'a> {
+ closure_box {cl: x}
+}
+
+fn call_static_closure(mut cl: closure_box<'static>) {
+ (cl.cl)();
+}
+
+pub fn main() {
+ let cl_box = box_it(Box::new(|| println!("Hello, world!")));
+ call_static_closure(cl_box);
+}