]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | #![feature(const_trait_impl)] |
2 | ||
3 | pub struct Int(i32); | |
4 | ||
923072b8 | 5 | impl const std::ops::Add for i32 { |
04454e1e | 6 | //~^ ERROR only traits defined in the current crate can be implemented for primitive types |
74b04a01 XL |
7 | type Output = Self; |
8 | ||
9 | fn add(self, rhs: Self) -> Self { | |
10 | self + rhs | |
11 | } | |
12 | } | |
13 | ||
923072b8 | 14 | impl std::ops::Add for Int { |
74b04a01 XL |
15 | type Output = Self; |
16 | ||
17 | fn add(self, rhs: Self) -> Self { | |
18 | Int(self.0 + rhs.0) | |
19 | } | |
20 | } | |
21 | ||
923072b8 | 22 | impl const std::ops::Add for Int { |
74b04a01 XL |
23 | //~^ ERROR conflicting implementations of trait |
24 | type Output = Self; | |
25 | ||
26 | fn add(self, rhs: Self) -> Self { | |
27 | Int(self.0 + rhs.0) | |
28 | } | |
29 | } | |
30 | ||
31 | fn main() {} |