Skip to content

Commit

Permalink
Test: check implemented for lifetime handling
Browse files Browse the repository at this point in the history
gcc/testsuite/ChangeLog:

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

Signed-off-by: Jakub Dupak <[email protected]>
  • Loading branch information
jdupak authored and CohenArthur committed Jan 22, 2024
1 parent 83b8634 commit 1586de8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions gcc/testsuite/rust/compile/for_lifetimes.rs
Original file line number Diff line number Diff line change
@@ -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 {}

0 comments on commit 1586de8

Please sign in to comment.