Debian Codegraph @

gcc/testsuite/rust/compile/issue-2019-3.rs

raw
1 #[lang = "sized"]
2 pub trait Sized {}
3
4 macro_rules! forward_ref_binop {
5 (impl $imp:ident, $method:ident for $t:ty, $u:ty) => {
6 forward_ref_binop!(impl $imp, $method for $t, $u,
7 #[stable(feature = "rust1", since = "1.0.0")]);
8 };
9 (impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => {
10 #[$attr]
11 impl<'a> $imp<$u> for &'a $t {
12 type Output = <$t as $imp<$u>>::Output;
13
14 #[inline]
15 fn $method(self, other: $u) -> <$t as $imp<$u>>::Output {
16 $imp::$method(*self, other)
17 }
18 }
19
20 #[$attr]
21 impl<'a> $imp<&'a $u> for $t {
22 type Output = <$t as $imp<$u>>::Output;
23
24 #[inline]
25 fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output {
26 $imp::$method(self, *other)
27 }
28 }
29
30 #[$attr]
31 impl<'a, 'b> $imp<&'a $u> for &'b $t {
32 type Output = <$t as $imp<$u>>::Output;
33
34 #[inline]
35 fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output {
36 $imp::$method(*self, *other)
37 }
38 }
39 }
40 }
41
42 #[lang = "add"]
43 pub trait Add<RHS = Self> {
44 type Output;
45
46 fn add(self, rhs: RHS) -> Self::Output;
47 }
48
49 macro_rules! add_impl {
50 ($($t:ty)*) => ($(
51 #[stable(feature = "rust1", since = "1.0.0")]
52 impl Add for $t {
53 type Output = $t;
54
55 fn add(self, other: $t) -> $t { self + other }
56 }
57
58 forward_ref_binop! { impl Add, add for $t, $t }
59 )*)
60 }
61
62 add_impl! { usize u8 u16 u32 u64 /*u128*/ isize i8 i16 i32 i64 /*i128*/ f32 f64 }