]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: add test cases to prove type inference is working
authorPhilip Herron <herron.philip@googlemail.com>
Sat, 3 Feb 2024 16:02:36 +0000 (16:02 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Wed, 7 Feb 2024 11:40:22 +0000 (12:40 +0100)
Fixes #2772

gcc/testsuite/ChangeLog:

* rust/compile/issue-2772-1.rs: New test.
* rust/compile/issue-2772-2.rs: New test.

gcc/testsuite/rust/compile/issue-2772-1.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/issue-2772-2.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/compile/issue-2772-1.rs b/gcc/testsuite/rust/compile/issue-2772-1.rs
new file mode 100644 (file)
index 0000000..69977db
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-options "-w" }
+#[lang = "sized"]
+pub trait Sized {}
+
+struct Pair<'a, T, U>
+where
+    T: 'a,
+    U: 'a,
+{
+    left: T,
+    right: U,
+}
+
+pub fn test<'a>() {
+    let a: i32 = 50;
+    let x = Pair {
+        left: &&a,
+        right: &a,
+    };
+}
diff --git a/gcc/testsuite/rust/compile/issue-2772-2.rs b/gcc/testsuite/rust/compile/issue-2772-2.rs
new file mode 100644 (file)
index 0000000..b05f2b1
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-options "-w" }
+#[lang = "sized"]
+pub trait Sized {}
+
+struct Pair<'a, T, U>
+where
+    T: 'a,
+    U: 'a,
+{
+    left: T,
+    right: U,
+}
+
+pub fn test<'a>() {
+    let a: i32 = 50;
+    let x = Pair::<&'_ _, &'_ _> {
+        left: &&a,
+        right: &a,
+    };
+}