gcc/testsuite/rust/compile/issue-2304.rs
raw| 1 | #[lang = "sized"] |
| 2 | pub trait Sized {} |
| 3 | |
| 4 | #[lang = "add"] |
| 5 | pub trait Add<RHS = Self> { |
| 6 | type Output; |
| 7 | |
| 8 | fn add(self, rhs: RHS) -> Self::Output; |
| 9 | } |
| 10 | macro_rules! add_impl { |
| 11 | ($($t:ty)*) => ($( |
| 12 | impl Add for $t { |
| 13 | type Output = $t; |
| 14 | |
| 15 | fn add(self, other: $t) -> $t { self + other } |
| 16 | } |
| 17 | )*) |
| 18 | } |
| 19 | |
| 20 | add_impl! { usize u8 u16 u32 u64 /*isize i8 i16 i32 i64*/ f32 f64 } |
| 21 | |
| 22 | pub fn test() { |
| 23 | let x: usize = 123; |
| 24 | let mut i = 0; |
| 25 | let _bug = i + x; |
| 26 | } |