aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2024-02-03 16:02:36 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2024-02-07 12:40:22 +0100
commit9fecac88d3ce37d3c2c483ea712e48baf904f27b (patch)
treed53ec09562398f46392b49648a853b897e8aeb17 /gcc/testsuite/rust
parentce096d34662574f435a16f2af157d5a44361f781 (diff)
downloadgcc-9fecac88d3ce37d3c2c483ea712e48baf904f27b.zip
gcc-9fecac88d3ce37d3c2c483ea712e48baf904f27b.tar.gz
gcc-9fecac88d3ce37d3c2c483ea712e48baf904f27b.tar.bz2
gccrs: add test cases to prove type inference is working
Fixes #2772 gcc/testsuite/ChangeLog: * rust/compile/issue-2772-1.rs: New test. * rust/compile/issue-2772-2.rs: New test.
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r--gcc/testsuite/rust/compile/issue-2772-1.rs20
-rw-r--r--gcc/testsuite/rust/compile/issue-2772-2.rs20
2 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-2772-1.rs b/gcc/testsuite/rust/compile/issue-2772-1.rs
new file mode 100644
index 0000000..69977db
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-2772-1.rs
@@ -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
index 0000000..b05f2b1
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-2772-2.rs
@@ -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,
+ };
+}