gcc/testsuite/rust/compile/issue-2190-2.rs
raw| 1 | // { dg-options "-w" } |
| 2 | #[lang = "sized"] |
| 3 | pub trait Sized {} |
| 4 | |
| 5 | #[lang = "deref"] |
| 6 | trait Deref { |
| 7 | type Target; |
| 8 | fn deref(&self) -> &Self::Target; |
| 9 | } |
| 10 | |
| 11 | fn foo<T: Deref<Target = i32>>(t: &T) -> i32 { |
| 12 | t.max(2) |
| 13 | } |
| 14 | |
| 15 | impl i32 { |
| 16 | fn max(self, other: i32) -> i32 { |
| 17 | if self > other { |
| 18 | self |
| 19 | } else { |
| 20 | other |
| 21 | } |
| 22 | } |
| 23 | } |