gcc/testsuite/rust/execute/torture/issue-1720.rs
raw| 1 | #[lang = "sized"] |
| 2 | pub trait Sized {} |
| 3 | |
| 4 | mod core { |
| 5 | mod ops { |
| 6 | #[lang = "add"] |
| 7 | pub trait Add<Rhs = Self> { |
| 8 | type Output; |
| 9 | |
| 10 | fn add(self, rhs: Rhs) -> Self::Output; |
| 11 | } |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | impl core::ops::Add for i32 { |
| 16 | type Output = i32; |
| 17 | |
| 18 | fn add(self, rhs: i32) -> Self::Output { |
| 19 | self + rhs |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | pub fn foo<T: core::ops::Add<Output = i32>>(a: T) -> i32 { |
| 24 | a + a |
| 25 | } |
| 26 | |
| 27 | pub fn main() -> i32 { |
| 28 | foo(1) - 2 |
| 29 | } |