From: Philip Herron Date: Thu, 12 Jan 2023 16:22:17 +0000 (+0000) Subject: gccrs: Add another test case for passing associated type-bounds X-Git-Tag: basepoints/gcc-14~148 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d1d08cdbcf40897282d9ed20ccf70bf2c93427c;p=thirdparty%2Fgcc.git gccrs: Add another test case for passing associated type-bounds This demonstrates that this also works for custom algebraic data types too. gcc/testsuite/ChangeLog: * rust/execute/torture/issue-1720-2.rs: New test. Signed-off-by: Philip Herron --- diff --git a/gcc/testsuite/rust/execute/torture/issue-1720-2.rs b/gcc/testsuite/rust/execute/torture/issue-1720-2.rs new file mode 100644 index 000000000000..35833dbb813a --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/issue-1720-2.rs @@ -0,0 +1,30 @@ +mod core { + mod ops { + #[lang = "add"] + pub trait Add { + type Output; + + fn add(self, rhs: Rhs) -> Self::Output; + } + } +} + +struct Foo(i32); + +impl core::ops::Add for Foo { + type Output = i32; + + fn add(self, rhs: Foo) -> Self::Output { + self.0 + rhs.0 + } +} + +pub fn bar>(a: T) -> i32 { + a + a +} + +pub fn main() -> i32 { + let a = Foo(1); + + bar(a) - 2 +}