aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2024-02-03 15:43:59 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2024-02-07 12:40:22 +0100
commitce096d34662574f435a16f2af157d5a44361f781 (patch)
tree1f3988fa9076e1da7daa20d7919b53ba42add3b1 /gcc
parent60f8171f5c8c7eec6c3441f735735f31cea2e1d1 (diff)
downloadgcc-ce096d34662574f435a16f2af157d5a44361f781.zip
gcc-ce096d34662574f435a16f2af157d5a44361f781.tar.gz
gcc-ce096d34662574f435a16f2af157d5a44361f781.tar.bz2
gccrs: add testcase to prove issue has already been fixed
Fixes #1483 gcc/testsuite/ChangeLog: * rust/compile/issue-1483.rs: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/rust/compile/issue-1483.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-1483.rs b/gcc/testsuite/rust/compile/issue-1483.rs
new file mode 100644
index 0000000..eda7e13
--- /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);
+}