From: Philip Herron Date: Sat, 3 Feb 2024 15:43:59 +0000 (+0000) Subject: gccrs: add testcase to prove issue has already been fixed X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=838eab4a46381916a66877ca99a327264d838d54;p=thirdparty%2Fgcc.git gccrs: add testcase to prove issue has already been fixed Fixes #1483 gcc/testsuite/ChangeLog: * rust/compile/issue-1483.rs: New test. --- diff --git a/gcc/testsuite/rust/compile/issue-1483.rs b/gcc/testsuite/rust/compile/issue-1483.rs new file mode 100644 index 000000000000..eda7e139283d --- /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 { + #[lang = "fn_once_output"] + type Output; + + extern "rust-call" fn call_once(self, args: Args) -> Self::Output; +} + +pub fn takes_fn_generic i32>(a: i32, f: F) -> i32 { + f(a) +} + +pub fn takes_fn_generic_where(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); +}