]>
Commit | Line | Data |
---|---|---|
9346a6ac | 1 | use std::ops::Add; |
223e47cc | 2 | |
9346a6ac | 3 | trait BrokenAdd: Copy + Add<Output=Self> { |
1a4d82fc | 4 | fn broken_add<T>(&self, rhs: T) -> Self { |
85aaf69f | 5 | *self + rhs //~ ERROR mismatched types |
60c5eb7d XL |
6 | //~| expected type parameter `Self`, found type parameter `T` |
7 | //~| expected type parameter `Self` | |
8 | //~| found type parameter `T` | |
223e47cc | 9 | } |
223e47cc LB |
10 | } |
11 | ||
9346a6ac | 12 | impl<T: Copy + Add<Output=T>> BrokenAdd for T {} |
1a4d82fc | 13 | |
223e47cc | 14 | pub fn main() { |
c34b1796 | 15 | let foo: u8 = 0; |
1a4d82fc JJ |
16 | let x: u8 = foo.broken_add("hello darkness my old friend".to_string()); |
17 | println!("{}", x); | |
223e47cc | 18 | } |