2 // Test a case of a trait which extends the same supertrait twice, but
3 // with difference type parameters. Test that we can invoke the
4 // various methods in various ways successfully.
5 // See also `compile-fail/trait-repeated-supertrait-ambig.rs`.
9 fn same_as(&self, t
: T
) -> bool
;
12 trait CompareToInts
: CompareTo
<i64> + CompareTo
<u64> {
15 impl CompareTo
<i64> for i64 {
16 fn same_as(&self, t
: i64) -> bool { *self == t }
19 impl CompareTo
<u64> for i64 {
20 fn same_as(&self, t
: u64) -> bool { *self == (t as i64) }
23 impl CompareToInts
for i64 { }
25 fn with_obj(c
: &dyn CompareToInts
) -> bool
{
26 c
.same_as(22_i64) && c
.same_as(22_u64)
29 fn with_trait
<C
:CompareToInts
>(c
: &C
) -> bool
{
30 c
.same_as(22_i64) && c
.same_as(22_u64)
33 fn with_ufcs1
<C
:CompareToInts
>(c
: &C
) -> bool
{
34 CompareToInts
::same_as(c
, 22_i64) && CompareToInts
::same_as(c
, 22_u64)
37 fn with_ufcs2
<C
:CompareToInts
>(c
: &C
) -> bool
{
38 CompareTo
::same_as(c
, 22_i64) && CompareTo
::same_as(c
, 22_u64)
42 assert_eq
!(22_i64.same_as(22_i64), true);
43 assert_eq
!(22_i64.same_as(22_u64), true);
44 assert_eq
!(with_trait(&22), true);
45 assert_eq
!(with_obj(&22), true);
46 assert_eq
!(with_ufcs1(&22), true);
47 assert_eq
!(with_ufcs2(&22), true);