]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/restrict-existing-type-bounds.rs
Modify existing bounds if they exist
[rust.git] / tests / ui / suggestions / restrict-existing-type-bounds.rs
1 pub trait TryAdd<Rhs = Self> {
2     type Error;
3     type Output;
4
5     fn try_add(self, rhs: Rhs) -> Result<Self::Output, Self::Error>;
6 }
7
8 impl<T: TryAdd> TryAdd for Option<T> {
9     type Error = <T as TryAdd>::Error;
10     type Output = Option<<T as TryAdd>::Output>;
11
12     fn try_add(self, rhs: Self) -> Result<Self::Output, Self::Error> {
13         Ok(self) //~ ERROR mismatched types
14     }
15 }
16
17 struct Other<A>(A);
18
19 struct X;
20
21 impl<T: TryAdd<Error = X>> TryAdd for Other<T> {
22     type Error = <T as TryAdd>::Error;
23     type Output = Other<<T as TryAdd>::Output>;
24
25     fn try_add(self, rhs: Self) -> Result<Self::Output, Self::Error> {
26         Ok(self) //~ ERROR mismatched types
27     }
28 }
29
30 fn main() {}