mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-22 20:01:22 -05:00
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>
This commit is contained in:
committed by
Arthur Cohen
parent
4141941ae7
commit
8d1d08cdbc
30
gcc/testsuite/rust/execute/torture/issue-1720-2.rs
Normal file
30
gcc/testsuite/rust/execute/torture/issue-1720-2.rs
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user