aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-01-12 16:22:17 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2023-04-06 10:47:19 +0200
commit8d1d08cdbcf40897282d9ed20ccf70bf2c93427c (patch)
treeb2193071840e036daf2656c1078bb1f46245371a
parent4141941ae7bd126c31f09b0aa23bc8a14186f496 (diff)
downloadgcc-8d1d08cdbcf40897282d9ed20ccf70bf2c93427c.zip
gcc-8d1d08cdbcf40897282d9ed20ccf70bf2c93427c.tar.gz
gcc-8d1d08cdbcf40897282d9ed20ccf70bf2c93427c.tar.bz2
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 <herron.philip@googlemail.com>
-rw-r--r--gcc/testsuite/rust/execute/torture/issue-1720-2.rs30
1 files changed, 30 insertions, 0 deletions
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 0000000..35833db
--- /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<Rhs = Self> {
+ 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<T: core::ops::Add<Output = i32>>(a: T) -> i32 {
+ a + a
+}
+
+pub fn main() -> i32 {
+ let a = Foo(1);
+
+ bar(a) - 2
+}