diff mbox series

[COMMITTED,10/25] gccrs: add testcase to prove issue has already been fixed

Message ID 20240207114419.1100894-11-arthur.cohen@embecosm.com
State New
Headers show
Series [COMMITTED,01/25] gccrs: Parse normal functions with `self` parameter correctly | expand

Commit Message

Arthur Cohen Feb. 7, 2024, 11:43 a.m. UTC
From: Philip Herron <herron.philip@googlemail.com>

Fixes #1483

gcc/testsuite/ChangeLog:

	* rust/compile/issue-1483.rs: New test.
---
 gcc/testsuite/rust/compile/issue-1483.rs | 28 ++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/issue-1483.rs
diff mbox series

Patch

diff --git a/gcc/testsuite/rust/compile/issue-1483.rs b/gcc/testsuite/rust/compile/issue-1483.rs
new file mode 100644
index 00000000000..eda7e139283
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-1483.rs
@@ -0,0 +1,28 @@ 
+#[lang = "sized"]
+pub trait Sized {}
+
+#[lang = "fn_once"]
+pub trait FnOnce<Args> {
+    #[lang = "fn_once_output"]
+    type Output;
+
+    extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
+}
+
+pub fn takes_fn_generic<F: FnOnce(i32) -> i32>(a: i32, f: F) -> i32 {
+    f(a)
+}
+
+pub fn takes_fn_generic_where<F>(a: i32, f: F) -> i32
+where
+    F: FnOnce(i32) -> i32,
+{
+    f(a)
+}
+
+pub fn test() {
+    let foo = |x: i32| -> i32 { x + 1 };
+
+    takes_fn_generic(1, foo);
+    takes_fn_generic_where(2, foo);
+}