]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Test: check implemented for lifetime handling
authorJakub Dupak <dev@jakubdupak.com>
Thu, 18 Jan 2024 13:37:58 +0000 (14:37 +0100)
committerCohenArthur <arthur.cohen@embecosm.com>
Mon, 22 Jan 2024 10:05:47 +0000 (10:05 +0000)
gcc/testsuite/ChangeLog:

* rust/compile/for_lifetimes.rs: New test.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/testsuite/rust/compile/for_lifetimes.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/compile/for_lifetimes.rs b/gcc/testsuite/rust/compile/for_lifetimes.rs
new file mode 100644 (file)
index 0000000..2646962
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-additional-options "-frust-compile-until=typecheck" }
+
+fn function_pointer_as_argument(f: for<'a> fn(&'a i32) -> &'a i32) -> i32 {
+    0
+}
+
+fn function_pointer_as_return() -> for<'a> fn(&'a i32) -> &'a i32 {
+}
+
+// https://doc.rust-lang.org/reference/trait-bounds.html
+
+trait Fn<T> {}
+fn call_on_ref_zero<F>(f: F) where for<'a> F: Fn(&'a i32) {}
+
+fn call_on_ref_zero2<F>(f: F) where F: for<'a> Fn(&'a i32) {}
+
+trait Trait<'a, T: 'a> {}
+
+impl<'a, T> Trait<'a, T> for &'a T {}
\ No newline at end of file