// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test a case of a trait which extends the same supertrait twice, but // with difference type parameters. Test then that when we don't give // enough information to pick between these, no selection is made. In // this particular case, the two choices are i64/u64 -- so when we use // an integer literal, we wind up falling this literal back to i32. // See also `run-pass/trait-repeated-supertrait.rs`. trait CompareTo { fn same_as(&self, t: T) -> bool; } trait CompareToInts : CompareTo + CompareTo { } impl CompareTo for i64 { fn same_as(&self, t: i64) -> bool { *self == t } } impl CompareTo for i64 { fn same_as(&self, t: u64) -> bool { *self == (t as i64) } } impl CompareToInts for i64 { } fn with_obj(c: &CompareToInts) -> bool { c.same_as(22) //~ ERROR `CompareToInts : CompareTo` is not satisfied } fn with_trait(c: &C) -> bool { c.same_as(22) //~ ERROR `C : CompareTo` is not satisfied } fn with_ufcs1(c: &C) -> bool { CompareToInts::same_as(c, 22) //~ ERROR `CompareToInts : CompareTo` is not satisfied } fn with_ufcs2(c: &C) -> bool { CompareTo::same_as(c, 22) //~ ERROR `C : CompareTo` is not satisfied } fn main() { assert_eq!(22_i64.same_as(22), true); //~ ERROR `i64 : CompareTo` is not satisfied }