Skip to content

Commit

Permalink
gccrs: add test cases to prove type inference is working
Browse files Browse the repository at this point in the history
Fixes #2772

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2772-1.rs: New test.
	* rust/compile/issue-2772-2.rs: New test.
  • Loading branch information
philberty committed Feb 3, 2024
1 parent 838eab4 commit 74c85f3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gcc/testsuite/rust/compile/issue-2772-1.rs
Original file line number Diff line number Diff line change
@@ -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,
};
}
20 changes: 20 additions & 0 deletions gcc/testsuite/rust/compile/issue-2772-2.rs
Original file line number Diff line number Diff line change
@@ -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,
};
}

0 comments on commit 74c85f3

Please sign in to comment.